Skip to content

Commit d66846d

Browse files
committed
Fixes for typing and docs
1 parent 89e0759 commit d66846d

2 files changed

Lines changed: 35 additions & 16 deletions

File tree

simvue/client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def get_runs(
197197
start_index: pydantic.NonNegativeInt = 0,
198198
show_shared: bool = True,
199199
sort_by_columns: list[tuple[str, bool]] | None = None,
200-
) -> DataFrame | Generator[tuple[str, Run]] | None:
200+
) -> DataFrame | Generator[tuple[str, Run]] | dict[str, object] | None:
201201
"""Retrieve all runs matching filters.
202202
203203
Parameters
@@ -226,8 +226,9 @@ def get_runs(
226226
output_format : Literal['dict', objects', 'dataframe'], optional
227227
the structure of the response
228228
* dict - dictionary of values.
229-
* objects - a dictionary of objects (default).
229+
* objects - a generator of (ID, object) pairs (default).
230230
* dataframe - a dataframe (Pandas must be installed).
231+
use of the generator is recommended.
231232
count_limit : int, optional
232233
maximum number of entries to return. Default is 100.
233234
start_index : int, optional
@@ -392,6 +393,7 @@ def delete_runs(
392393
def delete_folder(
393394
self,
394395
folder_path: typing.Annotated[str, pydantic.Field(pattern=FOLDER_REGEX)],
396+
*,
395397
recursive: bool = False,
396398
remove_runs: bool = False,
397399
allow_missing: bool = False,
@@ -628,7 +630,8 @@ def get_artifacts_as_files(
628630
if there was a failure retrieving artifacts from the server
629631
"""
630632
_artifacts: Generator[tuple[str, Artifact]] = Artifact.from_run(
631-
run_id=run_id, category=category
633+
run_id=run_id,
634+
category=category,
632635
)
633636

634637
with ThreadPoolExecutor(

simvue/handler.py

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,44 @@
1+
"""Simvue logging handler."""
2+
13
import logging
4+
import typing
5+
6+
if typing.TYPE_CHECKING:
7+
from simvue import Run
8+
9+
try:
10+
from typing import override
11+
except ImportError:
12+
from typing_extensions import override
213

314

415
class Handler(logging.Handler):
5-
"""
6-
Class for handling logging to Simvue
7-
"""
16+
"""Class for handling logging as events to a Simvue server."""
817

9-
def __init__(self, client):
18+
def __init__(self, simvue_run: "Run") -> None:
19+
"""Initialise a new Simvue logging handler.
20+
21+
Parameters
22+
----------
23+
simvue_run: simvue.Run
24+
run to attach this handler to
25+
"""
1026
logging.Handler.__init__(self)
11-
self._client = client
27+
self._run_object: Run = simvue_run
1228

13-
def emit(self, record):
29+
@override
30+
def emit(self, record: logging.LogRecord) -> None:
31+
"""Perform the logging action of sending to server."""
1432
if "simvue." in record.name:
1533
return
1634

17-
msg = self.format(record)
35+
_msg: str = self.format(record)
1836

1937
try:
20-
self._client.log_event(msg)
38+
self._run_object.log_event(_msg)
2139
except Exception:
2240
logging.Handler.handleError(self, record)
2341

24-
def flush(self):
25-
pass
26-
27-
def close(self):
28-
pass
42+
@override
43+
def close(self) -> None:
44+
"""Execute nothing on closure."""

0 commit comments

Comments
 (0)