From 058b8aa227deb498aa6a90d1892b6ce963ff7b4b Mon Sep 17 00:00:00 2001 From: Matt Date: Thu, 11 Jun 2026 15:26:23 +0100 Subject: [PATCH] Remove deduplication from client side --- simvue/api/objects/alert/user.py | 5 ++-- simvue/run.py | 39 -------------------------------- 2 files changed, 3 insertions(+), 41 deletions(-) diff --git a/simvue/api/objects/alert/user.py b/simvue/api/objects/alert/user.py index e4787e74..5c43febb 100644 --- a/simvue/api/objects/alert/user.py +++ b/simvue/api/objects/alert/user.py @@ -101,7 +101,7 @@ def new( token for alternative server, default None """ - return cls( + _alert = cls( name=name, description=description, notification=notification, @@ -109,10 +109,11 @@ def new( enabled=enabled, server_url=server_url, server_token=server_token, - _params={"deduplicate": True}, _read_only=False, _offline=offline, ) + _alert._params = {"deduplicate": True} + return _alert @override def _compare_objects(self, other: "AlertBase") -> bool: diff --git a/simvue/run.py b/simvue/run.py index fd2f9b90..7c05a330 100644 --- a/simvue/run.py +++ b/simvue/run.py @@ -76,9 +76,6 @@ except ImportError: from typing_extensions import Self -if typing.TYPE_CHECKING: - from simvue.api.objects.alert.base import AlertBase - HEARTBEAT_INTERVAL: int = 60 RESOURCES_METRIC_PREFIX: str = "resources" @@ -2314,18 +2311,6 @@ def add_alerts( return True - def _check_if_alert_exists(self, alert: "AlertBase") -> str | None: - """Check if an existing alert matches definition.""" - # If the alert already exists just add the existing one - for _id, _existing_alert in Alert.get( - offline=self.mode == "offline", - server_url=self._user_config.server.url, - server_token=self._user_config.server.token, - ): - if _existing_alert == alert: - return _id - return None - @skip_if_failed("_aborted", "_suppress_errors", on_failure_return=None) @pydantic.validate_call def create_metric_range_alert( @@ -2410,12 +2395,6 @@ def create_metric_range_alert( server_token=self._user_config.server.token, ) - # If the alert already exists just add the existing one - if _existing_id := self._check_if_alert_exists(_alert): - if attach_to_run: - self.add_alerts(ids=[_existing_id]) - return _existing_id - _alert.abort = trigger_abort _alert.commit() if attach_to_run: @@ -2503,12 +2482,6 @@ def create_metric_threshold_alert( server_token=self._user_config.server.token, ) - # If the alert already exists just add the existing one - if _existing_id := self._check_if_alert_exists(_alert): - if attach_to_run: - self.add_alerts(ids=[_existing_id]) - return _existing_id - _alert.abort = trigger_abort _alert.commit() if attach_to_run: @@ -2568,12 +2541,6 @@ def create_event_alert( server_token=self._user_config.server.token, ) - # If the alert already exists just add the existing one - if _existing_id := self._check_if_alert_exists(_alert): - if attach_to_run: - self.add_alerts(ids=[_existing_id]) - return _existing_id - _alert.abort = trigger_abort _alert.commit() @@ -2627,12 +2594,6 @@ def create_user_alert( server_token=self._user_config.server.token, ) - # If the alert already exists just add the existing one - if _existing_id := self._check_if_alert_exists(_alert): - if attach_to_run: - self.add_alerts(ids=[_existing_id]) - return _existing_id - _alert.abort = trigger_abort _alert.commit() if attach_to_run: