@@ -19,6 +19,8 @@ var textClassificationData []byte
1919//go:embed testData/tokenClassification.jsonl
2020var tokenClassificationData []byte
2121
22+ const onnxRuntimeSharedLibrary = "/usr/lib64/onnxruntime.so"
23+
2224func TestTextClassificationCli (t * testing.T ) {
2325 app := & cli.App {
2426 Name : "hugot" ,
@@ -43,7 +45,11 @@ func TestTextClassificationCli(t *testing.T) {
4345 check (t , err )
4446 }()
4547
46- args := append (baseArgs , "run" , fmt .Sprintf ("--input=%s" , testDataDir ), fmt .Sprintf ("--model=%s" , testModel ), "--type=textClassification" )
48+ args := append (baseArgs , "run" ,
49+ fmt .Sprintf ("--input=%s" , testDataDir ),
50+ fmt .Sprintf ("--s=%s" , onnxRuntimeSharedLibrary ),
51+ fmt .Sprintf ("--model=%s" , testModel ),
52+ "--type=textClassification" )
4753 if err := app .Run (args ); err != nil {
4854 check (t , err )
4955 }
@@ -69,8 +75,12 @@ func TestTokenClassificationCli(t *testing.T) {
6975 check (t , err )
7076 }()
7177
72- args := append (baseArgs , "run" , fmt .Sprintf ("--input=%s" , path .Join (testDataDir , "test-token-classification.jsonl" )),
73- fmt .Sprintf ("--model=%s" , testModel ), "--type=tokenClassification" , fmt .Sprintf ("--output=%s" , testDataDir ))
78+ args := append (baseArgs , "run" ,
79+ fmt .Sprintf ("--input=%s" , path .Join (testDataDir , "test-token-classification.jsonl" )),
80+ fmt .Sprintf ("--s=%s" , onnxRuntimeSharedLibrary ),
81+ fmt .Sprintf ("--model=%s" , testModel ),
82+ "--type=tokenClassification" ,
83+ fmt .Sprintf ("--output=%s" , testDataDir ))
7484 if err := app .Run (args ); err != nil {
7585 check (t , err )
7686 }
@@ -86,9 +96,7 @@ func TestFeatureExtractionCli(t *testing.T) {
8696 Commands : []* cli.Command {runCommand },
8797 }
8898 baseArgs := os .Args [0 :1 ]
89-
90- testModel := path .Join ("../models" , "sentence-transformers_all-MiniLM-L6-v2" )
91-
99+ testModel := path .Join ("../models" , "KnightsAnalytics_all-MiniLM-L6-v2" )
92100 testDataDir := path .Join (os .TempDir (), "hugoTestData" )
93101 err := os .MkdirAll (testDataDir , os .ModePerm )
94102 check (t , err )
@@ -99,9 +107,13 @@ func TestFeatureExtractionCli(t *testing.T) {
99107 check (t , err )
100108 }()
101109
102- args := append (baseArgs , "run" , fmt .Sprintf ("--input=%s" , path .Join (testDataDir , "test-feature-extraction.jsonl" )),
103- fmt .Sprintf ("--model=%s" , testModel ), fmt .Sprintf ("--onnxFilename=%s" , "model.onnx" ),
104- "--type=featureExtraction" , fmt .Sprintf ("--output=%s" , testDataDir ))
110+ args := append (baseArgs , "run" ,
111+ fmt .Sprintf ("--input=%s" , path .Join (testDataDir , "test-feature-extraction.jsonl" )),
112+ fmt .Sprintf ("--s=%s" , onnxRuntimeSharedLibrary ),
113+ fmt .Sprintf ("--model=%s" , testModel ),
114+ fmt .Sprintf ("--onnxFilename=%s" , "model.onnx" ),
115+ "--type=featureExtraction" ,
116+ fmt .Sprintf ("--output=%s" , testDataDir ))
105117 if err := app .Run (args ); err != nil {
106118 check (t , err )
107119 }
@@ -136,13 +148,20 @@ func TestModelChain(t *testing.T) {
136148 check (t , util .FileSystem .Delete (context .Background (), util .PathJoinSafe (userFolder , "hugot" )))
137149
138150 // try to download the model to hugo folder and run it
139- args := append (baseArgs , "run" , fmt .Sprintf ("--input=%s" , testDataDir ), fmt .Sprintf ("--model=%s" , "KnightsAnalytics/distilbert-base-uncased-finetuned-sst-2-english" ), "--type=textClassification" )
151+ args := append (baseArgs , "run" ,
152+ fmt .Sprintf ("--input=%s" , testDataDir ),
153+ fmt .Sprintf ("--s=%s" , onnxRuntimeSharedLibrary ),
154+ fmt .Sprintf ("--model=%s" , "KnightsAnalytics/distilbert-base-uncased-finetuned-sst-2-english" ),
155+ "--type=textClassification" )
140156 if err := app .Run (args ); err != nil {
141157 check (t , err )
142158 }
143159
144160 // run it again. This time the model should be read from the hugot folder without re-downloading it.
145- args = append (baseArgs , "run" , fmt .Sprintf ("--input=%s" , testDataDir ), fmt .Sprintf ("--model=%s" , "KnightsAnalytics/distilbert-base-uncased-finetuned-sst-2-english" ), "--type=textClassification" )
161+ args = append (baseArgs , "run" , fmt .Sprintf ("--input=%s" , testDataDir ),
162+ fmt .Sprintf ("--model=%s" , "KnightsAnalytics/distilbert-base-uncased-finetuned-sst-2-english" ),
163+ fmt .Sprintf ("--s=%s" , onnxRuntimeSharedLibrary ),
164+ "--type=textClassification" )
146165 if err := app .Run (args ); err != nil {
147166 check (t , err )
148167 }
0 commit comments