Skip to content

Commit adfc539

Browse files
Add patience_time and human_review Query Parameters to the Image Queries Endpoint (#79)
* use wait param to set iq patience time * add human_review query parameter image queries endpoint * Update spec/public-api.yaml Co-authored-by: robotrapta <[email protected]> * Update generated/openapi_client/api/image_queries_api.py Co-authored-by: robotrapta <[email protected]> --------- Co-authored-by: robotrapta <[email protected]>
1 parent ac41407 commit adfc539

File tree

5 files changed

+34
-3
lines changed

5 files changed

+34
-3
lines changed

generated/docs/ImageQueriesApi.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ with openapi_client.ApiClient(configuration) as api_client:
205205
# Create an instance of the API class
206206
api_instance = image_queries_api.ImageQueriesApi(api_client)
207207
detector_id = "detector_id_example" # str | Choose a detector by its ID.
208+
human_review = True # bool | Allow image queries to be marked for no human review. (optional)
209+
patience_time = 3.14 # float | How long to wait for a confident response. (optional)
208210
body = open('@path/to/image.jpeg', 'rb') # file_type | (optional)
209211

210212
# example passing only required values which don't have defaults set
@@ -217,7 +219,7 @@ with openapi_client.ApiClient(configuration) as api_client:
217219
# example passing only required values which don't have defaults set
218220
# and optional values
219221
try:
220-
api_response = api_instance.submit_image_query(detector_id, body=body)
222+
api_response = api_instance.submit_image_query(detector_id, human_review=human_review, patience_time=patience_time, body=body)
221223
pprint(api_response)
222224
except openapi_client.ApiException as e:
223225
print("Exception when calling ImageQueriesApi->submit_image_query: %s\n" % e)
@@ -229,6 +231,8 @@ with openapi_client.ApiClient(configuration) as api_client:
229231
Name | Type | Description | Notes
230232
------------- | ------------- | ------------- | -------------
231233
**detector_id** | **str**| Choose a detector by its ID. |
234+
**human_review** | **bool**| Allow image queries to be marked for no human review. | [optional]
235+
**patience_time** | **float**| How long to wait for a confident response. | [optional]
232236
**body** | **file_type**| | [optional]
233237

234238
### Return type

generated/model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: public-api.yaml
3-
# timestamp: 2023-05-26T20:07:17+00:00
3+
# timestamp: 2023-08-01T00:09:22+00:00
44

55
from __future__ import annotations
66

generated/openapi_client/api/image_queries_api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ def __init__(self, api_client=None):
131131
params_map={
132132
"all": [
133133
"detector_id",
134+
"human_review",
135+
"patience_time",
134136
"body",
135137
],
136138
"required": [
@@ -145,13 +147,19 @@ def __init__(self, api_client=None):
145147
"allowed_values": {},
146148
"openapi_types": {
147149
"detector_id": (str,),
150+
"human_review": (bool,),
151+
"patience_time": (float,),
148152
"body": (file_type,),
149153
},
150154
"attribute_map": {
151155
"detector_id": "detector_id",
156+
"human_review": "human_review",
157+
"patience_time": "patience_time",
152158
},
153159
"location_map": {
154160
"detector_id": "query",
161+
"human_review": "query",
162+
"patience_time": "query",
155163
"body": "body",
156164
},
157165
"collection_format_map": {},
@@ -289,6 +297,8 @@ def submit_image_query(self, detector_id, **kwargs):
289297
detector_id (str): Choose a detector by its ID.
290298
291299
Keyword Args:
300+
human_review (bool): If set to `False` then unconfident ML predictions will not be escalated to human review. [optional, defaults `True`]
301+
patience_time (float): How long to wait for a confident response.. [optional]
292302
body (file_type): [optional]
293303
_return_http_data_only (bool): response data without head status
294304
code and headers. Default is True.

spec/public-api.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,19 @@ paths:
132132
type: string
133133
description: Choose a detector by its ID.
134134
required: true
135+
- in: query
136+
name: human_review
137+
schema:
138+
type: boolean
139+
description: If set to `False` then unconfident ML predictions will not be escalated to human review. (Defaults `True`)
140+
required: false
141+
- in: query
142+
name: patience_time
143+
schema:
144+
type: number
145+
format: float
146+
description: How long to wait for a confident response.
147+
required: false
135148
tags:
136149
- image-queries
137150
requestBody:

src/groundlight/client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ def submit_image_query(
170170
detector: Union[Detector, str],
171171
image: Union[str, bytes, Image.Image, BytesIO, BufferedReader, np.ndarray],
172172
wait: Optional[float] = None,
173+
human_review: Optional[bool] = True,
173174
) -> ImageQuery:
174175
"""Evaluates an image with Groundlight.
175176
:param detector: the Detector object, or string id of a detector like `det_12345`
@@ -182,14 +183,17 @@ def submit_image_query(
182183
Any binary format must be JPEG-encoded already. Any pixel format will get
183184
converted to JPEG at high quality before sending to service.
184185
:param wait: How long to wait (in seconds) for a confident answer.
186+
:param human_review: If set to False, do not escalate for human review
185187
"""
186188
if wait is None:
187189
wait = self.DEFAULT_WAIT
188190
detector_id = detector.id if isinstance(detector, Detector) else detector
189191

190192
image_bytesio: ByteStreamWrapper = parse_supported_image_types(image)
191193

192-
raw_image_query = self.image_queries_api.submit_image_query(detector_id=detector_id, body=image_bytesio)
194+
raw_image_query = self.image_queries_api.submit_image_query(
195+
detector_id=detector_id, patience_time=wait, human_review=human_review, body=image_bytesio
196+
)
193197
image_query = ImageQuery.parse_obj(raw_image_query.to_dict())
194198
if wait:
195199
threshold = self.get_detector(detector).confidence_threshold

0 commit comments

Comments
 (0)