Skip to content

Commit 56bfe9c

Browse files
committed
Merge branch 'dev'
2 parents 381a4f3 + 5bbae4d commit 56bfe9c

File tree

18 files changed

+159
-40
lines changed

18 files changed

+159
-40
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ repos:
2323
args: [--branch, main, --branch, dev]
2424
- id: check-added-large-files
2525
- repo: https://github.com/astral-sh/ruff-pre-commit
26-
rev: v0.13.3
26+
rev: v0.14.3
2727
hooks:
2828
- id: ruff
2929
args: [ --fix, --exit-non-zero-on-fix, "--ignore=C901" ]

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [v2.2.3](https://github.com/simvue-io/client/releases/tag/v2.2.3) - 2025-11-10
4+
5+
- Use `msgpack` for `GridMetrics` in a manner similar to `Metrics`.
6+
- Fix incorrect setting of global log level.
7+
- Fix alert duplication in offline mode and other offline fixes.
8+
39
## [v2.2.2](https://github.com/simvue-io/client/releases/tag/v2.2.2) - 2025-10-14
410

511
- Enforced use of UTC for all datetime recording.

CITATION.cff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ keywords:
4242
- alerting
4343
- simulation
4444
license: Apache-2.0
45-
commit: 54974cdb71ca4f9ee36541054ef12b853ed99eba
46-
version: 2.2.2
47-
date-released: '2025-10-14'
45+
commit: 4edec13b494f4b6b034d42ad90f33f98a2058b40
46+
version: 2.2.3
47+
date-released: '2025-11-10'

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "simvue"
3-
version = "2.2.2"
3+
version = "2.2.3"
44
description = "Simulation tracking and monitoring"
55
authors = [
66
{name = "Simvue Development Team", email = "info@simvue.io"}

simvue/api/objects/alert/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def __init__(self, identifier: str | None = None, **kwargs) -> None:
3131
"""Retrieve an alert from the Simvue server by identifier"""
3232
self._label = "alert"
3333
super().__init__(identifier=identifier, **kwargs)
34+
self._local_only_args = ["frequency", "pattern", "aggregation"]
3435

3536
def compare(self, other: "AlertBase") -> bool:
3637
"""Compare this alert to another"""

simvue/api/objects/alert/metrics.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ def __init__(self, identifier: str | None = None, **kwargs) -> None:
3030
"""Connect to a local or remote threshold alert by identifier"""
3131
self.alert = MetricThresholdAlertDefinition(self)
3232
super().__init__(identifier, **kwargs)
33+
self._local_only_args += [
34+
"rule",
35+
"window",
36+
"metric",
37+
"threshold",
38+
]
3339

3440
@classmethod
3541
def get(
@@ -117,6 +123,13 @@ def __init__(self, identifier: str | None = None, **kwargs) -> None:
117123
"""Connect to a local or remote threshold alert by identifier"""
118124
self.alert = MetricRangeAlertDefinition(self)
119125
super().__init__(identifier, **kwargs)
126+
self._local_only_args += [
127+
"rule",
128+
"window",
129+
"metric",
130+
"range_low",
131+
"range_high",
132+
]
120133

121134
def compare(self, other: "MetricsRangeAlert") -> bool:
122135
"""Compare two MetricRangeAlerts"""

simvue/api/objects/artifact/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(
5454
self._label = "artifact"
5555
self._endpoint = f"{self._label}s"
5656
super().__init__(identifier=identifier, _read_only=_read_only, **kwargs)
57+
self._local_only_args += ["storage", "file_path", "runs"]
5758

5859
# If the artifact is an online instance, need a place to store the response
5960
# from the initial creation

simvue/api/objects/artifact/file.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ def new(
8080
else:
8181
file_path = pathlib.Path(file_path)
8282
if snapshot:
83-
_user_config = SimvueConfiguration.fetch()
83+
_user_config = SimvueConfiguration.fetch(
84+
mode="offline" if offline else "online"
85+
)
8486

8587
_local_staging_dir: pathlib.Path = _user_config.offline.cache.joinpath(
8688
"artifacts"

simvue/api/objects/base.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333
)
3434
from simvue.api.url import URL
3535

36-
logging.basicConfig(level=logging.INFO)
37-
3836
try:
3937
from typing import Self
4038
except ImportError:
@@ -199,6 +197,12 @@ def __init__(
199197
self._read_only: bool = _read_only
200198
self._is_set: bool = False
201199
self._endpoint: str = getattr(self, "_endpoint", f"{self._label}s")
200+
201+
# For simvue object initialisation, unlike the server there is no nested
202+
# arguments, however this means that there are extra keys during post which
203+
# need removing, this attribute handles that and should be set in subclasses.
204+
self._local_only_args: list[str] = []
205+
202206
self._identifier: str | None = (
203207
identifier if identifier is not None else f"offline_{uuid.uuid1()}"
204208
)
@@ -635,6 +639,10 @@ def _post_single(
635639
if not is_json:
636640
kwargs = msgpack.packb(data or kwargs, use_bin_type=True)
637641

642+
# Remove any extra keys
643+
for key in self._local_only_args:
644+
_ = (data or kwargs).pop(key, None)
645+
638646
_response = sv_post(
639647
url=f"{self._base_url}",
640648
headers=self._headers | {"Content-Type": "application/msgpack"},
@@ -672,6 +680,11 @@ def _post_single(
672680
def _put(self, **kwargs) -> dict[str, typing.Any]:
673681
if not self.url:
674682
raise RuntimeError(f"Identifier for instance of {self._label} Unknown")
683+
684+
# Remove any extra keys
685+
for key in self._local_only_args:
686+
_ = kwargs.pop(key, None)
687+
675688
_response = sv_put(
676689
url=f"{self.url}", headers=self._headers, data=kwargs, is_json=True
677690
)

simvue/api/objects/grids.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99

1010
import http
11+
import msgpack
1112
import numpy
1213
import typing
1314

@@ -373,8 +374,9 @@ def _log_values(self, metrics: list[GridMetricSet]) -> None:
373374

374375
_response = sv_post(
375376
url=f"{self._user_config.server.url}/{self.run_grids_endpoint(self._run_id)}",
376-
headers=self._headers,
377-
data=metrics,
377+
headers=self._headers | {"Content-Type": "application/msgpack"},
378+
data=msgpack.packb(metrics, use_bin_type=True),
379+
is_json=False,
378380
params={},
379381
)
380382

0 commit comments

Comments
 (0)