Skip to content

Commit 598c9fb

Browse files
committed
Updated metric and event retrieval
1 parent c6b1f94 commit 598c9fb

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

simvue/api/objects/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,15 @@ def ids(
311311
_class_instance = cls(_read_only=True, _local=True)
312312
_count: int = 0
313313
for response in cls._get_all_objects(offset):
314-
if count and _count > count:
315-
return
316314
if (_data := response.get("data")) is None:
317315
raise RuntimeError(
318316
f"Expected key 'data' for retrieval of {_class_instance.__class__.__name__.lower()}s"
319317
)
320318
for entry in _data:
321319
yield entry["id"]
322320
_count += 1
321+
if count and _count > count:
322+
return
323323

324324
@classmethod
325325
@pydantic.validate_call

simvue/api/objects/events.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,19 @@ def get(
4444
**kwargs,
4545
) -> typing.Generator[EventSet, None, None]:
4646
_class_instance = cls(_read_only=True, _local=True)
47-
if (
48-
_data := cls._get_all_objects(count, offset, run=run_id, **kwargs).get(
49-
"data"
50-
)
51-
) is None:
52-
raise RuntimeError(
53-
f"Expected key 'data' for retrieval of {_class_instance.__class__.__name__.lower()}s"
54-
)
55-
56-
for _entry in _data:
57-
yield EventSet(**_entry)
47+
_count: int = 0
48+
49+
for response in cls._get_all_objects(offset, run=run_id, **kwargs):
50+
if (_data := response.get("data")) is None:
51+
raise RuntimeError(
52+
f"Expected key 'data' for retrieval of {_class_instance.__class__.__name__.lower()}s"
53+
)
54+
55+
for _entry in _data:
56+
yield EventSet(**_entry)
57+
_count += 1
58+
if _count > count:
59+
return
5860

5961
@classmethod
6062
@pydantic.validate_call

simvue/api/objects/metrics.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,17 @@ def get(
5656
count: pydantic.PositiveInt | None = None,
5757
offset: pydantic.PositiveInt | None = None,
5858
**kwargs,
59-
) -> typing.Generator[MetricSet, None, None]:
59+
) -> typing.Generator[dict[str, dict[str, list[dict[str, float]]]], None, None]:
60+
"""Yields the values for the given metrics for each run."""
6061
_class_instance = cls(_read_only=True, _local=True)
61-
_data = cls._get_all_objects(
62-
count,
62+
yield from cls._get_all_objects(
6363
offset,
6464
metrics=json.dumps(metrics),
6565
runs=json.dumps(runs),
6666
xaxis=xaxis,
67+
count=count,
6768
**kwargs,
6869
)
69-
# TODO: Temp fix, just return the dictionary. Not sure what format we really want this in...
70-
return _data
7170

7271
@pydantic.validate_call
7372
def span(self, run_ids: list[str]) -> dict[str, int | float]:

simvue/api/request.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,3 +320,5 @@ def get_paginated(
320320
):
321321
yield _response
322322
_offset += MAX_ENTRIES_PER_PAGE
323+
324+
yield _response

0 commit comments

Comments
 (0)