ml-dash 0.5.8__py3-none-any.whl → 0.6.0__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.
- ml_dash/__init__.py +35 -9
- ml_dash/auth/__init__.py +51 -0
- ml_dash/auth/constants.py +10 -0
- ml_dash/auth/device_flow.py +237 -0
- ml_dash/auth/device_secret.py +49 -0
- ml_dash/auth/exceptions.py +31 -0
- ml_dash/auth/token_storage.py +262 -0
- ml_dash/auto_start.py +37 -14
- ml_dash/cli.py +14 -2
- ml_dash/cli_commands/download.py +10 -38
- ml_dash/cli_commands/list.py +10 -34
- ml_dash/cli_commands/login.py +225 -0
- ml_dash/cli_commands/logout.py +54 -0
- ml_dash/cli_commands/upload.py +3 -53
- ml_dash/client.py +67 -34
- ml_dash/config.py +15 -1
- ml_dash/experiment.py +151 -55
- ml_dash/files.py +97 -0
- ml_dash/metric.py +192 -3
- ml_dash/params.py +92 -3
- ml_dash/remote_auto_start.py +55 -0
- ml_dash/storage.py +366 -235
- {ml_dash-0.5.8.dist-info → ml_dash-0.6.0.dist-info}/METADATA +5 -1
- ml_dash-0.6.0.dist-info/RECORD +29 -0
- ml_dash-0.5.8.dist-info/RECORD +0 -20
- {ml_dash-0.5.8.dist-info → ml_dash-0.6.0.dist-info}/WHEEL +0 -0
- {ml_dash-0.5.8.dist-info → ml_dash-0.6.0.dist-info}/entry_points.txt +0 -0
ml_dash/params.py
CHANGED
|
@@ -6,6 +6,7 @@ Nested dicts are flattened to dot-notation: {"model": {"lr": 0.001}} → {"model
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
from typing import Dict, Any, Optional, TYPE_CHECKING
|
|
9
|
+
import inspect
|
|
9
10
|
|
|
10
11
|
if TYPE_CHECKING:
|
|
11
12
|
from .experiment import Experiment
|
|
@@ -62,13 +63,21 @@ class ParametersBuilder:
|
|
|
62
63
|
experiment.parameters().set(**{"model.lr": 0.001, "model.batch_size": 32})
|
|
63
64
|
"""
|
|
64
65
|
if not self._experiment._is_open:
|
|
65
|
-
raise RuntimeError(
|
|
66
|
+
raise RuntimeError(
|
|
67
|
+
"Experiment not started. Use 'with experiment.run:' or call experiment.run.start() first.\n"
|
|
68
|
+
"Example:\n"
|
|
69
|
+
" with dxp.run:\n"
|
|
70
|
+
" dxp.params.set(lr=0.001)"
|
|
71
|
+
)
|
|
66
72
|
|
|
67
73
|
if self._experiment._write_protected:
|
|
68
74
|
raise RuntimeError("Experiment is write-protected and cannot be modified.")
|
|
69
75
|
|
|
76
|
+
# Convert class objects to dicts (for params_proto support)
|
|
77
|
+
processed_kwargs = self._process_class_objects(kwargs)
|
|
78
|
+
|
|
70
79
|
# Flatten the kwargs
|
|
71
|
-
flattened = self.flatten_dict(
|
|
80
|
+
flattened = self.flatten_dict(processed_kwargs)
|
|
72
81
|
|
|
73
82
|
if not flattened:
|
|
74
83
|
# No parameters to set, just return
|
|
@@ -79,6 +88,43 @@ class ParametersBuilder:
|
|
|
79
88
|
|
|
80
89
|
return self
|
|
81
90
|
|
|
91
|
+
def log(self, **kwargs) -> 'ParametersBuilder':
|
|
92
|
+
"""
|
|
93
|
+
Alias for set(). Sets/merges parameters.
|
|
94
|
+
|
|
95
|
+
This method exists for better parameter organization and semantic clarity.
|
|
96
|
+
It behaves exactly the same as set().
|
|
97
|
+
|
|
98
|
+
Nested dicts are automatically flattened:
|
|
99
|
+
log(model={"lr": 0.001, "batch_size": 32})
|
|
100
|
+
→ {"model.lr": 0.001, "model.batch_size": 32}
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
**kwargs: Parameters to set (can be nested dicts)
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
Self for potential chaining
|
|
107
|
+
|
|
108
|
+
Raises:
|
|
109
|
+
RuntimeError: If experiment is not open
|
|
110
|
+
RuntimeError: If experiment is write-protected
|
|
111
|
+
|
|
112
|
+
Examples:
|
|
113
|
+
# Set parameters using log() - same as set()
|
|
114
|
+
experiment.params.log(
|
|
115
|
+
learning_rate=0.001,
|
|
116
|
+
batch_size=32,
|
|
117
|
+
model="resnet50"
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
# Track parameter changes during training
|
|
121
|
+
for epoch in range(10):
|
|
122
|
+
if epoch == 5:
|
|
123
|
+
experiment.params.log(learning_rate=0.0001) # Log LR decay
|
|
124
|
+
"""
|
|
125
|
+
# Just call set() - they behave exactly the same
|
|
126
|
+
return self.set(**kwargs)
|
|
127
|
+
|
|
82
128
|
def get(self, flatten: bool = True) -> Dict[str, Any]:
|
|
83
129
|
"""
|
|
84
130
|
Get parameters from the experiment.
|
|
@@ -103,7 +149,12 @@ class ParametersBuilder:
|
|
|
103
149
|
# → {"model": {"lr": 0.001, "batch_size": 32}, "optimizer": "adam"}
|
|
104
150
|
"""
|
|
105
151
|
if not self._experiment._is_open:
|
|
106
|
-
raise RuntimeError(
|
|
152
|
+
raise RuntimeError(
|
|
153
|
+
"Experiment not started. Use 'with experiment.run:' or call experiment.run.start() first.\n"
|
|
154
|
+
"Example:\n"
|
|
155
|
+
" with dxp.run:\n"
|
|
156
|
+
" dxp.params.get()"
|
|
157
|
+
)
|
|
107
158
|
|
|
108
159
|
# Read parameters through experiment
|
|
109
160
|
params = self._experiment._read_params()
|
|
@@ -186,3 +237,41 @@ class ParametersBuilder:
|
|
|
186
237
|
current[parts[-1]] = value
|
|
187
238
|
|
|
188
239
|
return result
|
|
240
|
+
|
|
241
|
+
@staticmethod
|
|
242
|
+
def _process_class_objects(d: Dict[str, Any]) -> Dict[str, Any]:
|
|
243
|
+
"""
|
|
244
|
+
Convert class objects to dicts by extracting their attributes.
|
|
245
|
+
|
|
246
|
+
This enables passing configuration classes directly:
|
|
247
|
+
dxp.params.log(Args=Args) # Args is a class
|
|
248
|
+
→ {"Args": {"batch_size": 64, "lr": 0.001, ...}}
|
|
249
|
+
|
|
250
|
+
Args:
|
|
251
|
+
d: Dictionary that may contain class objects as values
|
|
252
|
+
|
|
253
|
+
Returns:
|
|
254
|
+
Dictionary with class objects converted to attribute dicts
|
|
255
|
+
|
|
256
|
+
Examples:
|
|
257
|
+
>>> class Args:
|
|
258
|
+
... batch_size = 64
|
|
259
|
+
... lr = 0.001
|
|
260
|
+
>>> _process_class_objects({"Args": Args})
|
|
261
|
+
{"Args": {"batch_size": 64, "lr": 0.001}}
|
|
262
|
+
"""
|
|
263
|
+
result = {}
|
|
264
|
+
for key, value in d.items():
|
|
265
|
+
if inspect.isclass(value):
|
|
266
|
+
# Extract class attributes (skip private/magic and callables)
|
|
267
|
+
attrs = {}
|
|
268
|
+
for attr_name, attr_value in vars(value).items():
|
|
269
|
+
if not attr_name.startswith('_') and not callable(attr_value):
|
|
270
|
+
# Recursively handle nested types
|
|
271
|
+
if isinstance(attr_value, type):
|
|
272
|
+
continue # Skip type annotations
|
|
273
|
+
attrs[attr_name] = attr_value
|
|
274
|
+
result[key] = attrs
|
|
275
|
+
else:
|
|
276
|
+
result[key] = value
|
|
277
|
+
return result
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Pre-configured remote experiment singleton for ML-Dash SDK.
|
|
3
|
+
|
|
4
|
+
Provides a pre-configured experiment singleton named 'rdxp' that uses remote mode.
|
|
5
|
+
Requires manual start using 'with' statement or explicit start() call.
|
|
6
|
+
|
|
7
|
+
IMPORTANT: Before using rdxp, you must authenticate with the ML-Dash server:
|
|
8
|
+
# First time setup - authenticate with the server
|
|
9
|
+
python -m ml_dash.cli login
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
from ml_dash import rdxp
|
|
13
|
+
|
|
14
|
+
# Use with statement (recommended)
|
|
15
|
+
with rdxp.run:
|
|
16
|
+
rdxp.log().info("Hello from rdxp!")
|
|
17
|
+
rdxp.params.set(lr=0.001)
|
|
18
|
+
rdxp.metrics("loss").append(step=0, value=0.5)
|
|
19
|
+
# Automatically completes on exit from with block
|
|
20
|
+
|
|
21
|
+
# Or start/complete manually
|
|
22
|
+
rdxp.run.start()
|
|
23
|
+
rdxp.log().info("Training...")
|
|
24
|
+
rdxp.run.complete()
|
|
25
|
+
|
|
26
|
+
Configuration:
|
|
27
|
+
- Default server: https://api.dash.ml
|
|
28
|
+
- To use a different server, set MLDASH_API_URL environment variable
|
|
29
|
+
- Authentication token is auto-loaded from secure storage
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
import atexit
|
|
33
|
+
from .experiment import Experiment
|
|
34
|
+
|
|
35
|
+
# Create pre-configured singleton experiment for remote mode
|
|
36
|
+
# Uses remote API server - token auto-loaded from storage
|
|
37
|
+
rdxp = Experiment(
|
|
38
|
+
name="rdxp",
|
|
39
|
+
project="scratch",
|
|
40
|
+
remote="https://api.dash.ml"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Register cleanup handler to complete experiment on Python exit (if still open)
|
|
44
|
+
def _cleanup():
|
|
45
|
+
"""Complete the rdxp experiment on exit if still open."""
|
|
46
|
+
if rdxp._is_open:
|
|
47
|
+
try:
|
|
48
|
+
rdxp.run.complete()
|
|
49
|
+
except Exception:
|
|
50
|
+
# Silently ignore errors during cleanup
|
|
51
|
+
pass
|
|
52
|
+
|
|
53
|
+
atexit.register(_cleanup)
|
|
54
|
+
|
|
55
|
+
__all__ = ["rdxp"]
|