From 52d3969324f2d7f61cca1530885ee230b98f4d3f Mon Sep 17 00:00:00 2001 From: brandon Date: Tue, 29 Apr 2025 13:56:40 -0700 Subject: [PATCH 1/2] allows updating a detectors cloud labeling status --- src/groundlight/experimental_api.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/groundlight/experimental_api.py b/src/groundlight/experimental_api.py index 98c3754e..05bff3a6 100644 --- a/src/groundlight/experimental_api.py +++ b/src/groundlight/experimental_api.py @@ -1094,3 +1094,30 @@ def make_generic_api_request( # noqa: PLR0913 # pylint: disable=too-many-argume auth_settings=["ApiToken"], _preload_content=False, # This returns the urllib3 response rather than trying any type of processing ) + + def update_detector( + self, + detector: Union[str, Detector], + confidence_threshold: Optional[float] = None, + cloud_labeling_active: Optional[bool] = None, + ) -> None: + """ + Updates the detector with the given id. + + :param detector: The detector to update + :param confidence_threshold: The new confidence threshold for the detector + :param cloud_labeling_active: Whether cloud labeling is active for the detector + """ + if cloud_labeling_active: + escalation_type = "STANDARD" + else: + escalation_type = "NO_HUMAN_LABELING" + if isinstance(detector, Detector): + detector = detector.id + self.detectors_api.update_detector( + detector, + patched_detector_request=PatchedDetectorRequest( + confidence_threshold=confidence_threshold, + escalation_type=escalation_type, + ), + ) From 8925ebb592efacf9ae4bd45005c154f9cbf17669 Mon Sep 17 00:00:00 2001 From: Auto-format Bot Date: Tue, 29 Apr 2025 20:57:41 +0000 Subject: [PATCH 2/2] Automatically reformatting code --- src/groundlight/experimental_api.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/groundlight/experimental_api.py b/src/groundlight/experimental_api.py index 05bff3a6..d79f7dab 100644 --- a/src/groundlight/experimental_api.py +++ b/src/groundlight/experimental_api.py @@ -1096,10 +1096,10 @@ def make_generic_api_request( # noqa: PLR0913 # pylint: disable=too-many-argume ) def update_detector( - self, - detector: Union[str, Detector], - confidence_threshold: Optional[float] = None, - cloud_labeling_active: Optional[bool] = None, + self, + detector: Union[str, Detector], + confidence_threshold: Optional[float] = None, + cloud_labeling_active: Optional[bool] = None, ) -> None: """ Updates the detector with the given id.