1414 SegmentationPrediction ,
1515)
1616from nucleus .constants import ERROR_PAYLOAD
17- from nucleus .job import AsyncJob
17+ from nucleus .job import AsyncJob , JobError
1818
1919from .helpers import (
2020 TEST_BOX_PREDICTIONS ,
2424 TEST_IMG_URLS ,
2525 TEST_MODEL_NAME ,
2626 TEST_MODEL_RUN ,
27+ TEST_NONEXISTENT_TAXONOMY_CATEGORY_PREDICTION ,
2728 TEST_POLYGON_PREDICTIONS ,
2829 TEST_SEGMENTATION_PREDICTIONS ,
2930 assert_box_prediction_matches_dict ,
@@ -119,7 +120,7 @@ def test_polygon_pred_upload(model_run):
119120 response = model_run .predict (annotations = [prediction ])
120121
121122 assert response ["model_run_id" ] == model_run .model_run_id
122- assert response ["predictions_ignored " ] == 0
123+ assert response ["predictions_processed " ] == 1
123124 assert response ["predictions_ignored" ] == 0
124125
125126 response = model_run .refloc (prediction .reference_id )["polygon" ]
@@ -134,7 +135,7 @@ def test_category_pred_upload(model_run):
134135 response = model_run .predict (annotations = [prediction ])
135136
136137 assert response ["model_run_id" ] == model_run .model_run_id
137- assert response ["predictions_ignored " ] == 0
138+ assert response ["predictions_processed " ] == 1
138139 assert response ["predictions_ignored" ] == 0
139140
140141 response = model_run .refloc (prediction .reference_id )["category" ]
@@ -151,7 +152,7 @@ def test_default_category_pred_upload(model_run):
151152 response = model_run .predict (annotations = [prediction ])
152153
153154 assert response ["model_run_id" ] == model_run .model_run_id
154- assert response ["predictions_ignored " ] == 0
155+ assert response ["predictions_processed " ] == 1
155156 assert response ["predictions_ignored" ] == 0
156157
157158 response = model_run .refloc (prediction .reference_id )["category" ]
@@ -161,6 +162,20 @@ def test_default_category_pred_upload(model_run):
161162 )
162163
163164
165+ def test_non_existent_taxonomy_category_gt_upload (model_run ):
166+ prediction = CategoryPrediction .from_json (
167+ TEST_NONEXISTENT_TAXONOMY_CATEGORY_PREDICTION [0 ]
168+ )
169+ response = model_run .predict (annotations = [prediction ])
170+ assert response ["model_run_id" ] == model_run .model_run_id
171+ assert response ["predictions_processed" ] == 0
172+ assert response ["predictions_ignored" ] == 0
173+ assert (
174+ f'Input validation failed: Taxonomy { TEST_NONEXISTENT_TAXONOMY_CATEGORY_PREDICTION [0 ]["taxonomy_name" ]} does not exist in dataset'
175+ in response ["errors" ][0 ]
176+ )
177+
178+
164179def test_segmentation_pred_upload (model_run ):
165180 prediction = SegmentationPrediction .from_json (
166181 TEST_SEGMENTATION_PREDICTIONS [0 ]
@@ -576,3 +591,34 @@ def test_default_category_pred_upload_async(model_run: ModelRun):
576591 "completed_steps" : 1 ,
577592 "total_steps" : 1 ,
578593 }
594+
595+
596+ @pytest .mark .integration
597+ def test_non_existent_taxonomy_category_gt_upload_async (model_run : ModelRun ):
598+ prediction = CategoryPrediction .from_json (
599+ TEST_NONEXISTENT_TAXONOMY_CATEGORY_PREDICTION [0 ]
600+ )
601+ try :
602+ job : AsyncJob = model_run .predict (
603+ annotations = [
604+ prediction ,
605+ ],
606+ asynchronous = True ,
607+ )
608+ job .sleep_until_complete ()
609+ except JobError :
610+ assert (
611+ f'Input validation failed: Taxonomy { TEST_NONEXISTENT_TAXONOMY_CATEGORY_PREDICTION [0 ]["taxonomy_name" ]} does not exist in dataset'
612+ in job .errors ()[- 1 ]
613+ )
614+
615+ assert job .status () == {
616+ "job_id" : job .job_id ,
617+ "status" : "Errored" ,
618+ "message" : {
619+ "status_log" : "No additional information can be provided at this time."
620+ },
621+ "job_progress" : "0.00" ,
622+ "completed_steps" : 0 ,
623+ "total_steps" : 1 ,
624+ }
0 commit comments