Skip to content

Commit 20b71c4

Browse files
committed
🐛 Address MR issues
2 parents 647e409 + 9c6e588 commit 20b71c4

17 files changed

Lines changed: 1648 additions & 486 deletions

.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.12.12
26+
rev: v0.13.0
2727
hooks:
2828
- id: ruff
2929
args: [ --fix, --exit-non-zero-on-fix, "--ignore=C901" ]

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Improves handling of Conda based environments in metadata collection.
66
- Adds additional options to `Client.get_runs`.
77
- Added ability to include environment variables within metadata for runs.
8+
- Added new feature allowing users to log tensors as multidimensional metrics after defining a grid.
89
- Improves checks on `offline.cache` directory specification in config file.
910
- Added ability to upload multiple runs as a batch via the low level API.
1011

poetry.lock

Lines changed: 567 additions & 385 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

simvue/api/objects/__init__.py

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,54 @@
88
99
"""
1010

11-
from .administrator import Tenant as Tenant, User as User
11+
from .administrator import Tenant, User
1212
from .alert import (
13-
Alert as Alert,
14-
EventsAlert as EventsAlert,
15-
MetricsThresholdAlert as MetricsThresholdAlert,
16-
MetricsRangeAlert as MetricsRangeAlert,
17-
UserAlert as UserAlert,
13+
Alert,
14+
EventsAlert,
15+
MetricsThresholdAlert,
16+
MetricsRangeAlert,
17+
UserAlert,
1818
)
1919
from .storage import (
20-
S3Storage as S3Storage,
21-
FileStorage as FileStorage,
22-
Storage as Storage,
20+
S3Storage,
21+
FileStorage,
22+
Storage,
2323
)
2424
from .artifact import (
25-
FileArtifact as FileArtifact,
26-
ObjectArtifact as ObjectArtifact,
27-
Artifact as Artifact,
25+
FileArtifact,
26+
ObjectArtifact,
27+
Artifact,
2828
)
2929

30-
from .stats import Stats as Stats
31-
from .run import Run as Run
32-
from .tag import Tag as Tag
33-
from .folder import Folder as Folder, get_folder_from_path as get_folder_from_path
30+
from .stats import Stats
31+
from .run import Run
32+
from .tag import Tag
33+
from .folder import Folder, get_folder_from_path
3434
from .events import Events as Events
3535
from .metrics import Metrics as Metrics
36+
from .grids import Grid, GridMetrics
37+
38+
__all__ = [
39+
"Grid",
40+
"GridMetrics",
41+
"Metrics",
42+
"Events",
43+
"get_folder_from_path",
44+
"Folder",
45+
"Stats",
46+
"Run",
47+
"Tag",
48+
"Artifact",
49+
"FileArtifact",
50+
"ObjectArtifact",
51+
"S3Storage",
52+
"FileStorage",
53+
"Storage",
54+
"MetricsRangeAlert",
55+
"MetricsThresholdAlert",
56+
"UserAlert",
57+
"EventsAlert",
58+
"Alert",
59+
"Tenant",
60+
"User",
61+
]

simvue/api/objects/base.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,22 @@ def count(cls, **kwargs) -> int:
480480

481481
@classmethod
482482
def _get_all_objects(
483-
cls, offset: int | None, count: int | None, **kwargs
483+
cls,
484+
offset: int | None,
485+
count: int | None,
486+
endpoint: str | None = None,
487+
expected_type: type = dict,
488+
**kwargs,
484489
) -> Generator[dict, None, None]:
485490
_class_instance = cls(_read_only=True)
486-
_url = f"{_class_instance._base_url}"
491+
492+
# Allow the possibility of paginating a URL that is not the
493+
# main class endpoint
494+
_url = (
495+
f"{_class_instance._user_config.server.url}/{endpoint}"
496+
if endpoint
497+
else f"{_class_instance._base_url}"
498+
)
487499

488500
_label = _class_instance.__class__.__name__.lower()
489501
if _label.endswith("s"):
@@ -492,12 +504,18 @@ def _get_all_objects(
492504
for response in get_paginated(
493505
_url, headers=_class_instance._headers, offset=offset, count=count, **kwargs
494506
):
495-
yield get_json_from_response(
507+
_generator = get_json_from_response(
496508
response=response,
497509
expected_status=[http.HTTPStatus.OK],
498510
scenario=f"Retrieval of {_label}s",
511+
expected_type=expected_type,
499512
) # type: ignore
500513

514+
if expected_type is dict:
515+
yield _generator
516+
else:
517+
yield from _generator
518+
501519
def read_only(self, is_read_only: bool) -> None:
502520
"""Set whether this object is in read only state.
503521
@@ -535,7 +553,7 @@ def commit(self) -> dict | list[dict] | None:
535553
# If batch upload send as list, else send as dictionary of params
536554
if _batch_commit := self._staging.get("batch"):
537555
self._logger.debug(
538-
f"Posting batched data to server: \n{json.dumps(_batch_commit, indent=2)}"
556+
f"Posting batched data to server: {len(_batch_commit)} {self._label}s"
539557
)
540558
_response = self._post_batch(batch_data=_batch_commit)
541559
else:
@@ -612,19 +630,16 @@ def _post_batch(
612630
return _json_response
613631

614632
def _post_single(
615-
self,
616-
*,
617-
is_json: bool = True,
618-
**kwargs,
633+
self, *, is_json: bool = True, data: list | dict | None = None, **kwargs
619634
) -> dict[str, typing.Any] | list[dict[str, typing.Any]]:
620635
if not is_json:
621-
kwargs = msgpack.packb(kwargs, use_bin_type=True)
636+
kwargs = msgpack.packb(data or kwargs, use_bin_type=True)
622637

623638
_response = sv_post(
624639
url=f"{self._base_url}",
625640
headers=self._headers | {"Content-Type": "application/msgpack"},
626641
params=self._params,
627-
data=kwargs,
642+
data=data or kwargs,
628643
is_json=is_json,
629644
)
630645

simvue/api/objects/events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def new(
7878
**kwargs,
7979
)
8080

81-
def _post(self, **kwargs) -> dict[str, typing.Any]:
82-
return super()._post(is_json=False, **kwargs)
81+
def _post_single(self, **kwargs) -> dict[str, typing.Any]:
82+
return super()._post_single(is_json=False, **kwargs)
8383

8484
def _put(self, **kwargs) -> dict[str, typing.Any]:
8585
raise NotImplementedError("Method 'put' is not available for type Events")

0 commit comments

Comments
 (0)