From b6912af8f8a1a82fe4671ffe337538a77e024904 Mon Sep 17 00:00:00 2001 From: Matt Field Date: Tue, 23 Sep 2025 15:48:30 +0100 Subject: [PATCH 1/2] Fix metric name regex --- simvue/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simvue/models.py b/simvue/models.py index 3cb74518..d061b906 100644 --- a/simvue/models.py +++ b/simvue/models.py @@ -5,8 +5,8 @@ FOLDER_REGEX: str = r"^/.*" -NAME_REGEX: str = r"^[a-zA-Z0-9\-\_\s\/\.:]+$" -METRIC_KEY_REGEX: str = r"^[a-zA-Z0-9\-\_\s\/\.:=><]+$" +NAME_REGEX: str = r"^[a-zA-Z0-9\-\_\s\/\.:=><]+$" +METRIC_KEY_REGEX: str = r"^[a-zA-Z0-9\-\_\s\/\.:=><+\(\)]+$" DATETIME_FORMAT: str = "%Y-%m-%dT%H:%M:%S.%f" MetadataKeyString = typing.Annotated[ From 6620f0403c0e1b2df8e2fb2be43d7336162f4953 Mon Sep 17 00:00:00 2001 From: Matt Field Date: Tue, 23 Sep 2025 16:00:59 +0100 Subject: [PATCH 2/2] Update tests to catch wrong name validation --- tests/functional/test_run_class.py | 4 ++-- tests/unit/test_metrics.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/functional/test_run_class.py b/tests/functional/test_run_class.py index fc01e285..dd82846a 100644 --- a/tests/functional/test_run_class.py +++ b/tests/functional/test_run_class.py @@ -167,7 +167,7 @@ def test_log_metrics_online( visibility: typing.Literal["public", "tenant"] | list[str] | None, metric_type: typing.Literal["regular", "tensor"], ) -> None: - METRICS = {"a": 10, "b": 1.2} + METRICS = {"a": 10, "aB0-_/.:=><+()": 1.2} # Have to create the run outside of fixtures because the resources dispatch # occurs immediately and is not captured by the handler when using the fixture @@ -313,7 +313,7 @@ def test_log_metrics_offline( axes_labels=["x", "y"] ) else: - METRICS = {"a": 10, "b": 1.2, "c": 2} + METRICS = {"a": 10, "aB0-_/.:=><+()": 1.2, "c": 2} run.log_metrics(METRICS) diff --git a/tests/unit/test_metrics.py b/tests/unit/test_metrics.py index fc1b70fd..4d2823a7 100644 --- a/tests/unit/test_metrics.py +++ b/tests/unit/test_metrics.py @@ -19,7 +19,7 @@ def test_metrics_creation_online() -> None: _values = { "x": 1, "y": 2.0, - "z": True + "aB0-_/.:=><+()": True } _time: int = 1 _step: int = 1 @@ -40,7 +40,7 @@ def test_metrics_creation_online() -> None: ) assert _metrics.to_dict() _metrics.commit() - _data = next(_metrics.get(metrics=["x", "y", "z"], runs=[_run.id], xaxis="step")) + _data = next(_metrics.get(metrics=["x", "y", "aB0-_/.:=><+()"], runs=[_run.id], xaxis="step")) assert sorted(_metrics.names(run_ids=[_run.id])) == sorted(_values.keys()) assert _data.get(_run.id).get('y')[0].get('value') == 2.0 assert _data.get(_run.id).get('y')[0].get('step') == 1 @@ -61,7 +61,7 @@ def test_metrics_creation_offline(offline_cache_setup) -> None: _values = { "x": 1, "y": 2.0, - "z": True + "aB0-_/.:=><+()": True } _time: int = 1 _step: int = 1 @@ -93,7 +93,7 @@ def test_metrics_creation_offline(offline_cache_setup) -> None: # Get online version of metrics _online_metrics = Metrics(_id_mapping.get(_metrics.id)) - _data = next(_online_metrics.get(metrics=["x", "y", "z"], runs=[_id_mapping.get(_run.id)], xaxis="step")) + _data = next(_online_metrics.get(metrics=["x", "y", "aB0-_/.:=><+()"], runs=[_id_mapping.get(_run.id)], xaxis="step")) assert sorted(_online_metrics.names(run_ids=[_id_mapping.get(_run.id)])) == sorted(_values.keys()) assert _data.get(_id_mapping.get(_run.id)).get('y')[0].get('value') == 2.0 assert _data.get(_id_mapping.get(_run.id)).get('y')[0].get('step') == 1