Skip to content

Commit d79746d

Browse files
committed
refining the tests
1 parent e459875 commit d79746d

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

test/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
from groundlight import ExperimentalApi, Groundlight
77
from model import Detector, ImageQuery, ImageQueryTypeEnum, ResultTypeEnum
88

9+
# No test in the suite expects a human review answer, and the server already blocks ~6s
10+
# for ML inference before returning. Client-side polling adds no value.
11+
TEST_IQ_SUBMISSION_WAIT = 0.0
12+
913

1014
def _generate_unique_detector_name(prefix: str = "Test") -> str:
1115
"""Generates a detector name with a timestamp and random suffix to ensure uniqueness."""
@@ -31,7 +35,7 @@ def pytest_configure(config): # pylint: disable=unused-argument
3135
def fixture_gl() -> Groundlight:
3236
"""Creates a Groundlight client object for testing."""
3337
_gl = Groundlight()
34-
_gl.DEFAULT_WAIT = 10
38+
_gl.DEFAULT_WAIT = TEST_IQ_SUBMISSION_WAIT
3539
return _gl
3640

3741

@@ -84,7 +88,7 @@ def fixture_image_query_zero(gl_experimental: Groundlight, count_detector: Detec
8488
@pytest.fixture(name="gl_experimental")
8589
def fixture_gl_experimental() -> ExperimentalApi:
8690
_gl = ExperimentalApi()
87-
_gl.DEFAULT_WAIT = 10
91+
_gl.DEFAULT_WAIT = TEST_IQ_SUBMISSION_WAIT
8892
return _gl
8993

9094

test/integration/test_groundlight.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,14 @@ def test_get_detector_by_name(gl: Groundlight, detector: Detector):
274274

275275

276276
def test_ask_confident(gl: Groundlight, detector: Detector):
277-
_image_query = gl.ask_confident(detector=detector.id, image="test/assets/dog.jpeg", wait=10)
277+
_image_query = gl.ask_confident(detector=detector.id, image="test/assets/dog.jpeg", wait=0)
278278
assert str(_image_query)
279279
assert isinstance(_image_query, ImageQuery)
280280
assert is_valid_display_result(_image_query.result)
281281

282282

283283
def test_ask_ml(gl: Groundlight, detector: Detector):
284-
_image_query = gl.ask_ml(detector=detector.id, image="test/assets/dog.jpeg", wait=10)
284+
_image_query = gl.ask_ml(detector=detector.id, image="test/assets/dog.jpeg", wait=0)
285285
assert str(_image_query)
286286
assert isinstance(_image_query, ImageQuery)
287287
assert is_valid_display_result(_image_query.result)
@@ -294,29 +294,29 @@ def validate_image_query(_image_query: ImageQuery):
294294
assert is_valid_display_result(_image_query.result)
295295

296296
_image_query = gl.submit_image_query(
297-
detector=detector.id, image="test/assets/dog.jpeg", wait=10, human_review="NEVER"
297+
detector=detector.id, image="test/assets/dog.jpeg", wait=0, human_review="NEVER"
298298
)
299299
validate_image_query(_image_query)
300300
_image_query = gl.submit_image_query(
301-
detector=detector.id, image="test/assets/dog.jpeg", wait=3, human_review="NEVER"
301+
detector=detector.id, image="test/assets/dog.jpeg", wait=0, human_review="NEVER"
302302
)
303303
validate_image_query(_image_query)
304304
_image_query = gl.submit_image_query(
305-
detector=detector.id, image="test/assets/dog.jpeg", wait=10, patience_time=20, human_review="NEVER"
305+
detector=detector.id, image="test/assets/dog.jpeg", wait=0, patience_time=20, human_review="NEVER"
306306
)
307307
validate_image_query(_image_query)
308308
_image_query = gl.submit_image_query(detector=detector.id, image="test/assets/dog.jpeg", human_review="NEVER")
309309
validate_image_query(_image_query)
310310
_image_query = gl.submit_image_query(
311-
detector=detector.id, image="test/assets/dog.jpeg", wait=180, confidence_threshold=0.75, human_review="NEVER"
311+
detector=detector.id, image="test/assets/dog.jpeg", wait=0, confidence_threshold=0.75, human_review="NEVER"
312312
)
313313
validate_image_query(_image_query)
314314
assert _image_query.result.confidence >= IQ_IMPROVEMENT_THRESHOLD
315315

316316

317317
def test_submit_image_query_blocking(gl: Groundlight, detector: Detector):
318318
_image_query = gl.submit_image_query(
319-
detector=detector.id, image="test/assets/dog.jpeg", wait=10, human_review="NEVER"
319+
detector=detector.id, image="test/assets/dog.jpeg", wait=0, human_review="NEVER"
320320
)
321321
assert str(_image_query)
322322
assert isinstance(_image_query, ImageQuery)
@@ -326,7 +326,7 @@ def test_submit_image_query_blocking(gl: Groundlight, detector: Detector):
326326
def test_submit_image_query_returns_yes(gl: Groundlight):
327327
# We use the "never-review" pipeline to guarantee a confident "yes" answer.
328328
detector = gl.get_or_create_detector(name="Always a dog", query="Is there a dog?", pipeline_config="never-review")
329-
image_query = gl.submit_image_query(detector=detector, image="test/assets/dog.jpeg", wait=10, human_review="NEVER")
329+
image_query = gl.submit_image_query(detector=detector, image="test/assets/dog.jpeg", wait=0, human_review="NEVER")
330330
assert image_query.result.label == Label.YES
331331

332332

@@ -335,7 +335,7 @@ def test_submit_image_query_returns_text(gl: Groundlight):
335335
detector = gl.get_or_create_detector(
336336
name="Always same text", query="Is there a dog?", pipeline_config="constant-text-pred"
337337
)
338-
image_query = gl.submit_image_query(detector=detector, image="test/assets/dog.jpeg", wait=10, human_review="NEVER")
338+
image_query = gl.submit_image_query(detector=detector, image="test/assets/dog.jpeg", wait=0, human_review="NEVER")
339339
assert isinstance(image_query.text, str)
340340

341341

@@ -358,7 +358,7 @@ def test_submit_image_query_with_confidence_threshold(gl: Groundlight, detector:
358358
_image_query = gl.submit_image_query(
359359
detector=detector.id,
360360
image="test/assets/dog.jpeg",
361-
wait=10,
361+
wait=0,
362362
confidence_threshold=confidence_threshold,
363363
human_review="NEVER",
364364
)
@@ -370,7 +370,7 @@ def test_submit_image_query_with_id(gl: Groundlight, detector: Detector):
370370
# submit_image_query
371371
id = f"iq_{KsuidMs()}"
372372
_image_query = gl.submit_image_query(
373-
detector=detector.id, image="test/assets/dog.jpeg", wait=10, human_review="NEVER", image_query_id=id
373+
detector=detector.id, image="test/assets/dog.jpeg", wait=0, human_review="NEVER", image_query_id=id
374374
)
375375
assert str(_image_query)
376376
assert isinstance(_image_query, ImageQuery)

test/unit/test_http_retries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_submit_image_query_attempts_retries(gl: Groundlight, detector_name: Cal
8080
expected_call_counts=TOTAL_RETRIES + 1,
8181
detector=detector_name(),
8282
image=IMAGE_FILE,
83-
wait=1,
83+
wait=0,
8484
)
8585

8686

0 commit comments

Comments
 (0)