expr_tracker 0.3.0__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- expr_tracker/cli.py +17 -2
- expr_tracker/run.py +20 -22
- {expr_tracker-0.3.0.dist-info → expr_tracker-0.3.2.dist-info}/METADATA +2 -1
- {expr_tracker-0.3.0.dist-info → expr_tracker-0.3.2.dist-info}/RECORD +7 -7
- {expr_tracker-0.3.0.dist-info → expr_tracker-0.3.2.dist-info}/WHEEL +0 -0
- {expr_tracker-0.3.0.dist-info → expr_tracker-0.3.2.dist-info}/entry_points.txt +0 -0
- {expr_tracker-0.3.0.dist-info → expr_tracker-0.3.2.dist-info}/licenses/LICENSE +0 -0
expr_tracker/cli.py
CHANGED
|
@@ -4,8 +4,10 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
6
|
import time
|
|
7
|
+
from pathlib import Path
|
|
7
8
|
|
|
8
9
|
import click
|
|
10
|
+
from dotenv import load_dotenv
|
|
9
11
|
|
|
10
12
|
from .alerts import alert as send_alert
|
|
11
13
|
from .alerts.dispatch import Dispatcher
|
|
@@ -26,8 +28,21 @@ def main():
|
|
|
26
28
|
@click.option("--title", default="Alert", help="Title of the alert")
|
|
27
29
|
@click.option("--level", default="info", help="info | warning | error | critical")
|
|
28
30
|
@click.option("--channel", "channels", multiple=True, help="Restrict to these channels")
|
|
29
|
-
|
|
30
|
-
"""
|
|
31
|
+
@click.option(
|
|
32
|
+
"--no-dotenv", is_flag=True, help="Skip loading .env from the current directory"
|
|
33
|
+
)
|
|
34
|
+
def alert(
|
|
35
|
+
msg: str, title: str, level: str, channels: tuple[str, ...], no_dotenv: bool
|
|
36
|
+
):
|
|
37
|
+
"""Send a manual alert, loading the current directory's .env by default."""
|
|
38
|
+
if not no_dotenv:
|
|
39
|
+
try:
|
|
40
|
+
with Path(".env").open(encoding="utf-8") as stream:
|
|
41
|
+
load_dotenv(stream=stream, override=False)
|
|
42
|
+
except FileNotFoundError:
|
|
43
|
+
pass
|
|
44
|
+
except (OSError, UnicodeError) as exc:
|
|
45
|
+
raise click.ClickException(f"Could not read .env: {exc}") from exc
|
|
31
46
|
send_alert(title=title, text=msg, level=level, channels=list(channels) or None)
|
|
32
47
|
|
|
33
48
|
|
expr_tracker/run.py
CHANGED
|
@@ -15,7 +15,7 @@ from typing import Any, Literal
|
|
|
15
15
|
from loguru import logger
|
|
16
16
|
|
|
17
17
|
from .artifacts import Artifact, ArtifactStore, coerce_artifact
|
|
18
|
-
from .history import HistoryStore, current_rank
|
|
18
|
+
from .history import HistoryStore, current_rank
|
|
19
19
|
from .history.naming import resolve_artifact_root, sidecar_filename
|
|
20
20
|
from .summary import Summary
|
|
21
21
|
|
|
@@ -245,34 +245,32 @@ class Run:
|
|
|
245
245
|
# ------------------------------------------------------------------ logging
|
|
246
246
|
|
|
247
247
|
def _on_commit(self, record: dict):
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
All sinks share one timeline: if local history rejects the call (closed run,
|
|
255
|
-
or a backward step), the summary and remote backends are skipped too.
|
|
256
|
-
"""
|
|
257
|
-
resolved_step = self.history.log(data, step=step, commit=commit)
|
|
258
|
-
if resolved_step is None:
|
|
259
|
-
return
|
|
248
|
+
metrics = {
|
|
249
|
+
key: value
|
|
250
|
+
for key, value in record.items()
|
|
251
|
+
if isinstance(key, str) and not key.startswith("_")
|
|
252
|
+
}
|
|
253
|
+
step = record["_step"]
|
|
260
254
|
try:
|
|
261
|
-
self.summary.observe(
|
|
255
|
+
self.summary.observe(metrics)
|
|
262
256
|
except Exception as e: # a sink must never break the training loop
|
|
263
257
|
logger.warning(f"Failed to update summary: {e}")
|
|
264
258
|
for name, backend in self.backends.items():
|
|
265
|
-
|
|
266
|
-
# matches the local history instead of drifting on its own counter.
|
|
267
|
-
extra = (
|
|
268
|
-
{"commit": resolve_commit(step, commit)}
|
|
269
|
-
if self._takes_commit.get(name)
|
|
270
|
-
else {}
|
|
271
|
-
)
|
|
259
|
+
extra = {"commit": True} if self._takes_commit.get(name) else {}
|
|
272
260
|
try:
|
|
273
|
-
backend.log(
|
|
261
|
+
backend.log(metrics, step=step, **extra)
|
|
274
262
|
except Exception as e:
|
|
275
263
|
logger.warning(f"Failed to log metrics to {name}: {e}")
|
|
264
|
+
if self.alerts is not None:
|
|
265
|
+
self.alerts.on_step(record)
|
|
266
|
+
|
|
267
|
+
def log(self, data: dict, step: int | None = None, commit: bool | None = None):
|
|
268
|
+
"""Log metrics, mirroring ``wandb.log(data, step=..., commit=...)``.
|
|
269
|
+
|
|
270
|
+
Local history owns row assembly. Summary, alerts and remote backends receive
|
|
271
|
+
the same complete row only after it commits, including span/plugin metrics.
|
|
272
|
+
"""
|
|
273
|
+
self.history.log(data, step=step, commit=commit)
|
|
276
274
|
|
|
277
275
|
def history_query(self, *args, **kwargs):
|
|
278
276
|
return self.history.get(*args, **kwargs)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: expr_tracker
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: Local-first experiment tracking with queryable history and expression-based alerts on your training metrics
|
|
5
5
|
Project-URL: Homepage, https://hspk.github.io/expr_tracker/
|
|
6
6
|
Project-URL: Documentation, https://hspk.github.io/expr_tracker/
|
|
@@ -27,6 +27,7 @@ Requires-Python: >=3.10
|
|
|
27
27
|
Requires-Dist: click>=8.1.0
|
|
28
28
|
Requires-Dist: loguru>=0.7.3
|
|
29
29
|
Requires-Dist: pydantic>=2.0
|
|
30
|
+
Requires-Dist: python-dotenv>=1.0
|
|
30
31
|
Provides-Extra: all
|
|
31
32
|
Requires-Dist: nvidia-ml-py>=12.0; extra == 'all'
|
|
32
33
|
Requires-Dist: pandas>=1.5; extra == 'all'
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
expr_tracker/__init__.py,sha256=AdY6R3bKLlZFhNtJPBAA3UHhO9nZ7YpojLrkW9OevlM,1442
|
|
2
2
|
expr_tracker/_compat.py,sha256=qf8oYIK_lkoLzcPp6wPCYLJtVatCl7ROYRNPwc5F1Pg,981
|
|
3
3
|
expr_tracker/artifacts.py,sha256=yRVXmuqdZUxiZa0c_CwZi4rBxaItwhu9bZ1x21yP1S0,12560
|
|
4
|
-
expr_tracker/cli.py,sha256=
|
|
4
|
+
expr_tracker/cli.py,sha256=xR-5ME_uAEBMflFHdLwIfd1yZax_BLFJaLG-UypGdYQ,8048
|
|
5
5
|
expr_tracker/encoders.py,sha256=X5ySQasSrYPsdYCdk7nhpJFGFB9f_8HWQuGOQjTvh9E,11991
|
|
6
6
|
expr_tracker/plugins.py,sha256=-ako71QBr5ARYS3aFUueHx3SMESk5ii2wj_yiz2_Mzc,9592
|
|
7
7
|
expr_tracker/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
expr_tracker/run.py,sha256=
|
|
8
|
+
expr_tracker/run.py,sha256=nFiKkY8zhSdR5k-IeV2CUCo6tTtJ4blecbxYxUYL7U4,17292
|
|
9
9
|
expr_tracker/spans.py,sha256=w5711ozspUocEJJAbQynLjyBSfBICO6SwEGPg6C2-H8,13051
|
|
10
10
|
expr_tracker/summary.py,sha256=lpHSh3pci2Ym6wJhVZwNUJbUp2A64EN_rC7Ym2d7PPI,3150
|
|
11
11
|
expr_tracker/trace.py,sha256=stOIuEzuFLHZrrqbaTWndOOnhSXEJzHF91zPGDpU5PA,7019
|
|
@@ -33,8 +33,8 @@ expr_tracker/history/reader.py,sha256=5PY5nbNfX-Cl34jcyYTq2qm8nNgNDTqv7U5Xnb9Rgx
|
|
|
33
33
|
expr_tracker/history/series.py,sha256=cFdUO1FRs5KW0jYsNPzda3tcu645NH1wwfXJitQfXFM,4042
|
|
34
34
|
expr_tracker/history/store.py,sha256=D6dSJj0W7Y6ozmHYqXRtYbKCIjnuw-7kLSPtZ4xla-0,36594
|
|
35
35
|
expr_tracker/history/writer.py,sha256=q5kNANcZCq5nykvOK5jZ2xc6Z1B4oZxEn3uSXzDCtlY,16096
|
|
36
|
-
expr_tracker-0.3.
|
|
37
|
-
expr_tracker-0.3.
|
|
38
|
-
expr_tracker-0.3.
|
|
39
|
-
expr_tracker-0.3.
|
|
40
|
-
expr_tracker-0.3.
|
|
36
|
+
expr_tracker-0.3.2.dist-info/METADATA,sha256=zA4Wwzc9sRJo_pKSpImNvfQwNRNK02NqHKgZmyihZlo,10818
|
|
37
|
+
expr_tracker-0.3.2.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
38
|
+
expr_tracker-0.3.2.dist-info/entry_points.txt,sha256=GfZCAG2JFsd5CxTjRsGJAhYInpBCuLjrU3csmUVBDSs,45
|
|
39
|
+
expr_tracker-0.3.2.dist-info/licenses/LICENSE,sha256=ORsYTnF-2SLUaM8FgXlJ-uXuN4ceGACAAU3JZiS8pvs,1069
|
|
40
|
+
expr_tracker-0.3.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|