From 73a0f9a6e03457be386b8e43f2260b80654ac9a9 Mon Sep 17 00:00:00 2001 From: blaise-muhirwa Date: Thu, 27 Jul 2023 14:25:30 -0700 Subject: [PATCH] use wait param to set iq patience time --- generated/docs/ImageQueriesApi.md | 8 +++++--- generated/model.py | 2 +- generated/openapi_client/api/image_queries_api.py | 11 +++++++++-- spec/public-api.yaml | 7 +++++++ src/groundlight/client.py | 4 +++- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/generated/docs/ImageQueriesApi.md b/generated/docs/ImageQueriesApi.md index 83c29bd0..44af90bc 100644 --- a/generated/docs/ImageQueriesApi.md +++ b/generated/docs/ImageQueriesApi.md @@ -167,7 +167,7 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **submit_image_query** -> ImageQuery submit_image_query(detector_id) +> ImageQuery submit_image_query(detector_id, patience_time) @@ -205,11 +205,12 @@ with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = image_queries_api.ImageQueriesApi(api_client) detector_id = "detector_id_example" # str | Choose a detector by its ID. + patience_time = 3.14 # float | How long to wait for a confident response. body = open('@path/to/image.jpeg', 'rb') # file_type | (optional) # example passing only required values which don't have defaults set try: - api_response = api_instance.submit_image_query(detector_id) + api_response = api_instance.submit_image_query(detector_id, patience_time) pprint(api_response) except openapi_client.ApiException as e: print("Exception when calling ImageQueriesApi->submit_image_query: %s\n" % e) @@ -217,7 +218,7 @@ with openapi_client.ApiClient(configuration) as api_client: # example passing only required values which don't have defaults set # and optional values try: - api_response = api_instance.submit_image_query(detector_id, body=body) + api_response = api_instance.submit_image_query(detector_id, patience_time, body=body) pprint(api_response) except openapi_client.ApiException as e: print("Exception when calling ImageQueriesApi->submit_image_query: %s\n" % e) @@ -229,6 +230,7 @@ with openapi_client.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **detector_id** | **str**| Choose a detector by its ID. | + **patience_time** | **float**| How long to wait for a confident response. | **body** | **file_type**| | [optional] ### Return type diff --git a/generated/model.py b/generated/model.py index 0b3b9079..b7fa9077 100644 --- a/generated/model.py +++ b/generated/model.py @@ -1,6 +1,6 @@ # generated by datamodel-codegen: # filename: public-api.yaml -# timestamp: 2023-05-26T20:07:17+00:00 +# timestamp: 2023-07-27T21:24:51+00:00 from __future__ import annotations diff --git a/generated/openapi_client/api/image_queries_api.py b/generated/openapi_client/api/image_queries_api.py index 544b7e62..89a331fd 100644 --- a/generated/openapi_client/api/image_queries_api.py +++ b/generated/openapi_client/api/image_queries_api.py @@ -131,10 +131,12 @@ def __init__(self, api_client=None): params_map={ "all": [ "detector_id", + "patience_time", "body", ], "required": [ "detector_id", + "patience_time", ], "nullable": [], "enum": [], @@ -145,13 +147,16 @@ def __init__(self, api_client=None): "allowed_values": {}, "openapi_types": { "detector_id": (str,), + "patience_time": (float,), "body": (file_type,), }, "attribute_map": { "detector_id": "detector_id", + "patience_time": "patience_time", }, "location_map": { "detector_id": "query", + "patience_time": "query", "body": "body", }, "collection_format_map": {}, @@ -275,18 +280,19 @@ def list_image_queries(self, **kwargs): kwargs["_host_index"] = kwargs.get("_host_index") return self.list_image_queries_endpoint.call_with_http_info(**kwargs) - def submit_image_query(self, detector_id, **kwargs): + def submit_image_query(self, detector_id, patience_time, **kwargs): """submit_image_query # noqa: E501 Submit an image query against a detector. You must use `\"Content-Type: image/jpeg\"` for the image data. For example: ```Bash $ curl https://api.groundlight.ai/device-api/v1/image-queries?detector_id=det_abc123 \\ --header \"Content-Type: image/jpeg\" \\ --data-binary @path/to/filename.jpeg ``` # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.submit_image_query(detector_id, async_req=True) + >>> thread = api.submit_image_query(detector_id, patience_time, async_req=True) >>> result = thread.get() Args: detector_id (str): Choose a detector by its ID. + patience_time (float): How long to wait for a confident response. Keyword Args: body (file_type): [optional] @@ -332,4 +338,5 @@ def submit_image_query(self, detector_id, **kwargs): kwargs["_content_type"] = kwargs.get("_content_type") kwargs["_host_index"] = kwargs.get("_host_index") kwargs["detector_id"] = detector_id + kwargs["patience_time"] = patience_time return self.submit_image_query_endpoint.call_with_http_info(**kwargs) diff --git a/spec/public-api.yaml b/spec/public-api.yaml index b9020145..edc121da 100644 --- a/spec/public-api.yaml +++ b/spec/public-api.yaml @@ -132,6 +132,13 @@ paths: type: string description: Choose a detector by its ID. required: true + - in: query + name: patience_time + schema: + type: number + format: float + description: How long to wait for a confident response. + required: true tags: - image-queries requestBody: diff --git a/src/groundlight/client.py b/src/groundlight/client.py index e0250bcf..2e6d51fb 100644 --- a/src/groundlight/client.py +++ b/src/groundlight/client.py @@ -189,7 +189,9 @@ def submit_image_query( image_bytesio: ByteStreamWrapper = parse_supported_image_types(image) - raw_image_query = self.image_queries_api.submit_image_query(detector_id=detector_id, body=image_bytesio) + raw_image_query = self.image_queries_api.submit_image_query( + detector_id=detector_id, patience_time=wait, body=image_bytesio + ) image_query = ImageQuery.parse_obj(raw_image_query.to_dict()) if wait: threshold = self.get_detector(detector).confidence_threshold