Skip to content

Commit 318c456

Browse files
committed
fix test paths
1 parent f02227d commit 318c456

5 files changed

Lines changed: 73 additions & 60 deletions

File tree

scripts/run-unit-tests-container.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,27 @@ 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

23-
# echo "Running training tests..."
23+
echo "Running simplego 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-go.xml --jsonfile=$folder/unit-go.json -- -coverprofile=$folder/cover-go.out -coverpkg ./... -tags=GO -timeout 60m ./...
2626

27-
echo "Training tests completed."
27+
echo "simplego tests completed."
2828

29-
# echo "Running simplego tests..."
29+
echo "Running training 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-training.xml --jsonfile=$folder/unit-training.json -- -coverprofile=$folder/cover-training.out -coverpkg ./... -tags=ORT,XLA,TRAINING -timeout 60m ./...
3232

33-
# echo "simplego tests completed."
33+
echo "Training tests completed."
3434

3535
echo "merging coverage files"
3636
head -n 1 $folder/cover-ort.out > $folder/cover.out

tests/go/hugot_go_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ func TestTokenClassificationPipelineValidationGo(t *testing.T) {
9191
// Zero shot
9292

9393
func TestZeroShotClassificationPipelineGo(t *testing.T) {
94+
if os.Getenv("CI") != "" {
95+
t.SkipNow()
96+
}
9497
session, err := hugot.NewGoSession(t.Context())
9598
testutil.CheckT(t, err)
9699
defer func(session *hugot.Session) {
@@ -101,6 +104,9 @@ func TestZeroShotClassificationPipelineGo(t *testing.T) {
101104
}
102105

103106
func TestZeroShotClassificationPipelineValidationGo(t *testing.T) {
107+
if os.Getenv("CI") != "" {
108+
t.SkipNow()
109+
}
104110
session, err := hugot.NewGoSession(t.Context())
105111
testutil.CheckT(t, err)
106112
defer func(session *hugot.Session) {
@@ -157,6 +163,9 @@ func TestImageClassificationPipelineValidationGo(t *testing.T) {
157163
// Object detection
158164

159165
func TestObjectDetectionPipelineGo(t *testing.T) {
166+
if os.Getenv("CI") != "" {
167+
t.SkipNow()
168+
}
160169
session, err := hugot.NewGoSession(t.Context())
161170
testutil.CheckT(t, err)
162171
defer func(session *hugot.Session) {
@@ -167,6 +176,9 @@ func TestObjectDetectionPipelineGo(t *testing.T) {
167176
}
168177

169178
func TestObjectDetectionPipelineValidationGo(t *testing.T) {
179+
if os.Getenv("CI") != "" {
180+
t.SkipNow()
181+
}
170182
session, err := hugot.NewGoSession(t.Context())
171183
testutil.CheckT(t, err)
172184
defer func(session *hugot.Session) {
@@ -295,7 +307,7 @@ func TestReadmeExample(t *testing.T) {
295307
// drop the dependency on huggingfaceModelDownloader.
296308
// modelPath, err := DownloadModel("KnightsAnalytics/distilbert-base-uncased-finetuned-sst-2-english", "./models/", NewDownloadOptions())
297309
// check(err)
298-
modelPath := "./models/KnightsAnalytics_distilbert-base-uncased-finetuned-sst-2-english"
310+
modelPath := testutil.ModelsFolder + "KnightsAnalytics_distilbert-base-uncased-finetuned-sst-2-english"
299311

300312
// we now create the configuration for the text classification pipeline we want to create.
301313
// 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: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -109,29 +109,29 @@ 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.
134-
data, err := os.ReadFile("./testcases/semanticSimilarityTest.jsonl")
134+
data, err := os.ReadFile(testutil.TestCasesFolder + "semanticSimilarityTest.jsonl")
135135
testutil.CheckT(t, err)
136136
lines := bytes.Split(data, []byte("\n"))
137137

@@ -167,15 +167,15 @@ func TestTrainSemanticSimilarity(t *testing.T) {
167167
// The datasets.NewSemanticSimilarityDataset function also accepts a custom function that will be applied
168168
// to all examples in a batch before they are passed to the model. This can be used to apply whatever preprocessing
169169
// you need.
170-
trainDataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), "./testcases/semanticSimilarityTest.jsonl", 1, nil)
170+
trainDataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), testutil.TestCasesFolder + "semanticSimilarityTest.jsonl", 1, nil)
171171
if err != nil {
172172
t.Fatal(err)
173173
}
174174

175175
// next we create a trainEvalDataset. This is the same as the train dataset, but it will be used to evaluate the model on
176176
// in-sample data at the end of each epoch.
177177
// We can also specify an eval dataset with early stopping (see test below).
178-
trainEvalDataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), "./testcases/semanticSimilarityTest.jsonl", 1, nil)
178+
trainEvalDataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), testutil.TestCasesFolder + "semanticSimilarityTest.jsonl", 1, nil)
179179
if err != nil {
180180
t.Fatal(err)
181181
}
@@ -246,12 +246,12 @@ func TestTrainSemanticSimilarityCuda(t *testing.T) {
246246
t.SkipNow()
247247
}
248248

249-
dataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), "./testcases/semanticSimilarityTest.jsonl", 32, nil)
249+
dataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), testutil.TestCasesFolder + "semanticSimilarityTest.jsonl", 32, nil)
250250
if err != nil {
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
}
@@ -293,12 +293,12 @@ func TestTrainSemanticSimilarityGo(t *testing.T) {
293293
t.SkipNow()
294294
}
295295

296-
dataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), "./testcases/semanticSimilarityTest.jsonl", 1, nil)
296+
dataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), testutil.TestCasesFolder + "semanticSimilarityTest.jsonl", 1, nil)
297297
if err != nil {
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,33 +321,33 @@ 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

340-
trainDataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), "./testcases/semanticSimilarityTest.jsonl", 1, nil)
340+
trainDataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), testutil.TestCasesFolder + "semanticSimilarityTest.jsonl", 1, nil)
341341
if err != nil {
342342
t.Fatal(err)
343343
}
344-
evalDataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), "./testcases/semanticSimilarityTestEval.jsonl", 1, nil)
344+
evalDataset, err := datasets.NewSemanticSimilarityDataset(t.Context(), testutil.TestCasesFolder + "semanticSimilarityTestEval.jsonl", 1, nil)
345345
if err != nil {
346346
t.Fatal(err)
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
}

0 commit comments

Comments
 (0)