Skip to content

Commit 23afab2

Browse files
author
brandon
committed
bugfix related to removing enum validation
1 parent 7c51af0 commit 23afab2

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

src/groundlight/experimental_api.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from groundlight_openapi_client.model.payload_template_request import PayloadTemplateRequest
3131
from groundlight_openapi_client.model.rule_request import RuleRequest
3232
from groundlight_openapi_client.model.status_enum import StatusEnum
33-
from groundlight_openapi_client.model.verb_enum import VerbEnum
3433
from groundlight_openapi_client.model.webhook_action_request import WebhookActionRequest
3534
from model import (
3635
ROI,
@@ -302,7 +301,7 @@ def create_alert( # pylint: disable=too-many-locals, too-many-arguments # noqa
302301
name=name,
303302
enabled=enabled,
304303
action=actions,
305-
condition=ConditionRequest(verb=VerbEnum(condition.verb), parameters=condition.parameters),
304+
condition=ConditionRequest(verb=condition.verb, parameters=condition.parameters),
306305
snooze_time_enabled=snooze_time_enabled,
307306
snooze_time_value=snooze_time_value,
308307
snooze_time_unit=snooze_time_unit,
@@ -318,7 +317,7 @@ def create_rule( # pylint: disable=too-many-locals # noqa: PLR0913
318317
channel: Union[str, ChannelEnum],
319318
recipient: str,
320319
*,
321-
alert_on: Union[str, VerbEnum] = "CHANGED_TO",
320+
alert_on: str = "CHANGED_TO",
322321
enabled: bool = True,
323322
include_image: bool = False,
324323
condition_parameters: Union[str, dict, None] = None,
@@ -393,8 +392,6 @@ def create_rule( # pylint: disable=too-many-locals # noqa: PLR0913
393392

394393
if condition_parameters is None:
395394
condition_parameters = {}
396-
if isinstance(alert_on, str):
397-
alert_on = VerbEnum(alert_on.upper())
398395
if isinstance(channel, str):
399396
channel = ChannelEnum(channel.upper())
400397
if isinstance(condition_parameters, str):
@@ -839,7 +836,7 @@ def update_detector_escalation_type(self, detector: Union[str, Detector], escala
839836
raise ValueError("escalation_type must be either 'STANDARD' or 'NO_HUMAN_LABELING'")
840837
self.detectors_api.update_detector(
841838
detector,
842-
patched_detector_request=PatchedDetectorRequest(escalation_type=EscalationTypeEnum(escalation_type)),
839+
patched_detector_request=PatchedDetectorRequest(escalation_type=escalation_type),
843840
)
844841

845842
def create_counting_detector( # noqa: PLR0913 # pylint: disable=too-many-arguments, too-many-locals

test/unit/test_experimental.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ def test_update_detector_escalation_type(gl_experimental: ExperimentalApi):
6060
detector = gl_experimental.get_or_create_detector(f"test {datetime.utcnow()}", "Is there a dog?")
6161
gl_experimental.update_detector_escalation_type(detector.id, "NO_HUMAN_LABELING")
6262
updated_detector = gl_experimental.get_detector(detector.id)
63-
updated_detector.escalation_type.value == "NO_HUMAN_LABELING"
63+
updated_detector.escalation_type == "NO_HUMAN_LABELING"
6464
gl_experimental.update_detector_escalation_type(detector.id, "STANDARD")
6565
updated_detector = gl_experimental.get_detector(detector.id)
66-
updated_detector.escalation_type.value == "STANDARD"
66+
updated_detector.escalation_type == "STANDARD"
6767

6868

6969
@pytest.mark.skip(

0 commit comments

Comments
 (0)