Skip to content

Commit

Permalink
use wait param to set iq patience time
Browse files Browse the repository at this point in the history
  • Loading branch information
blaise-muhirwa committed Jul 27, 2023
1 parent 9426378 commit 73a0f9a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
8 changes: 5 additions & 3 deletions generated/docs/ImageQueriesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -205,19 +205,20 @@ 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)

# 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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion generated/model.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
11 changes: 9 additions & 2 deletions generated/openapi_client/api/image_queries_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": [],
Expand All @@ -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": {},
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)
7 changes: 7 additions & 0 deletions spec/public-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion src/groundlight/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 73a0f9a

Please sign in to comment.