mllogs 0.1.4__tar.gz → 0.2.0__tar.gz
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.
- {mllogs-0.1.4 → mllogs-0.2.0}/PKG-INFO +12 -3
- {mllogs-0.1.4 → mllogs-0.2.0}/README.md +11 -2
- {mllogs-0.1.4 → mllogs-0.2.0}/pyproject.toml +1 -1
- {mllogs-0.1.4 → mllogs-0.2.0}/src/mllogs/client.py +31 -8
- {mllogs-0.1.4 → mllogs-0.2.0}/src/mllogs/storage.py +15 -1
- {mllogs-0.1.4 → mllogs-0.2.0}/src/mllogs.egg-info/PKG-INFO +12 -3
- {mllogs-0.1.4 → mllogs-0.2.0}/tests/test_client.py +21 -3
- {mllogs-0.1.4 → mllogs-0.2.0}/tests/test_storage.py +24 -1
- {mllogs-0.1.4 → mllogs-0.2.0}/LICENSE +0 -0
- {mllogs-0.1.4 → mllogs-0.2.0}/setup.cfg +0 -0
- {mllogs-0.1.4 → mllogs-0.2.0}/src/mllogs/__init__.py +0 -0
- {mllogs-0.1.4 → mllogs-0.2.0}/src/mllogs/run.py +0 -0
- {mllogs-0.1.4 → mllogs-0.2.0}/src/mllogs.egg-info/SOURCES.txt +0 -0
- {mllogs-0.1.4 → mllogs-0.2.0}/src/mllogs.egg-info/dependency_links.txt +0 -0
- {mllogs-0.1.4 → mllogs-0.2.0}/src/mllogs.egg-info/requires.txt +0 -0
- {mllogs-0.1.4 → mllogs-0.2.0}/src/mllogs.egg-info/top_level.txt +0 -0
- {mllogs-0.1.4 → mllogs-0.2.0}/tests/test_run.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mllogs
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Local experiment logging for machine learning
|
|
5
5
|
Author: Finn Walsh
|
|
6
6
|
License-Expression: MIT
|
|
@@ -37,14 +37,23 @@ client.log_param("learning_rate", 0.01)
|
|
|
37
37
|
client.log_metric("accuracy", 0.92)
|
|
38
38
|
client.set_tag("model", "logistic_regression")
|
|
39
39
|
|
|
40
|
-
client.end_run()
|
|
40
|
+
run = client.end_run()
|
|
41
|
+
|
|
42
|
+
client.list_runs()
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Retrieve or delete a saved run:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
client.get_run(id)
|
|
49
|
+
client.delete_run(id)
|
|
41
50
|
```
|
|
42
51
|
|
|
43
52
|
## Features
|
|
44
53
|
|
|
45
54
|
- Start and end experiment runs
|
|
46
55
|
- Log parameters, metrics, and tags
|
|
47
|
-
-
|
|
56
|
+
- Automatically persist completed runs to local storage
|
|
48
57
|
- Load, list, and delete saved runs
|
|
49
58
|
|
|
50
59
|
## Development
|
|
@@ -24,14 +24,23 @@ client.log_param("learning_rate", 0.01)
|
|
|
24
24
|
client.log_metric("accuracy", 0.92)
|
|
25
25
|
client.set_tag("model", "logistic_regression")
|
|
26
26
|
|
|
27
|
-
client.end_run()
|
|
27
|
+
run = client.end_run()
|
|
28
|
+
|
|
29
|
+
client.list_runs()
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Retrieve or delete a saved run:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
client.get_run(id)
|
|
36
|
+
client.delete_run(id)
|
|
28
37
|
```
|
|
29
38
|
|
|
30
39
|
## Features
|
|
31
40
|
|
|
32
41
|
- Start and end experiment runs
|
|
33
42
|
- Log parameters, metrics, and tags
|
|
34
|
-
-
|
|
43
|
+
- Automatically persist completed runs to local storage
|
|
35
44
|
- Load, list, and delete saved runs
|
|
36
45
|
|
|
37
46
|
## Development
|
|
@@ -11,6 +11,14 @@ class MLLogsClient:
|
|
|
11
11
|
self._active_run: Run | None = None
|
|
12
12
|
self._file_store = file_store if file_store is not None else LocalFileStore()
|
|
13
13
|
|
|
14
|
+
|
|
15
|
+
def _require_active_run(self) -> Run:
|
|
16
|
+
if self._active_run is None:
|
|
17
|
+
raise RuntimeError("No active run.")
|
|
18
|
+
|
|
19
|
+
return self._active_run
|
|
20
|
+
|
|
21
|
+
|
|
14
22
|
def start_run(
|
|
15
23
|
self,
|
|
16
24
|
name: str | None = None,
|
|
@@ -23,6 +31,9 @@ class MLLogsClient:
|
|
|
23
31
|
name: Optional name for the run.
|
|
24
32
|
run_type: Optional type used to categorize the run.
|
|
25
33
|
"""
|
|
34
|
+
if self._active_run is not None:
|
|
35
|
+
raise RuntimeError("Active run already exists.")
|
|
36
|
+
|
|
26
37
|
# generate run id
|
|
27
38
|
started_at = datetime.now(UTC)
|
|
28
39
|
timestamp = started_at.strftime("%Y%m%d%H%M%S")
|
|
@@ -40,15 +51,18 @@ class MLLogsClient:
|
|
|
40
51
|
|
|
41
52
|
|
|
42
53
|
def log_param(self, key: str, value: Any) -> None:
|
|
43
|
-
|
|
54
|
+
run = self._require_active_run()
|
|
55
|
+
run.params[key] = value
|
|
44
56
|
|
|
45
57
|
|
|
46
58
|
def log_metric(self, key: str, value: float) -> None:
|
|
47
|
-
|
|
59
|
+
run = self._require_active_run()
|
|
60
|
+
run.metrics[key] = value
|
|
48
61
|
|
|
49
62
|
|
|
50
63
|
def set_tag(self, key: str, value: str) -> None:
|
|
51
|
-
|
|
64
|
+
run = self._require_active_run()
|
|
65
|
+
run.tags[key] = value
|
|
52
66
|
|
|
53
67
|
|
|
54
68
|
def end_run(self) -> Run:
|
|
@@ -58,10 +72,7 @@ class MLLogsClient:
|
|
|
58
72
|
Returns:
|
|
59
73
|
- Active run
|
|
60
74
|
"""
|
|
61
|
-
|
|
62
|
-
raise RuntimeError("No active run.")
|
|
63
|
-
|
|
64
|
-
run = self._active_run
|
|
75
|
+
run = self._require_active_run()
|
|
65
76
|
|
|
66
77
|
run.ended_at = datetime.now(UTC)
|
|
67
78
|
run.status = RunStatus.COMPLETE
|
|
@@ -71,4 +82,16 @@ class MLLogsClient:
|
|
|
71
82
|
# clear run
|
|
72
83
|
self._active_run = None
|
|
73
84
|
|
|
74
|
-
return run
|
|
85
|
+
return run
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def get_run(self, run_id: str | None = None) -> Run | None:
|
|
89
|
+
return self._file_store.load_run(run_id=run_id)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def list_runs(self, limit: int | None = None) -> list[Run]:
|
|
93
|
+
return self._file_store.list_runs(limit=limit)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def delete_run(self, run_id: str) -> None:
|
|
97
|
+
self._file_store.delete_run(run_id=run_id)
|
|
@@ -25,10 +25,24 @@ class LocalFileStore:
|
|
|
25
25
|
json.dump(run.to_dict(), f, indent=4)
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def load_run(self, run_id: str) -> Run:
|
|
28
|
+
def load_run(self, run_id: str | None = None) -> Run | None:
|
|
29
29
|
"""
|
|
30
30
|
Reads JSON run file from storage and returns a Run.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
- run_id: returns latest run if no argument is passed
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
- Run if exists else None
|
|
31
37
|
"""
|
|
38
|
+
if run_id is None:
|
|
39
|
+
runs = self.list_runs(limit=1)
|
|
40
|
+
|
|
41
|
+
if not runs:
|
|
42
|
+
return None
|
|
43
|
+
|
|
44
|
+
return runs[0]
|
|
45
|
+
|
|
32
46
|
path = self._runs_dir / f"{run_id}.json"
|
|
33
47
|
|
|
34
48
|
with path.open("r") as f:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mllogs
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Local experiment logging for machine learning
|
|
5
5
|
Author: Finn Walsh
|
|
6
6
|
License-Expression: MIT
|
|
@@ -37,14 +37,23 @@ client.log_param("learning_rate", 0.01)
|
|
|
37
37
|
client.log_metric("accuracy", 0.92)
|
|
38
38
|
client.set_tag("model", "logistic_regression")
|
|
39
39
|
|
|
40
|
-
client.end_run()
|
|
40
|
+
run = client.end_run()
|
|
41
|
+
|
|
42
|
+
client.list_runs()
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Retrieve or delete a saved run:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
client.get_run(id)
|
|
49
|
+
client.delete_run(id)
|
|
41
50
|
```
|
|
42
51
|
|
|
43
52
|
## Features
|
|
44
53
|
|
|
45
54
|
- Start and end experiment runs
|
|
46
55
|
- Log parameters, metrics, and tags
|
|
47
|
-
-
|
|
56
|
+
- Automatically persist completed runs to local storage
|
|
48
57
|
- Load, list, and delete saved runs
|
|
49
58
|
|
|
50
59
|
## Development
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from pathlib import Path
|
|
2
|
+
import pytest
|
|
2
3
|
|
|
3
4
|
from mllogs.run import RunStatus
|
|
4
5
|
from mllogs.client import MLLogsClient
|
|
@@ -12,6 +13,9 @@ def test_start_run() -> None:
|
|
|
12
13
|
run_type="training",
|
|
13
14
|
)
|
|
14
15
|
|
|
16
|
+
with pytest.raises(RuntimeError):
|
|
17
|
+
client.start_run()
|
|
18
|
+
|
|
15
19
|
run = client._active_run
|
|
16
20
|
|
|
17
21
|
# assert active run is generated
|
|
@@ -55,15 +59,29 @@ def test_mutate_params() -> None:
|
|
|
55
59
|
|
|
56
60
|
# log param
|
|
57
61
|
client.log_param("alpha", 0.1)
|
|
58
|
-
assert "alpha" in client._active_run.params.keys()
|
|
59
62
|
assert client._active_run.params["alpha"] == 0.1
|
|
60
63
|
|
|
61
64
|
# log metric
|
|
62
65
|
client.log_metric("RMSE", 0.01)
|
|
63
|
-
assert "RMSE" in client._active_run.metrics.keys()
|
|
64
66
|
assert client._active_run.metrics["RMSE"] == 0.01
|
|
65
67
|
|
|
66
68
|
# set tag
|
|
67
69
|
client.set_tag("ml_model", "ridge")
|
|
68
|
-
assert "ml_model" in client._active_run.tags.keys()
|
|
69
70
|
assert client._active_run.tags["ml_model"] == "ridge"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_ops_requiring_active_run() -> None:
|
|
74
|
+
client = MLLogsClient()
|
|
75
|
+
|
|
76
|
+
with pytest.raises(RuntimeError):
|
|
77
|
+
client.log_param("alpha", 0.1)
|
|
78
|
+
|
|
79
|
+
with pytest.raises(RuntimeError):
|
|
80
|
+
client.log_metric("RMSE", 0.01)
|
|
81
|
+
|
|
82
|
+
with pytest.raises(RuntimeError):
|
|
83
|
+
client.set_tag("model", "ridge")
|
|
84
|
+
|
|
85
|
+
with pytest.raises(RuntimeError):
|
|
86
|
+
client.end_run()
|
|
87
|
+
|
|
@@ -63,4 +63,27 @@ def test_runs_with_invalid_limit(tmp_path: Path) -> None:
|
|
|
63
63
|
storage = LocalFileStore(root_dir=tmp_path)
|
|
64
64
|
|
|
65
65
|
with pytest.raises(ValueError):
|
|
66
|
-
storage.list_runs(limit=0)
|
|
66
|
+
storage.list_runs(limit=0)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def test_load_latest_run(tmp_path: Path) -> None:
|
|
70
|
+
storage = LocalFileStore(root_dir=tmp_path)
|
|
71
|
+
|
|
72
|
+
run1 = Run(
|
|
73
|
+
id="001",
|
|
74
|
+
status=RunStatus.RUNNING,
|
|
75
|
+
started_at=datetime.now(UTC),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
run2 = Run(
|
|
79
|
+
id="002",
|
|
80
|
+
status=RunStatus.RUNNING,
|
|
81
|
+
started_at=datetime.now(UTC),
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
storage.save_run(run1)
|
|
85
|
+
storage.save_run(run2)
|
|
86
|
+
|
|
87
|
+
latest_run = storage.load_run()
|
|
88
|
+
|
|
89
|
+
assert latest_run == run2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|