@@ -73,14 +73,10 @@ func TestTextClassificationPipeline(t *testing.T) {
7373
7474 for _ , tt := range tests {
7575 t .Run (tt .name , func (t * testing.T ) {
76- batchResult , err := tt .pipeline .Run (tt .strings )
77- result , ok := batchResult .(* pipelines.TextClassificationOutput )
78- if ! ok {
79- t .FailNow ()
80- }
76+ batchResult , err := tt .pipeline .RunPipeline (tt .strings )
8177 check (t , err )
8278 for i , expected := range tt .expected .ClassificationOutputs {
83- checkClassificationOutput (t , expected , result .ClassificationOutputs [i ])
79+ checkClassificationOutput (t , expected , batchResult .ClassificationOutputs [i ])
8480 }
8581 })
8682 }
@@ -176,15 +172,10 @@ func TestTokenClassificationPipeline(t *testing.T) {
176172
177173 for _ , tt := range tests {
178174 t .Run (tt .name , func (t * testing.T ) {
179- batchResult , err := tt .pipeline .Run (tt .strings )
175+ batchResult , err := tt .pipeline .RunPipeline (tt .strings )
180176 check (t , err )
181- result , ok := batchResult .(* pipelines.TokenClassificationOutput )
182- if ! ok {
183- t .FailNow ()
184- }
185-
186- printTokenEntities (result )
187- for i , predictedEntities := range result .Entities {
177+ printTokenEntities (batchResult )
178+ for i , predictedEntities := range batchResult .Entities {
188179 assert .Equal (t , len (tt .expected .Entities [i ]), len (predictedEntities ))
189180 for j , entity := range predictedEntities {
190181 expectedEntity := tt .expected .Entities [i ][j ]
@@ -254,13 +245,9 @@ func TestFeatureExtractionPipeline(t *testing.T) {
254245 // test 'robert smith'
255246 testResults = expectedResults ["test1output" ]
256247 for i := 1 ; i <= 10 ; i ++ {
257- batchResult , err := pipeline .Run ([]string {"robert smith" })
248+ batchResult , err := pipeline .RunPipeline ([]string {"robert smith" })
258249 check (t , err )
259- result , ok := batchResult .(* pipelines.FeatureExtractionOutput )
260- if ! ok {
261- t .FailNow ()
262- }
263- e := floatsEqual (result .Embeddings [0 ], testResults [0 ])
250+ e := floatsEqual (batchResult .Embeddings [0 ], testResults [0 ])
264251 if e != nil {
265252 t .Logf ("Test 1: The neural network didn't produce the correct result on loop %d: %s\n " , i , e )
266253 t .FailNow ()
@@ -270,13 +257,9 @@ func TestFeatureExtractionPipeline(t *testing.T) {
270257 // test ['robert smith junior', 'francis ford coppola']
271258 testResults = expectedResults ["test2output" ]
272259 for i := 1 ; i <= 10 ; i ++ {
273- batchResult , err := pipeline .Run ([]string {"robert smith junior" , "francis ford coppola" })
260+ batchResult , err := pipeline .RunPipeline ([]string {"robert smith junior" , "francis ford coppola" })
274261 check (t , err )
275- result , ok := batchResult .(* pipelines.FeatureExtractionOutput )
276- if ! ok {
277- t .FailNow ()
278- }
279- for j , res := range result .Embeddings {
262+ for j , res := range batchResult .Embeddings {
280263 e := floatsEqual (res , testResults [j ])
281264 if e != nil {
282265 t .Logf ("Test 2: The neural network didn't produce the correct result on loop %d: %s\n " , i , e )
@@ -293,21 +276,13 @@ func TestFeatureExtractionPipeline(t *testing.T) {
293276
294277 for k , sentencePair := range testPairs {
295278 // these vectors should be the same
296- firstBatchResult , err2 := pipeline .Run (sentencePair [0 ])
279+ firstBatchResult , err2 := pipeline .RunPipeline (sentencePair [0 ])
297280 check (t , err2 )
298- firstResult , ok := firstBatchResult .(* pipelines.FeatureExtractionOutput )
299- if ! ok {
300- t .FailNow ()
301- }
302- firstEmbedding := firstResult .Embeddings [0 ]
281+ firstEmbedding := firstBatchResult .Embeddings [0 ]
303282
304- secondBatchResult , err3 := pipeline .Run (sentencePair [1 ])
283+ secondBatchResult , err3 := pipeline .RunPipeline (sentencePair [1 ])
305284 check (t , err3 )
306- secondResult , ok := secondBatchResult .(* pipelines.FeatureExtractionOutput )
307- if ! ok {
308- t .FailNow ()
309- }
310- secondEmbedding := secondResult .Embeddings [0 ]
285+ secondEmbedding := secondBatchResult .Embeddings [0 ]
311286 e := floatsEqual (firstEmbedding , secondEmbedding )
312287 if e != nil {
313288 t .Logf ("Equality failed for determinism test %s test with pairs %s and %s" , k , strings .Join (sentencePair [0 ], "," ), strings .Join (sentencePair [1 ], "," ))
0 commit comments