Skip to content

Commit eaf3a54

Browse files
committed
request timeout for submit_image_query
1 parent e438031 commit eaf3a54

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/groundlight/client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ def _fixup_image_query(iq: ImageQuery) -> ImageQuery:
233233
iq.result.label = convert_internal_label_to_display(iq, iq.result.label)
234234
return iq
235235

236+
def _get_request_timeout(self, **kwargs):
237+
"""Extract request_timeout from kwargs or use default."""
238+
return kwargs.get("request_timeout", DEFAULT_REQUEST_TIMEOUT)
239+
236240
def whoami(self) -> str:
237241
"""
238242
Return the username (email address) associated with the current API token.
@@ -637,6 +641,7 @@ def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments, t
637641
inspection_id: Optional[str] = None,
638642
metadata: Union[dict, str, None] = None,
639643
image_query_id: Optional[str] = None,
644+
**kwargs,
640645
) -> ImageQuery:
641646
"""
642647
Evaluates an image with Groundlight. This is the core method for getting predictions about images.
@@ -731,7 +736,11 @@ def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments, t
731736

732737
image_bytesio: ByteStreamWrapper = parse_supported_image_types(image)
733738

734-
params = {"detector_id": detector_id, "body": image_bytesio, "_request_timeout": DEFAULT_REQUEST_TIMEOUT}
739+
params = {
740+
"detector_id": detector_id,
741+
"body": image_bytesio,
742+
"_request_timeout": self._get_request_timeout(**kwargs),
743+
}
735744

736745
if patience_time is not None:
737746
params["patience_time"] = patience_time

0 commit comments

Comments
 (0)