Skip to content

Commit 302edad

Browse files
authored
Include confidence_threshold in submit_image_query params (#286)
Pass `confidence_threshold` through to the `submit_image_query` call, which will fix some edge behavior and improve overall consistency. Will merge after the backend change is deployed.
1 parent d88db2c commit 302edad

File tree

4 files changed

+74
-94
lines changed

4 files changed

+74
-94
lines changed

generated/groundlight_openapi_client/model/patched_detector_request.py

Lines changed: 58 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Generated by: https://openapi-generator.tech
99
"""
1010

11+
1112
import re # noqa: F401
1213
import sys # noqa: F401
1314

@@ -24,7 +25,7 @@
2425
file_type,
2526
none_type,
2627
validate_get_composed_info,
27-
OpenApiModel,
28+
OpenApiModel
2829
)
2930
from groundlight_openapi_client.exceptions import ApiAttributeError
3031

@@ -33,10 +34,9 @@ def lazy_import():
3334
from groundlight_openapi_client.model.blank_enum import BlankEnum
3435
from groundlight_openapi_client.model.escalation_type_enum import EscalationTypeEnum
3536
from groundlight_openapi_client.model.status_enum import StatusEnum
36-
37-
globals()["BlankEnum"] = BlankEnum
38-
globals()["EscalationTypeEnum"] = EscalationTypeEnum
39-
globals()["StatusEnum"] = StatusEnum
37+
globals()['BlankEnum'] = BlankEnum
38+
globals()['EscalationTypeEnum'] = EscalationTypeEnum
39+
globals()['StatusEnum'] = StatusEnum
4040

4141

4242
class PatchedDetectorRequest(ModelNormal):
@@ -63,20 +63,21 @@ class PatchedDetectorRequest(ModelNormal):
6363
as additional properties values.
6464
"""
6565

66-
allowed_values = {}
66+
allowed_values = {
67+
}
6768

6869
validations = {
69-
("name",): {
70-
"max_length": 200,
71-
"min_length": 1,
70+
('name',): {
71+
'max_length': 200,
72+
'min_length': 1,
7273
},
73-
("confidence_threshold",): {
74-
"inclusive_maximum": 1.0,
75-
"inclusive_minimum": 0.0,
74+
('confidence_threshold',): {
75+
'inclusive_maximum': 1.0,
76+
'inclusive_minimum': 0.0,
7677
},
77-
("patience_time",): {
78-
"inclusive_maximum": 3600,
79-
"inclusive_minimum": 0,
78+
('patience_time',): {
79+
'inclusive_maximum': 3600,
80+
'inclusive_minimum': 0,
8081
},
8182
}
8283

@@ -87,17 +88,7 @@ def additional_properties_type():
8788
of type self, this must run after the class is loaded
8889
"""
8990
lazy_import()
90-
return (
91-
bool,
92-
date,
93-
datetime,
94-
dict,
95-
float,
96-
int,
97-
list,
98-
str,
99-
none_type,
100-
) # noqa: E501
91+
return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501
10192

10293
_nullable = False
10394

@@ -113,46 +104,28 @@ def openapi_types():
113104
"""
114105
lazy_import()
115106
return {
116-
"name": (str,), # noqa: E501
117-
"confidence_threshold": (float,), # noqa: E501
118-
"patience_time": (float,), # noqa: E501
119-
"status": (
120-
bool,
121-
date,
122-
datetime,
123-
dict,
124-
float,
125-
int,
126-
list,
127-
str,
128-
none_type,
129-
), # noqa: E501
130-
"escalation_type": (
131-
bool,
132-
date,
133-
datetime,
134-
dict,
135-
float,
136-
int,
137-
list,
138-
str,
139-
none_type,
140-
), # noqa: E501
107+
'name': (str,), # noqa: E501
108+
'confidence_threshold': (float,), # noqa: E501
109+
'patience_time': (float,), # noqa: E501
110+
'status': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501
111+
'escalation_type': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501
141112
}
142113

143114
@cached_property
144115
def discriminator():
145116
return None
146117

118+
147119
attribute_map = {
148-
"name": "name", # noqa: E501
149-
"confidence_threshold": "confidence_threshold", # noqa: E501
150-
"patience_time": "patience_time", # noqa: E501
151-
"status": "status", # noqa: E501
152-
"escalation_type": "escalation_type", # noqa: E501
120+
'name': 'name', # noqa: E501
121+
'confidence_threshold': 'confidence_threshold', # noqa: E501
122+
'patience_time': 'patience_time', # noqa: E501
123+
'status': 'status', # noqa: E501
124+
'escalation_type': 'escalation_type', # noqa: E501
153125
}
154126

155-
read_only_vars = {}
127+
read_only_vars = {
128+
}
156129

157130
_composed_schemas = {}
158131

@@ -199,18 +172,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
199172
escalation_type (bool, date, datetime, dict, float, int, list, str, none_type): Category that define internal proccess for labeling image queries * `STANDARD` - STANDARD * `NO_HUMAN_LABELING` - NO_HUMAN_LABELING. [optional] # noqa: E501
200173
"""
201174

202-
_check_type = kwargs.pop("_check_type", True)
203-
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
204-
_path_to_item = kwargs.pop("_path_to_item", ())
205-
_configuration = kwargs.pop("_configuration", None)
206-
_visited_composed_classes = kwargs.pop("_visited_composed_classes", ())
175+
_check_type = kwargs.pop('_check_type', True)
176+
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
177+
_path_to_item = kwargs.pop('_path_to_item', ())
178+
_configuration = kwargs.pop('_configuration', None)
179+
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
207180

208181
self = super(OpenApiModel, cls).__new__(cls)
209182

210183
if args:
211184
raise ApiTypeError(
212-
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments."
213-
% (
185+
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
214186
args,
215187
self.__class__.__name__,
216188
),
@@ -226,24 +198,22 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
226198
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
227199

228200
for var_name, var_value in kwargs.items():
229-
if (
230-
var_name not in self.attribute_map
231-
and self._configuration is not None
232-
and self._configuration.discard_unknown_keys
233-
and self.additional_properties_type is None
234-
):
201+
if var_name not in self.attribute_map and \
202+
self._configuration is not None and \
203+
self._configuration.discard_unknown_keys and \
204+
self.additional_properties_type is None:
235205
# discard variable.
236206
continue
237207
setattr(self, var_name, var_value)
238208
return self
239209

240210
required_properties = set([
241-
"_data_store",
242-
"_check_type",
243-
"_spec_property_naming",
244-
"_path_to_item",
245-
"_configuration",
246-
"_visited_composed_classes",
211+
'_data_store',
212+
'_check_type',
213+
'_spec_property_naming',
214+
'_path_to_item',
215+
'_configuration',
216+
'_visited_composed_classes',
247217
])
248218

249219
@convert_js_args_to_python_args
@@ -288,16 +258,15 @@ def __init__(self, *args, **kwargs): # noqa: E501
288258
escalation_type (bool, date, datetime, dict, float, int, list, str, none_type): Category that define internal proccess for labeling image queries * `STANDARD` - STANDARD * `NO_HUMAN_LABELING` - NO_HUMAN_LABELING. [optional] # noqa: E501
289259
"""
290260

291-
_check_type = kwargs.pop("_check_type", True)
292-
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
293-
_path_to_item = kwargs.pop("_path_to_item", ())
294-
_configuration = kwargs.pop("_configuration", None)
295-
_visited_composed_classes = kwargs.pop("_visited_composed_classes", ())
261+
_check_type = kwargs.pop('_check_type', True)
262+
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
263+
_path_to_item = kwargs.pop('_path_to_item', ())
264+
_configuration = kwargs.pop('_configuration', None)
265+
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())
296266

297267
if args:
298268
raise ApiTypeError(
299-
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments."
300-
% (
269+
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
301270
args,
302271
self.__class__.__name__,
303272
),
@@ -313,17 +282,13 @@ def __init__(self, *args, **kwargs): # noqa: E501
313282
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
314283

315284
for var_name, var_value in kwargs.items():
316-
if (
317-
var_name not in self.attribute_map
318-
and self._configuration is not None
319-
and self._configuration.discard_unknown_keys
320-
and self.additional_properties_type is None
321-
):
285+
if var_name not in self.attribute_map and \
286+
self._configuration is not None and \
287+
self._configuration.discard_unknown_keys and \
288+
self.additional_properties_type is None:
322289
# discard variable.
323290
continue
324291
setattr(self, var_name, var_value)
325292
if var_name in self.read_only_vars:
326-
raise ApiAttributeError(
327-
f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate "
328-
"class with read only attributes."
329-
)
293+
raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate "
294+
f"class with read only attributes.")

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: 2024-12-07T00:51:02+00:00
3+
# timestamp: 2024-12-09T18:29:17+00:00
44

55
from __future__ import annotations
66

src/groundlight/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,9 @@ def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments, t
669669
if patience_time is not None:
670670
params["patience_time"] = patience_time
671671

672+
if confidence_threshold is not None:
673+
params["confidence_threshold"] = confidence_threshold
674+
672675
if human_review is not None:
673676
params["human_review"] = human_review
674677

test/integration/test_groundlight.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,18 @@ def test_submit_image_query_png(gl: Groundlight, detector: Detector):
320320
assert is_valid_display_result(_image_query.result)
321321

322322

323+
def test_submit_image_query_with_confidence_threshold(gl: Groundlight, detector: Detector):
324+
confidence_threshold = 0.5234 # Arbitrary specific value
325+
_image_query = gl.submit_image_query(
326+
detector=detector.id,
327+
image="test/assets/dog.jpeg",
328+
wait=10,
329+
confidence_threshold=confidence_threshold,
330+
human_review="NEVER",
331+
)
332+
assert _image_query.confidence_threshold == confidence_threshold
333+
334+
323335
@pytest.mark.skip_for_edge_endpoint(reason="The edge-endpoint does not support passing an image query ID.")
324336
def test_submit_image_query_with_id(gl: Groundlight, detector: Detector):
325337
# submit_image_query

0 commit comments

Comments
 (0)