2626 PaginatedDetectorList ,
2727 PaginatedImageQueryList ,
2828)
29+ from test .retry_decorator import retry_on_failure
2930from urllib3 .exceptions import ConnectTimeoutError , MaxRetryError , ReadTimeoutError
3031from urllib3 .util .retry import Retry
3132
@@ -273,20 +274,23 @@ def test_get_detector_by_name(gl: Groundlight, detector: Detector):
273274 gl .get_detector_by_name (name = "not a real name" )
274275
275276
277+ @retry_on_failure ()
276278def test_ask_confident (gl : Groundlight , detector : Detector ):
277279 _image_query = gl .ask_confident (detector = detector .id , image = "test/assets/dog.jpeg" , wait = 10 )
278280 assert str (_image_query )
279281 assert isinstance (_image_query , ImageQuery )
280282 assert is_valid_display_result (_image_query .result )
281283
282284
285+ @retry_on_failure ()
283286def test_ask_ml (gl : Groundlight , detector : Detector ):
284287 _image_query = gl .ask_ml (detector = detector .id , image = "test/assets/dog.jpeg" , wait = 10 )
285288 assert str (_image_query )
286289 assert isinstance (_image_query , ImageQuery )
287290 assert is_valid_display_result (_image_query .result )
288291
289292
293+ @retry_on_failure ()
290294def test_submit_image_query (gl : Groundlight , detector : Detector ):
291295 def validate_image_query (_image_query : ImageQuery ):
292296 assert str (_image_query )
@@ -314,6 +318,7 @@ def validate_image_query(_image_query: ImageQuery):
314318 assert _image_query .result .confidence >= IQ_IMPROVEMENT_THRESHOLD
315319
316320
321+ @retry_on_failure ()
317322def test_submit_image_query_blocking (gl : Groundlight , detector : Detector ):
318323 _image_query = gl .submit_image_query (
319324 detector = detector .id , image = "test/assets/dog.jpeg" , wait = 10 , human_review = "NEVER"
@@ -323,13 +328,15 @@ def test_submit_image_query_blocking(gl: Groundlight, detector: Detector):
323328 assert is_valid_display_result (_image_query .result )
324329
325330
331+ @retry_on_failure ()
326332def test_submit_image_query_returns_yes (gl : Groundlight ):
327333 # We use the "never-review" pipeline to guarantee a confident "yes" answer.
328334 detector = gl .get_or_create_detector (name = "Always a dog" , query = "Is there a dog?" , pipeline_config = "never-review" )
329335 image_query = gl .submit_image_query (detector = detector , image = "test/assets/dog.jpeg" , wait = 10 , human_review = "NEVER" )
330336 assert image_query .result .label == Label .YES
331337
332338
339+ @retry_on_failure ()
333340def test_submit_image_query_returns_text (gl : Groundlight ):
334341 # We use the "never-review" pipeline to guarantee a confident "yes" answer.
335342 detector = gl .get_or_create_detector (
@@ -339,20 +346,23 @@ def test_submit_image_query_returns_text(gl: Groundlight):
339346 assert isinstance (image_query .text , str )
340347
341348
349+ @retry_on_failure ()
342350def test_submit_image_query_filename (gl : Groundlight , detector : Detector ):
343351 _image_query = gl .submit_image_query (detector = detector .id , image = "test/assets/dog.jpeg" , human_review = "NEVER" )
344352 assert str (_image_query )
345353 assert isinstance (_image_query , ImageQuery )
346354 assert is_valid_display_result (_image_query .result )
347355
348356
357+ @retry_on_failure ()
349358def test_submit_image_query_png (gl : Groundlight , detector : Detector ):
350359 _image_query = gl .submit_image_query (detector = detector .id , image = "test/assets/cat.png" , human_review = "NEVER" )
351360 assert str (_image_query )
352361 assert isinstance (_image_query , ImageQuery )
353362 assert is_valid_display_result (_image_query .result )
354363
355364
365+ @retry_on_failure ()
356366def test_submit_image_query_with_confidence_threshold (gl : Groundlight , detector : Detector ):
357367 confidence_threshold = 0.5234 # Arbitrary specific value
358368 _image_query = gl .submit_image_query (
@@ -366,6 +376,7 @@ def test_submit_image_query_with_confidence_threshold(gl: Groundlight, detector:
366376
367377
368378@pytest .mark .skip_for_edge_endpoint (reason = "The edge-endpoint does not support passing an image query ID." )
379+ @retry_on_failure ()
369380def test_submit_image_query_with_id (gl : Groundlight , detector : Detector ):
370381 # submit_image_query
371382 id = f"iq_{ KsuidMs ()} "
@@ -380,6 +391,7 @@ def test_submit_image_query_with_id(gl: Groundlight, detector: Detector):
380391 assert _image_query .metadata .get ("is_from_edge" )
381392
382393
394+ @retry_on_failure ()
383395def test_submit_image_query_with_human_review_param (gl : Groundlight , detector : Detector ):
384396 # For now, this just tests that the image query is submitted successfully.
385397 # There should probably be a better way to check whether the image query was escalated for human review.
@@ -451,6 +463,7 @@ def test_create_detector_with_invalid_metadata(gl: Groundlight, metadata_list: A
451463
452464@pytest .mark .skip_for_edge_endpoint (reason = "The edge-endpoint does not support passing image query metadata." )
453465@pytest .mark .parametrize ("metadata" , [None , {}, {"a" : 1 }, '{"a": 1}' ])
466+ @retry_on_failure ()
454467def test_submit_image_query_with_metadata (
455468 gl : Groundlight , detector : Detector , image : str , metadata : Union [Dict , str , None ]
456469):
@@ -505,6 +518,7 @@ def test_submit_image_query_with_metadata_returns_user_error(gl: Groundlight, de
505518 assert is_user_error (exc_info .value .status )
506519
507520
521+ @retry_on_failure ()
508522def test_submit_image_query_jpeg_bytes (gl : Groundlight , detector : Detector ):
509523 jpeg = open ("test/assets/dog.jpeg" , "rb" ).read ()
510524 _image_query = gl .submit_image_query (detector = detector .id , image = jpeg , human_review = "NEVER" )
@@ -543,6 +557,7 @@ def test_submit_image_query_bad_jpeg_file(gl: Groundlight, detector: Detector):
543557
544558
545559@pytest .mark .skipif (MISSING_PIL , reason = "Needs pillow" ) # type: ignore
560+ @retry_on_failure ()
546561def test_submit_image_query_pil (gl : Groundlight , detector : Detector ):
547562 # generates a pil image and submits it
548563 from PIL import Image
@@ -565,6 +580,7 @@ def test_submit_image_query_wait_and_want_async_causes_exception(gl: Groundlight
565580 )
566581
567582
583+ @retry_on_failure ()
568584def test_submit_image_query_with_want_async_workflow (gl : Groundlight , detector : Detector ):
569585 """
570586 Tests the workflow for submitting an image query with the want_async parameter set to True.
@@ -589,6 +605,7 @@ def test_submit_image_query_with_want_async_workflow(gl: Groundlight, detector:
589605 assert _image_query .result .label in VALID_DISPLAY_LABELS
590606
591607
608+ @retry_on_failure ()
592609def test_ask_async_workflow (gl : Groundlight , detector : Detector ):
593610 """
594611 Tests the workflow for submitting an image query with ask_async.
@@ -709,6 +726,7 @@ def test_enum_string_equality():
709726
710727
711728@pytest .mark .skipif (MISSING_NUMPY or MISSING_PIL , reason = "Needs numpy and pillow" ) # type: ignore
729+ @retry_on_failure ()
712730def test_submit_numpy_image (gl : Groundlight , detector : Detector ):
713731 np_img = np .random .uniform (0 , 255 , (600 , 800 , 3 )) # type: ignore
714732 _image_query = gl .submit_image_query (detector = detector .id , image = np_img , human_review = "NEVER" )
@@ -820,6 +838,7 @@ def test_update_detector_confidence_threshold_failure(gl: Groundlight, detector:
820838
821839
822840@pytest .mark .skip_for_edge_endpoint (reason = "The edge-endpoint does not support passing detector metadata." )
841+ @retry_on_failure ()
823842def test_submit_image_query_with_inspection_id_metadata_and_want_async (gl : Groundlight , detector : Detector , image : str ):
824843 inspection_id = gl .start_inspection ()
825844 metadata = {"key" : "value" }
@@ -852,6 +871,7 @@ def test_submit_image_query_with_empty_inspection_id(gl: Groundlight, detector:
852871 )
853872
854873
874+ @retry_on_failure ()
855875def test_binary_detector (gl : Groundlight , detector_name : Callable ):
856876 """
857877 verify that we can create and submit to a binary detector
@@ -863,6 +883,7 @@ def test_binary_detector(gl: Groundlight, detector_name: Callable):
863883 assert binary_iq .result .label is not None
864884
865885
886+ @retry_on_failure ()
866887def test_counting_detector (gl : Groundlight , detector_name : Callable ):
867888 """
868889 verify that we can create and submit to a counting detector
@@ -874,6 +895,7 @@ def test_counting_detector(gl: Groundlight, detector_name: Callable):
874895 assert count_iq .result .count is not None
875896
876897
898+ @retry_on_failure ()
877899def test_counting_detector_async (gl : Groundlight , detector_name : Callable ):
878900 """
879901 verify that we can create and submit to a counting detector
@@ -893,6 +915,7 @@ def test_counting_detector_async(gl: Groundlight, detector_name: Callable):
893915 assert _image_query .result is not None
894916
895917
918+ @retry_on_failure ()
896919def test_multiclass_detector (gl : Groundlight , detector_name : Callable ):
897920 """
898921 verify that we can create and submit to a multi-class detector
0 commit comments