55import random
66import string
77import time
8- from typing import Any , Dict , Optional , Union
8+ from typing import Any , Callable , Dict , Optional , Union
99
1010import pytest
11- from conftest import generate_test_detector_name
1211from groundlight import Groundlight
1312from groundlight .binary_labels import VALID_DISPLAY_LABELS , Label , convert_internal_label_to_display
1413from groundlight .internalapi import ApiException , InternalApiError , NotFoundError
@@ -96,7 +95,7 @@ def test_create_groundlight_with_retries():
9695 assert gl .api_client .configuration .retries .total == retries .total
9796
9897
99- def test_create_detector (gl : Groundlight ):
98+ def test_create_detector (gl : Groundlight , generate_test_detector_name : Callable ):
10099 name = generate_test_detector_name ()
101100 query = "Is there a dog?"
102101 _detector = gl .create_detector (name = name , query = query )
@@ -117,7 +116,7 @@ def test_create_detector(gl: Groundlight):
117116 assert str (multiclass_detector )
118117
119118
120- def test_create_detector_with_pipeline_config (gl : Groundlight ):
119+ def test_create_detector_with_pipeline_config (gl : Groundlight , generate_test_detector_name : Callable ):
121120 # "never-review" is a special model that always returns the same result with 100% confidence.
122121 # It's useful for testing.
123122 name = generate_test_detector_name ("Test never-review" )
@@ -128,7 +127,7 @@ def test_create_detector_with_pipeline_config(gl: Groundlight):
128127 assert isinstance (_detector , Detector )
129128
130129
131- def test_create_detector_with_edge_pipeline_config (gl : Groundlight ):
130+ def test_create_detector_with_edge_pipeline_config (gl : Groundlight , generate_test_detector_name : Callable ):
132131 name = generate_test_detector_name ("Test edge-pipeline-config" )
133132 query = "Is there a dog (edge-config)?"
134133 _detector = gl .create_detector (
@@ -141,7 +140,7 @@ def test_create_detector_with_edge_pipeline_config(gl: Groundlight):
141140 assert isinstance (_detector , Detector )
142141
143142
144- def test_create_detector_with_confidence_threshold (gl : Groundlight ):
143+ def test_create_detector_with_confidence_threshold (gl : Groundlight , generate_test_detector_name : Callable ):
145144 # "never-review" is a special model that always returns the same result with 100% confidence.
146145 # It's useful for testing.
147146 name = generate_test_detector_name ("Test with confidence" )
@@ -197,7 +196,7 @@ def test_create_detector_with_confidence_threshold(gl: Groundlight):
197196
198197
199198@pytest .mark .skip_for_edge_endpoint (reason = "The edge-endpoint does not support passing detector metadata." )
200- def test_create_detector_with_everything (gl : Groundlight ):
199+ def test_create_detector_with_everything (gl : Groundlight , generate_test_detector_name : Callable ):
201200 name = generate_test_detector_name ()
202201 query = "Is there a dog?"
203202 group_name = "Test group"
@@ -232,7 +231,7 @@ def test_list_detectors(gl: Groundlight):
232231 assert isinstance (detectors , PaginatedDetectorList )
233232
234233
235- def test_get_or_create_detector (gl : Groundlight ):
234+ def test_get_or_create_detector (gl : Groundlight , generate_test_detector_name : Callable ):
236235 # With a unique name, we should be creating a new detector.
237236 unique_name = generate_test_detector_name ()
238237 query = "Is there a dog?"
@@ -410,7 +409,7 @@ def test_submit_image_query_with_low_request_timeout(gl: Groundlight, detector:
410409
411410
412411@pytest .mark .skip_for_edge_endpoint (reason = "The edge-endpoint does not support passing detector metadata." )
413- def test_create_detector_with_metadata (gl : Groundlight ):
412+ def test_create_detector_with_metadata (gl : Groundlight , generate_test_detector_name : Callable ):
414413 name = generate_test_detector_name ()
415414 query = "Is there a dog?"
416415 metadata = generate_random_dict (target_size_bytes = 200 )
@@ -422,7 +421,7 @@ def test_create_detector_with_metadata(gl: Groundlight):
422421
423422
424423@pytest .mark .skip_for_edge_endpoint (reason = "The edge-endpoint does not support passing detector metadata." )
425- def test_get_or_create_detector_with_metadata (gl : Groundlight ):
424+ def test_get_or_create_detector_with_metadata (gl : Groundlight , generate_test_detector_name : Callable ):
426425 unique_name = generate_test_detector_name ()
427426 query = "Is there a dog?"
428427 metadata = generate_random_dict (target_size_bytes = 200 )
@@ -443,7 +442,7 @@ def test_get_or_create_detector_with_metadata(gl: Groundlight):
443442 ["" ],
444443 ],
445444)
446- def test_create_detector_with_invalid_metadata (gl : Groundlight , metadata_list : Any ):
445+ def test_create_detector_with_invalid_metadata (gl : Groundlight , metadata_list : Any , generate_test_detector_name : Callable ):
447446 name = generate_test_detector_name ()
448447 query = "Is there a dog?"
449448
@@ -627,7 +626,7 @@ def test_list_image_queries(gl: Groundlight):
627626 assert is_valid_display_result (image_query .result )
628627
629628
630- def test_list_image_queries_with_filter (gl : Groundlight ):
629+ def test_list_image_queries_with_filter (gl : Groundlight , generate_test_detector_name : Callable ):
631630 # We want a fresh detector so we know exactly what image queries are associated with it
632631 detector = gl .create_detector (name = generate_test_detector_name (), query = "Is there a dog?" )
633632 image_query_yes = gl .ask_async (detector = detector .id , image = "test/assets/dog.jpeg" , human_review = "NEVER" )
@@ -855,7 +854,7 @@ def test_submit_image_query_with_empty_inspection_id(gl: Groundlight, detector:
855854 )
856855
857856
858- def test_binary_detector (gl : Groundlight ):
857+ def test_binary_detector (gl : Groundlight , generate_test_detector_name : Callable ):
859858 """
860859 verify that we can create and submit to a binary detector
861860 """
@@ -866,7 +865,7 @@ def test_binary_detector(gl: Groundlight):
866865 assert binary_iq .result .label is not None
867866
868867
869- def test_counting_detector (gl : Groundlight ):
868+ def test_counting_detector (gl : Groundlight , generate_test_detector_name : Callable ):
870869 """
871870 verify that we can create and submit to a counting detector
872871 """
@@ -877,7 +876,7 @@ def test_counting_detector(gl: Groundlight):
877876 assert count_iq .result .count is not None
878877
879878
880- def test_counting_detector_async (gl : Groundlight ):
879+ def test_counting_detector_async (gl : Groundlight , generate_test_detector_name : Callable ):
881880 """
882881 verify that we can create and submit to a counting detector
883882 """
@@ -896,7 +895,7 @@ def test_counting_detector_async(gl: Groundlight):
896895 assert _image_query .result is not None
897896
898897
899- def test_multiclass_detector (gl : Groundlight ):
898+ def test_multiclass_detector (gl : Groundlight , generate_test_detector_name : Callable ):
900899 """
901900 verify that we can create and submit to a multi-class detector
902901 """
@@ -911,7 +910,7 @@ def test_multiclass_detector(gl: Groundlight):
911910 assert mc_iq .result .label in class_names
912911
913912
914- def test_delete_detector (gl : Groundlight ):
913+ def test_delete_detector (gl : Groundlight , generate_test_detector_name : Callable ):
915914 """
916915 Test deleting a detector by both ID and object, and verify proper error handling.
917916 """
@@ -952,7 +951,7 @@ def test_delete_detector(gl: Groundlight):
952951 gl .delete_detector (fake_detector_id ) # type: ignore
953952
954953
955- def test_create_detector_with_invalid_priming_group_id (gl : Groundlight ):
954+ def test_create_detector_with_invalid_priming_group_id (gl : Groundlight , generate_test_detector_name : Callable ):
956955 """
957956 Test that creating a detector with a non-existent priming_group_id returns an appropriate error.
958957
0 commit comments