From 63d945ab4544c5613993e768d03bcfe00b363c76 Mon Sep 17 00:00:00 2001 From: Tim Huff Date: Thu, 14 Mar 2024 11:39:46 -0700 Subject: [PATCH 1/5] adding back timeout --- pyproject.toml | 2 +- src/groundlight/client.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 26a17850..5a1e6538 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ packages = [ {include = "**/*.py", from = "src"}, ] readme = "README.md" -version = "0.14.0" +version = "0.14.1" [tool.poetry.dependencies] # For certifi, use ">=" instead of "^" since it upgrades its "major version" every year, not really following semver diff --git a/src/groundlight/client.py b/src/groundlight/client.py index a6fdc6b7..e7672215 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -427,14 +427,15 @@ def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments, t image_bytesio: ByteStreamWrapper = parse_supported_image_types(image) - params = {"detector_id": detector_id, "body": image_bytesio} + params = {"detector_id": detector_id, "body": image_bytesio, "_request_timeout": DEFAULT_REQUEST_TIMEOUT} + if patience_time is not None: params["patience_time"] = patience_time if human_review is not None: params["human_review"] = human_review - if inspection_id is not None: + if inspection_id: # consider an empty string to mean there is no inspection params["inspection_id"] = inspection_id if want_async is True: From 37d0d36ea8a7ab0fa023889077c4af3804c0f9dc Mon Sep 17 00:00:00 2001 From: Tim Huff Date: Thu, 14 Mar 2024 12:01:44 -0700 Subject: [PATCH 2/5] adding a test --- test/integration/test_groundlight.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/integration/test_groundlight.py b/test/integration/test_groundlight.py index 68fa43a0..2ea8579b 100644 --- a/test/integration/test_groundlight.py +++ b/test/integration/test_groundlight.py @@ -796,3 +796,14 @@ def test_submit_image_query_with_inspection_id_metadata_and_want_async(gl: Groun assert iq.metadata == metadata assert iq.result.label == Label.YES + +def test_submit_image_query_with_empty_inspection_id(gl: Groundlight, detector: Detector, image: str): + """The URCap submits the inspection_id as an empty string when there is no active inspection. + This test ensures that this behavior is allowed and does not raise an exception. + """ + gl.submit_image_query( + detector=detector.id, + image=image, + human_review="NEVER", + inspection_id='', + ) \ No newline at end of file From b8c7ea6847d3a12017a79d844799660449ecf833 Mon Sep 17 00:00:00 2001 From: Auto-format Bot Date: Thu, 14 Mar 2024 19:02:38 +0000 Subject: [PATCH 3/5] Automatically reformatting code --- test/integration/test_groundlight.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/integration/test_groundlight.py b/test/integration/test_groundlight.py index 2ea8579b..2f7dd0ed 100644 --- a/test/integration/test_groundlight.py +++ b/test/integration/test_groundlight.py @@ -797,6 +797,7 @@ def test_submit_image_query_with_inspection_id_metadata_and_want_async(gl: Groun assert iq.metadata == metadata assert iq.result.label == Label.YES + def test_submit_image_query_with_empty_inspection_id(gl: Groundlight, detector: Detector, image: str): """The URCap submits the inspection_id as an empty string when there is no active inspection. This test ensures that this behavior is allowed and does not raise an exception. @@ -805,5 +806,5 @@ def test_submit_image_query_with_empty_inspection_id(gl: Groundlight, detector: detector=detector.id, image=image, human_review="NEVER", - inspection_id='', - ) \ No newline at end of file + inspection_id="", + ) From 6c961060a8557a6927bb1ea8359904b135453456 Mon Sep 17 00:00:00 2001 From: Tim Huff Date: Mon, 18 Mar 2024 09:19:52 -0700 Subject: [PATCH 4/5] responding to pr feedback, increasing timeout slightly --- src/groundlight/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/groundlight/client.py b/src/groundlight/client.py index e7672215..51bf11f7 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -39,7 +39,7 @@ # Set urllib3 request timeout to something modern and fast. # The system defaults can be stupidly long # It used to take >8 min to timeout to a bad IP address -DEFAULT_REQUEST_TIMEOUT = 5 +DEFAULT_REQUEST_TIMEOUT = 10 # seconds class GroundlightClientError(Exception): From 90a1efe29f065d76fd86a5ab64e0ebb46769d403 Mon Sep 17 00:00:00 2001 From: Auto-format Bot Date: Mon, 18 Mar 2024 16:21:20 +0000 Subject: [PATCH 5/5] Automatically reformatting code --- src/groundlight/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/groundlight/client.py b/src/groundlight/client.py index 51bf11f7..51d96945 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -39,7 +39,7 @@ # Set urllib3 request timeout to something modern and fast. # The system defaults can be stupidly long # It used to take >8 min to timeout to a bad IP address -DEFAULT_REQUEST_TIMEOUT = 10 # seconds +DEFAULT_REQUEST_TIMEOUT = 10 # seconds class GroundlightClientError(Exception):