Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include confidence_threshold in submit_image_query params #286

Merged
merged 8 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 58 additions & 93 deletions generated/groundlight_openapi_client/model/patched_detector_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Generated by: https://openapi-generator.tech
"""


import re # noqa: F401
import sys # noqa: F401

Expand All @@ -24,7 +25,7 @@
file_type,
none_type,
validate_get_composed_info,
OpenApiModel,
OpenApiModel
)
from groundlight_openapi_client.exceptions import ApiAttributeError

Expand All @@ -33,10 +34,9 @@ def lazy_import():
from groundlight_openapi_client.model.blank_enum import BlankEnum
from groundlight_openapi_client.model.escalation_type_enum import EscalationTypeEnum
from groundlight_openapi_client.model.status_enum import StatusEnum

globals()["BlankEnum"] = BlankEnum
globals()["EscalationTypeEnum"] = EscalationTypeEnum
globals()["StatusEnum"] = StatusEnum
globals()['BlankEnum'] = BlankEnum
globals()['EscalationTypeEnum'] = EscalationTypeEnum
globals()['StatusEnum'] = StatusEnum


class PatchedDetectorRequest(ModelNormal):
Expand All @@ -63,20 +63,21 @@ class PatchedDetectorRequest(ModelNormal):
as additional properties values.
"""

allowed_values = {}
allowed_values = {
}

validations = {
("name",): {
"max_length": 200,
"min_length": 1,
('name',): {
'max_length': 200,
'min_length': 1,
},
("confidence_threshold",): {
"inclusive_maximum": 1.0,
"inclusive_minimum": 0.0,
('confidence_threshold',): {
'inclusive_maximum': 1.0,
'inclusive_minimum': 0.0,
},
("patience_time",): {
"inclusive_maximum": 3600,
"inclusive_minimum": 0,
('patience_time',): {
'inclusive_maximum': 3600,
'inclusive_minimum': 0,
},
}

Expand All @@ -87,17 +88,7 @@ def additional_properties_type():
of type self, this must run after the class is loaded
"""
lazy_import()
return (
bool,
date,
datetime,
dict,
float,
int,
list,
str,
none_type,
) # noqa: E501
return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501

_nullable = False

Expand All @@ -113,46 +104,28 @@ def openapi_types():
"""
lazy_import()
return {
"name": (str,), # noqa: E501
"confidence_threshold": (float,), # noqa: E501
"patience_time": (float,), # noqa: E501
"status": (
bool,
date,
datetime,
dict,
float,
int,
list,
str,
none_type,
), # noqa: E501
"escalation_type": (
bool,
date,
datetime,
dict,
float,
int,
list,
str,
none_type,
), # noqa: E501
'name': (str,), # noqa: E501
'confidence_threshold': (float,), # noqa: E501
'patience_time': (float,), # noqa: E501
'status': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501
'escalation_type': (bool, date, datetime, dict, float, int, list, str, none_type,), # noqa: E501
}

@cached_property
def discriminator():
return None


attribute_map = {
"name": "name", # noqa: E501
"confidence_threshold": "confidence_threshold", # noqa: E501
"patience_time": "patience_time", # noqa: E501
"status": "status", # noqa: E501
"escalation_type": "escalation_type", # noqa: E501
'name': 'name', # noqa: E501
'confidence_threshold': 'confidence_threshold', # noqa: E501
'patience_time': 'patience_time', # noqa: E501
'status': 'status', # noqa: E501
'escalation_type': 'escalation_type', # noqa: E501
}

read_only_vars = {}
read_only_vars = {
}

_composed_schemas = {}

Expand Down Expand Up @@ -199,18 +172,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
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
"""

_check_type = kwargs.pop("_check_type", True)
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
_path_to_item = kwargs.pop("_path_to_item", ())
_configuration = kwargs.pop("_configuration", None)
_visited_composed_classes = kwargs.pop("_visited_composed_classes", ())
_check_type = kwargs.pop('_check_type', True)
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
_path_to_item = kwargs.pop('_path_to_item', ())
_configuration = kwargs.pop('_configuration', None)
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())

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

if args:
raise ApiTypeError(
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments."
% (
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
args,
self.__class__.__name__,
),
Expand All @@ -226,24 +198,22 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

for var_name, var_value in kwargs.items():
if (
var_name not in self.attribute_map
and self._configuration is not None
and self._configuration.discard_unknown_keys
and self.additional_properties_type is None
):
if var_name not in self.attribute_map and \
self._configuration is not None and \
self._configuration.discard_unknown_keys and \
self.additional_properties_type is None:
# discard variable.
continue
setattr(self, var_name, var_value)
return self

required_properties = set([
"_data_store",
"_check_type",
"_spec_property_naming",
"_path_to_item",
"_configuration",
"_visited_composed_classes",
'_data_store',
'_check_type',
'_spec_property_naming',
'_path_to_item',
'_configuration',
'_visited_composed_classes',
])

@convert_js_args_to_python_args
Expand Down Expand Up @@ -288,16 +258,15 @@ def __init__(self, *args, **kwargs): # noqa: E501
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
"""

_check_type = kwargs.pop("_check_type", True)
_spec_property_naming = kwargs.pop("_spec_property_naming", False)
_path_to_item = kwargs.pop("_path_to_item", ())
_configuration = kwargs.pop("_configuration", None)
_visited_composed_classes = kwargs.pop("_visited_composed_classes", ())
_check_type = kwargs.pop('_check_type', True)
_spec_property_naming = kwargs.pop('_spec_property_naming', False)
_path_to_item = kwargs.pop('_path_to_item', ())
_configuration = kwargs.pop('_configuration', None)
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())

if args:
raise ApiTypeError(
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments."
% (
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
args,
self.__class__.__name__,
),
Expand All @@ -313,17 +282,13 @@ def __init__(self, *args, **kwargs): # noqa: E501
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

for var_name, var_value in kwargs.items():
if (
var_name not in self.attribute_map
and self._configuration is not None
and self._configuration.discard_unknown_keys
and self.additional_properties_type is None
):
if var_name not in self.attribute_map and \
self._configuration is not None and \
self._configuration.discard_unknown_keys and \
self.additional_properties_type is None:
# discard variable.
continue
setattr(self, var_name, var_value)
if var_name in self.read_only_vars:
raise ApiAttributeError(
f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate "
"class with read only attributes."
)
raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate "
f"class with read only attributes.")
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: 2024-12-07T00:51:02+00:00
# timestamp: 2024-12-09T18:29:17+00:00

from __future__ import annotations

Expand Down
3 changes: 3 additions & 0 deletions src/groundlight/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,9 @@ def submit_image_query( # noqa: PLR0913 # pylint: disable=too-many-arguments, t
if patience_time is not None:
params["patience_time"] = patience_time

if confidence_threshold is not None:
params["confidence_threshold"] = confidence_threshold

if human_review is not None:
params["human_review"] = human_review

Expand Down
12 changes: 12 additions & 0 deletions test/integration/test_groundlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,18 @@ def test_submit_image_query_png(gl: Groundlight, detector: Detector):
assert is_valid_display_result(_image_query.result)


def test_submit_image_query_with_confidence_threshold(gl: Groundlight, detector: Detector):
confidence_threshold = 0.5234 # Arbitrary specific value
_image_query = gl.submit_image_query(
detector=detector.id,
image="test/assets/dog.jpeg",
wait=10,
confidence_threshold=confidence_threshold,
human_review="NEVER",
)
assert _image_query.confidence_threshold == confidence_threshold


@pytest.mark.skip_for_edge_endpoint(reason="The edge-endpoint does not support passing an image query ID.")
def test_submit_image_query_with_id(gl: Groundlight, detector: Detector):
# submit_image_query
Expand Down
Loading