Skip to content

Commit d9b6c78

Browse files
committed
fix gotestsum paths
1 parent f02227d commit d9b6c78

5 files changed

Lines changed: 49 additions & 49 deletions

File tree

scripts/run-unit-tests-container.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ go run ./testcases/downloadModels.go
1010

1111
echo "Running ORT tests..."
1212

13-
gotestsum --format testname --junitfile=$folder/unit-ort.xml --jsonfile=$folder/unit-ort.json -- -coverprofile=$folder/cover-ort.out -coverpkg ./... -tags=ORT -timeout 60m -race
13+
gotestsum --format testname --junitfile=$folder/unit-ort.xml --jsonfile=$folder/unit-ort.json -- -coverprofile=$folder/cover-ort.out -coverpkg ./... -tags=ORT -timeout 60m -race ./...
1414

1515
echo "ORT tests completed."
1616

1717
echo "Running XLA tests..."
1818

19-
gotestsum --format testname --junitfile=$folder/unit-xla.xml --jsonfile=$folder/unit-xla.json -- -coverprofile=$folder/cover-xla.out -coverpkg ./... -tags=XLA -timeout 60m
19+
gotestsum --format testname --junitfile=$folder/unit-xla.xml --jsonfile=$folder/unit-xla.json -- -coverprofile=$folder/cover-xla.out -coverpkg ./... -tags=XLA -timeout 60m ./...
2020

2121
echo "XLA tests completed."
2222

2323
# echo "Running training tests..."
2424

25-
gotestsum --format testname --junitfile=$folder/unit-training.xml --jsonfile=$folder/unit-training.json -- -coverprofile=$folder/cover-training.out -coverpkg ./... -tags=ORT,XLA,TRAINING -timeout 60m
25+
gotestsum --format testname --junitfile=$folder/unit-training.xml --jsonfile=$folder/unit-training.json -- -coverprofile=$folder/cover-training.out -coverpkg ./... -tags=ORT,XLA,TRAINING -timeout 60m ./...
2626

2727
echo "Training tests completed."
2828

2929
# echo "Running simplego tests..."
3030

31-
gotestsum --format testname --junitfile=$folder/unit-go.xml --jsonfile=$folder/unit-go.json -- -tags=GO -timeout 60m
31+
gotestsum --format testname --junitfile=$folder/unit-go.xml --jsonfile=$folder/unit-go.json -- -coverprofile=$folder/cover-go.out -coverpkg ./... -tags=GO -timeout 60m ./...
3232

3333
# echo "simplego tests completed."
3434

tests/go/hugot_go_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func TestReadmeExample(t *testing.T) {
295295
// drop the dependency on huggingfaceModelDownloader.
296296
// modelPath, err := DownloadModel("KnightsAnalytics/distilbert-base-uncased-finetuned-sst-2-english", "./models/", NewDownloadOptions())
297297
// check(err)
298-
modelPath := "./models/KnightsAnalytics_distilbert-base-uncased-finetuned-sst-2-english"
298+
modelPath := testutil.ModelsFolder + "KnightsAnalytics_distilbert-base-uncased-finetuned-sst-2-english"
299299

300300
// we now create the configuration for the text classification pipeline we want to create.
301301
// Options to the pipeline can be set here using the Options field

tests/ort/hugot_ort_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func runBenchmarkEmbedding(ctx context.Context, strings *[]string, cuda bool) {
488488
}
489489
}(session)
490490

491-
modelPath := "./models/KnightsAnalytics_all-MiniLM-L6-v2"
491+
modelPath := testutil.ModelsFolder + "KnightsAnalytics_all-MiniLM-L6-v2"
492492
config := hugot.FeatureExtractionConfig{
493493
ModelPath: modelPath,
494494
Name: "benchmarkEmbedding",

tests/training/hugot_training_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,25 @@ func trainSimilarity(t *testing.T,
109109
// we now write the fine-tuned pipeline back to disk as an onnx model.
110110
// This will also copy the tokenizer files for you. If your models are on s3
111111
// this can also work (see documentation).
112-
if e := trainingSession.Save(t.Context(), "./models/testTrain"); e != nil {
112+
if e := trainingSession.Save(t.Context(), testutil.ModelsFolder + "testTrain"); e != nil {
113113
t.Fatal(e)
114114
}
115-
if _, err := os.Stat("./models/testTrain"); err != nil {
115+
if _, err := os.Stat(testutil.ModelsFolder + "testTrain"); err != nil {
116116
t.Fatal(err)
117117
}
118118

119119
defer func() {
120-
if err = os.RemoveAll("./models/testTrain"); err != nil {
120+
if err = os.RemoveAll(testutil.ModelsFolder + "testTrain"); err != nil {
121121
t.Fatal(err)
122122
}
123123
}()
124124

125125
// we now load the newly trained onnx model and generate the predictions with onnxruntime backend
126-
return runModel(t, "ORT", examplesLHS, examplesRHS, "./models/testTrain")
126+
return runModel(t, "ORT", examplesLHS, examplesRHS, testutil.ModelsFolder + "testTrain")
127127
}
128128

129129
func TestTrainSemanticSimilarity(t *testing.T) {
130-
modelPath := "./models/KnightsAnalytics_all-MiniLM-L6-v2"
130+
modelPath := testutil.ModelsFolder + "KnightsAnalytics_all-MiniLM-L6-v2"
131131

132132
// each line in this dataset is an example. In training we will use the dataset object but for inference
133133
// we just load the strings here.
@@ -251,7 +251,7 @@ func TestTrainSemanticSimilarityCuda(t *testing.T) {
251251
t.Fatal(err)
252252
}
253253

254-
modelPath := "./models/KnightsAnalytics_all-MiniLM-L6-v2"
254+
modelPath := testutil.ModelsFolder + "KnightsAnalytics_all-MiniLM-L6-v2"
255255

256256
session, err := hugot.NewXLATrainingSession[*pipelines.FeatureExtractionPipeline](
257257
t.Context(),
@@ -275,15 +275,15 @@ func TestTrainSemanticSimilarityCuda(t *testing.T) {
275275
}
276276

277277
// we now write the fine-tuned pipeline back to disk as an onnx model
278-
if e := session.Save(t.Context(), "./models/testTrain"); e != nil {
278+
if e := session.Save(t.Context(), testutil.ModelsFolder + "testTrain"); e != nil {
279279
t.Fatal(e)
280280
}
281-
if exists, existsErr := fileutil.FileExists(t.Context(), "./models/testTrain"); existsErr != nil {
281+
if exists, existsErr := fileutil.FileExists(t.Context(), testutil.ModelsFolder + "testTrain"); existsErr != nil {
282282
t.Fatal(err)
283283
} else if !exists {
284-
t.Fatal("model file ./models/testTrain does not exist")
284+
t.Fatal("model file " + testutil.ModelsFolder + "testTrain does not exist")
285285
}
286-
if err = fileutil.DeleteFile(t.Context(), "./models/testTrain"); err != nil {
286+
if err = fileutil.DeleteFile(t.Context(), testutil.ModelsFolder + "testTrain"); err != nil {
287287
t.Fatal(err)
288288
}
289289
}
@@ -298,7 +298,7 @@ func TestTrainSemanticSimilarityGo(t *testing.T) {
298298
t.Fatal(err)
299299
}
300300

301-
modelPath := "./models/KnightsAnalytics_all-MiniLM-L6-v2"
301+
modelPath := testutil.ModelsFolder + "KnightsAnalytics_all-MiniLM-L6-v2"
302302

303303
session, err := hugot.NewGoTrainingSession[*pipelines.FeatureExtractionPipeline](
304304
t.Context(),
@@ -321,21 +321,21 @@ func TestTrainSemanticSimilarityGo(t *testing.T) {
321321
}
322322

323323
// we now write the fine-tuned pipeline back to disk as an onnx model
324-
if e := session.Save(t.Context(), "./models/testTrain"); e != nil {
324+
if e := session.Save(t.Context(), testutil.ModelsFolder + "testTrain"); e != nil {
325325
t.Fatal(e)
326326
}
327-
if exists, existsErr := fileutil.FileExists(t.Context(), "./models/testTrain"); existsErr != nil {
327+
if exists, existsErr := fileutil.FileExists(t.Context(), testutil.ModelsFolder + "testTrain"); existsErr != nil {
328328
t.Fatal(err)
329329
} else if !exists {
330-
t.Fatal("model file ./models/testTrain does not exist")
330+
t.Fatal("model file " + testutil.ModelsFolder + "testTrain does not exist")
331331
}
332-
if err = fileutil.DeleteFile(t.Context(), "./models/testTrain"); err != nil {
332+
if err = fileutil.DeleteFile(t.Context(), testutil.ModelsFolder + "testTrain"); err != nil {
333333
t.Fatal(err)
334334
}
335335
}
336336

337337
func TestEarlyStopping(t *testing.T) {
338-
modelPath := "./models/KnightsAnalytics_all-MiniLM-L6-v2"
338+
modelPath := testutil.ModelsFolder + "KnightsAnalytics_all-MiniLM-L6-v2"
339339

340340
trainDataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), "./testcases/semanticSimilarityTest.jsonl", 1, nil)
341341
if err != nil {
@@ -347,7 +347,7 @@ func TestEarlyStopping(t *testing.T) {
347347
}
348348

349349
defer func() {
350-
err := os.RemoveAll("./models/testTrainEval")
350+
err := os.RemoveAll(testutil.ModelsFolder + "testTrainEval")
351351
if err != nil {
352352
t.Fatal(err)
353353
}
@@ -377,7 +377,7 @@ func TestEarlyStopping(t *testing.T) {
377377
}
378378

379379
// save the model
380-
if saveErr := trainingSession.Save(t.Context(), "./models/testTrainEval"); saveErr != nil {
380+
if saveErr := trainingSession.Save(t.Context(), testutil.ModelsFolder + "testTrainEval"); saveErr != nil {
381381
t.Fatal(saveErr)
382382
}
383383
}

tests/utils.go

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"github.com/knights-analytics/hugot/util/imageutil"
2222
)
2323

24-
const modelsFolder = "../../models/"
24+
const ModelsFolder = "../../models/"
2525

2626
// test download validation
2727

@@ -41,7 +41,7 @@ func TestDownloadValidation(t *testing.T) {
4141
func FeatureExtractionPipeline(t *testing.T, session *hugot.Session) {
4242
t.Helper()
4343

44-
modelPath := modelsFolder + "KnightsAnalytics_all-MiniLM-L6-v2"
44+
modelPath := ModelsFolder + "KnightsAnalytics_all-MiniLM-L6-v2"
4545

4646
config := hugot.FeatureExtractionConfig{
4747
ModelPath: modelPath,
@@ -167,7 +167,7 @@ func FeatureExtractionPipeline(t *testing.T, session *hugot.Session) {
167167
func FeatureExtractionPipelineValidation(t *testing.T, session *hugot.Session) {
168168
t.Helper()
169169

170-
modelPath := modelsFolder + "KnightsAnalytics_all-MiniLM-L6-v2"
170+
modelPath := ModelsFolder + "KnightsAnalytics_all-MiniLM-L6-v2"
171171
config := hugot.FeatureExtractionConfig{
172172
ModelPath: modelPath,
173173
OnnxFilename: "model.onnx",
@@ -191,7 +191,7 @@ func FeatureExtractionPipelineValidation(t *testing.T, session *hugot.Session) {
191191
func TextClassificationPipeline(t *testing.T, session *hugot.Session) {
192192
t.Helper()
193193

194-
modelPath := modelsFolder + "KnightsAnalytics_distilbert-base-uncased-finetuned-sst-2-english"
194+
modelPath := ModelsFolder + "KnightsAnalytics_distilbert-base-uncased-finetuned-sst-2-english"
195195

196196
config := hugot.TextClassificationConfig{
197197
ModelPath: modelPath,
@@ -245,7 +245,7 @@ func TextClassificationPipeline(t *testing.T, session *hugot.Session) {
245245
func TextClassificationPipelineMulti(t *testing.T, session *hugot.Session) {
246246
t.Helper()
247247

248-
modelPathMulti := modelsFolder + "KnightsAnalytics_roberta-base-go_emotions"
248+
modelPathMulti := ModelsFolder + "KnightsAnalytics_roberta-base-go_emotions"
249249

250250
configMulti := hugot.TextClassificationConfig{
251251
ModelPath: modelPathMulti,
@@ -408,7 +408,7 @@ func TextClassificationPipelineMulti(t *testing.T, session *hugot.Session) {
408408
func TextClassificationPipelineValidation(t *testing.T, session *hugot.Session) {
409409
t.Helper()
410410

411-
modelPath := modelsFolder + "KnightsAnalytics_distilbert-base-uncased-finetuned-sst-2-english"
411+
modelPath := ModelsFolder + "KnightsAnalytics_distilbert-base-uncased-finetuned-sst-2-english"
412412

413413
config := hugot.TextClassificationConfig{
414414
ModelPath: modelPath,
@@ -446,7 +446,7 @@ func TextClassificationPipelineValidation(t *testing.T, session *hugot.Session)
446446
func ZeroShotClassificationPipeline(t *testing.T, session *hugot.Session) {
447447
t.Helper()
448448

449-
modelPath := modelsFolder + "KnightsAnalytics_deberta-v3-base-zeroshot-v1"
449+
modelPath := ModelsFolder + "KnightsAnalytics_deberta-v3-base-zeroshot-v1"
450450

451451
config := hugot.ZeroShotClassificationConfig{
452452
ModelPath: modelPath,
@@ -670,7 +670,7 @@ func ZeroShotClassificationPipeline(t *testing.T, session *hugot.Session) {
670670
func ZeroShotClassificationPipelineValidation(t *testing.T, session *hugot.Session) {
671671
t.Helper()
672672

673-
modelPath := modelsFolder + "KnightsAnalytics_deberta-v3-base-zeroshot-v1"
673+
modelPath := ModelsFolder + "KnightsAnalytics_deberta-v3-base-zeroshot-v1"
674674

675675
config := hugot.TextClassificationConfig{
676676
ModelPath: modelPath,
@@ -705,7 +705,7 @@ func ZeroShotClassificationPipelineValidation(t *testing.T, session *hugot.Sessi
705705
func TokenClassificationPipeline(t *testing.T, session *hugot.Session) {
706706
t.Helper()
707707

708-
modelPath := modelsFolder + "KnightsAnalytics_distilbert-NER"
708+
modelPath := ModelsFolder + "KnightsAnalytics_distilbert-NER"
709709
configSimple := hugot.TokenClassificationConfig{
710710
ModelPath: modelPath,
711711
Name: "testPipelineSimple",
@@ -849,7 +849,7 @@ func TokenClassificationPipeline(t *testing.T, session *hugot.Session) {
849849
func TokenClassificationPipelineValidation(t *testing.T, session *hugot.Session) {
850850
t.Helper()
851851

852-
modelPath := modelsFolder + "KnightsAnalytics_distilbert-NER"
852+
modelPath := ModelsFolder + "KnightsAnalytics_distilbert-NER"
853853
configSimple := hugot.TokenClassificationConfig{
854854
ModelPath: modelPath,
855855
Name: "testPipelineSimple",
@@ -887,7 +887,7 @@ func TokenClassificationPipelineValidation(t *testing.T, session *hugot.Session)
887887
func CrossEncoderPipeline(t *testing.T, session *hugot.Session) {
888888
t.Helper()
889889
config := hugot.CrossEncoderConfig{
890-
ModelPath: modelsFolder + "KnightsAnalytics_jina-reranker-v1-tiny-en",
890+
ModelPath: ModelsFolder + "KnightsAnalytics_jina-reranker-v1-tiny-en",
891891
Name: "test-cross-encoder",
892892
}
893893
pipeline, err := hugot.NewPipeline(session, config)
@@ -943,7 +943,7 @@ func CrossEncoderPipeline(t *testing.T, session *hugot.Session) {
943943
func CrossEncoderPipelineValidation(t *testing.T, session *hugot.Session) {
944944
t.Helper()
945945
config := hugot.CrossEncoderConfig{
946-
ModelPath: modelsFolder + "KnightsAnalytics_jina-reranker-v1-tiny-en",
946+
ModelPath: ModelsFolder + "KnightsAnalytics_jina-reranker-v1-tiny-en",
947947
Name: "test-cross-encoder-validation",
948948
}
949949
pipeline, err := hugot.NewPipeline(session, config)
@@ -977,8 +977,8 @@ func CrossEncoderPipelineValidation(t *testing.T, session *hugot.Session) {
977977
func ImageClassificationPipeline(t *testing.T, session *hugot.Session) {
978978
t.Helper()
979979

980-
modelPath := modelsFolder + "/KnightsAnalytics_resnet50"
981-
imagePath := modelsFolder + "/imageData/cat.jpg"
980+
modelPath := ModelsFolder + "KnightsAnalytics_resnet50"
981+
imagePath := ModelsFolder + "imageData/cat.jpg"
982982

983983
config := hugot.ImageClassificationConfig{
984984
ModelPath: modelPath,
@@ -1013,7 +1013,7 @@ func ImageClassificationPipeline(t *testing.T, session *hugot.Session) {
10131013
func ImageClassificationPipelineValidation(t *testing.T, session *hugot.Session) {
10141014
t.Helper()
10151015

1016-
modelPath := modelsFolder + "/KnightsAnalytics_resnet50"
1016+
modelPath := ModelsFolder + "/KnightsAnalytics_resnet50"
10171017
config := hugot.ImageClassificationConfig{
10181018
ModelPath: modelPath,
10191019
Name: "testImageClassification",
@@ -1033,7 +1033,7 @@ func ObjectDetectionPipeline(t *testing.T, session *hugot.Session) {
10331033
t.Helper()
10341034

10351035
config := backends.PipelineConfig[*pipelines.ObjectDetectionPipeline]{
1036-
ModelPath: modelsFolder + "/KnightsAnalytics_detr-resnet-50",
1036+
ModelPath: ModelsFolder + "KnightsAnalytics_detr-resnet-50",
10371037
Name: "testObjectDetection",
10381038
Options: []backends.PipelineOption[*pipelines.ObjectDetectionPipeline]{
10391039
pipelines.WithNCHWFormat[*pipelines.ObjectDetectionPipeline](),
@@ -1047,7 +1047,7 @@ func ObjectDetectionPipeline(t *testing.T, session *hugot.Session) {
10471047
CheckT(t, err)
10481048

10491049
// Use a simple cat image similar to classification test style
1050-
inputs := []string{"models/imageData/cat.jpg"}
1050+
inputs := []string{ModelsFolder + "imageData/cat.jpg"}
10511051
result, err := pipeline.RunPipeline(t.Context(), inputs)
10521052
CheckT(t, err)
10531053

@@ -1081,7 +1081,7 @@ func ObjectDetectionPipelineValidation(t *testing.T, session *hugot.Session) {
10811081
t.Helper()
10821082

10831083
config := backends.PipelineConfig[*pipelines.ObjectDetectionPipeline]{
1084-
ModelPath: modelsFolder + "/KnightsAnalytics_detr-resnet-50",
1084+
ModelPath: ModelsFolder + "KnightsAnalytics_detr-resnet-50",
10851085
Name: "testObjectDetectionValidation",
10861086
}
10871087
pipeline, err := hugot.NewPipeline(session, config)
@@ -1137,7 +1137,7 @@ func ObjectDetectionPipelineValidation(t *testing.T, session *hugot.Session) {
11371137

11381138
func NoSameNamePipeline(t *testing.T, session *hugot.Session) {
11391139
t.Helper()
1140-
modelPath := modelsFolder + "/KnightsAnalytics_distilbert-NER"
1140+
modelPath := ModelsFolder + "/KnightsAnalytics_distilbert-NER"
11411141
configSimple := hugot.TokenClassificationConfig{
11421142
ModelPath: modelPath,
11431143
Name: "testPipelineSimple",
@@ -1157,7 +1157,7 @@ func NoSameNamePipeline(t *testing.T, session *hugot.Session) {
11571157
func DestroyPipelines(t *testing.T, session *hugot.Session) {
11581158
t.Helper()
11591159

1160-
modelPath := modelsFolder + "/KnightsAnalytics_distilbert-NER"
1160+
modelPath := ModelsFolder + "/KnightsAnalytics_distilbert-NER"
11611161
configSimple := hugot.TokenClassificationConfig{
11621162
ModelPath: modelPath,
11631163
Name: "testClosePipeline",
@@ -1196,7 +1196,7 @@ func DestroyPipelines(t *testing.T, session *hugot.Session) {
11961196
// Text Generation.
11971197
func TextGenerationPipeline(t *testing.T, session *hugot.Session) {
11981198
t.Helper()
1199-
modelPath := modelsFolder + "/KnightsAnalytics_qwen3-4B-int4"
1199+
modelPath := ModelsFolder + "/KnightsAnalytics_qwen3-4B-int4"
12001200

12011201
defer func(session *hugot.Session) {
12021202
err := session.Destroy()
@@ -1396,7 +1396,7 @@ func TextGenerationPipelineValidation(t *testing.T, session *hugot.Session) {
13961396

13971397
// Configure the text generation pipeline
13981398
config := hugot.TextGenerationConfig{
1399-
ModelPath: modelsFolder + "/KnightsAnalytics_qwen3-4B-int4",
1399+
ModelPath: ModelsFolder + "/KnightsAnalytics_qwen3-4B-int4",
14001400
Name: "testPipeline",
14011401
Options: []backends.PipelineOption[*pipelines.TextGenerationPipeline]{},
14021402
}
@@ -1412,7 +1412,7 @@ func TextGenerationPipelineValidation(t *testing.T, session *hugot.Session) {
14121412
func QuestionAnsweringPipeline(t *testing.T, session *hugot.Session) {
14131413
t.Helper()
14141414

1415-
modelPath := modelsFolder + "/KnightsAnalytics_distilbert-onnx"
1415+
modelPath := ModelsFolder + "/KnightsAnalytics_distilbert-onnx"
14161416

14171417
config := hugot.QuestionAnsweringConfig{
14181418
ModelPath: modelPath,
@@ -1480,7 +1480,7 @@ func QuestionAnsweringPipeline(t *testing.T, session *hugot.Session) {
14801480
func TabularPipeline(t *testing.T, session *hugot.Session) {
14811481
t.Helper()
14821482
config := backends.PipelineConfig[*pipelines.TabularPipeline]{
1483-
ModelPath: modelsFolder + "/KnightsAnalytics_iris-decision-tree",
1483+
ModelPath: ModelsFolder + "/KnightsAnalytics_iris-decision-tree",
14841484
Name: "testTabularClassification",
14851485
Options: []backends.PipelineOption[*pipelines.TabularPipeline]{
14861486
pipelines.WithIDLabelMap(map[int]string{
@@ -1520,7 +1520,7 @@ func ThreadSafety(t *testing.T, session *hugot.Session, numEmbeddings int) {
15201520
numResults := numWorkers * numEmbeddings
15211521

15221522
t.Helper()
1523-
modelPath := modelsFolder + "/KnightsAnalytics_all-MiniLM-L6-v2"
1523+
modelPath := ModelsFolder + "/KnightsAnalytics_all-MiniLM-L6-v2"
15241524
config := hugot.FeatureExtractionConfig{
15251525
ModelPath: modelPath,
15261526
Name: "testPipeline",

0 commit comments

Comments
 (0)