dmlops 0.2.10__py3-none-win_amd64.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.
- dmlops/__init__.py +36 -0
- dmlops/_auth.py +668 -0
- dmlops/_envprobe.py +163 -0
- dmlops/_metrics_clean.py +239 -0
- dmlops/_resource.py +151 -0
- dmlops/_run.py +755 -0
- dmlops/_spool.py +367 -0
- dmlops/_status.py +90 -0
- dmlops/_tee.py +192 -0
- dmlops/_transport.py +133 -0
- dmlops/_tui.py +668 -0
- dmlops/_uploader.py +120 -0
- dmlops/exceptions.py +26 -0
- dmlops-0.2.10.data/scripts/dmlops.exe +0 -0
- dmlops-0.2.10.dist-info/METADATA +36 -0
- dmlops-0.2.10.dist-info/RECORD +18 -0
- dmlops-0.2.10.dist-info/WHEEL +4 -0
- dreamsports_mlops_client/__init__.py +39 -0
dmlops/_uploader.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""Artifact upload pipeline: presign → direct PUT → confirm.
|
|
2
|
+
|
|
3
|
+
Each file is independent: a failure prints a warning and never aborts the
|
|
4
|
+
training run (the server treats missing artifacts as an incomplete, not a
|
|
5
|
+
failed, run).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import hashlib
|
|
11
|
+
import os
|
|
12
|
+
import warnings
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
from ._transport import Transport
|
|
16
|
+
from .exceptions import MlopsError
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def sha256_hex(data: bytes) -> str:
|
|
20
|
+
return hashlib.sha256(data).hexdigest()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _sha256_file(path: Path) -> str:
|
|
24
|
+
digest = hashlib.sha256()
|
|
25
|
+
with open(path, "rb") as fh:
|
|
26
|
+
for chunk in iter(lambda: fh.read(1024 * 1024), b""):
|
|
27
|
+
digest.update(chunk)
|
|
28
|
+
return digest.hexdigest()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def upload_file(
|
|
32
|
+
transport: Transport,
|
|
33
|
+
experiment_id: str,
|
|
34
|
+
source: "bytes | bytearray | str | os.PathLike[str]",
|
|
35
|
+
path: str,
|
|
36
|
+
) -> None:
|
|
37
|
+
"""Upload one file through the presign→PUT→confirm pipeline.
|
|
38
|
+
|
|
39
|
+
``source`` is either in-memory bytes or a filesystem path. Path sources
|
|
40
|
+
stream from disk (constant memory); each attempt re-stats and re-hashes
|
|
41
|
+
the file, so a file modified between retries uploads its newer bytes on
|
|
42
|
+
the next attempt (the server re-validates size/sha at confirm).
|
|
43
|
+
Classification is server-side by extension. Raises on failure — callers
|
|
44
|
+
convert to a warning."""
|
|
45
|
+
data: "bytes | None" = None
|
|
46
|
+
file_path: "Path | None" = None
|
|
47
|
+
if isinstance(source, (bytes, bytearray)):
|
|
48
|
+
data = bytes(source)
|
|
49
|
+
size = len(data)
|
|
50
|
+
sha = sha256_hex(data)
|
|
51
|
+
elif isinstance(source, (str, os.PathLike)):
|
|
52
|
+
file_path = Path(source)
|
|
53
|
+
size = file_path.stat().st_size
|
|
54
|
+
sha = _sha256_file(file_path)
|
|
55
|
+
else:
|
|
56
|
+
raise MlopsError(f"unsupported source type: {type(source).__name__}")
|
|
57
|
+
declared = {
|
|
58
|
+
"path": path,
|
|
59
|
+
"sizeBytes": size,
|
|
60
|
+
"sha256": sha,
|
|
61
|
+
}
|
|
62
|
+
presign = transport.request(
|
|
63
|
+
"POST",
|
|
64
|
+
f"/api/experiments/{experiment_id}/artifacts/presign",
|
|
65
|
+
declared,
|
|
66
|
+
timeout=60.0,
|
|
67
|
+
)
|
|
68
|
+
upload_url = presign["uploadUrl"]
|
|
69
|
+
headers = {str(k): str(v) for k, v in (presign.get("headers") or {}).items()}
|
|
70
|
+
if data is not None:
|
|
71
|
+
transport.put_data(upload_url, data, headers, size)
|
|
72
|
+
else:
|
|
73
|
+
assert file_path is not None
|
|
74
|
+
with open(file_path, "rb") as fh:
|
|
75
|
+
transport.put_data(upload_url, fh, headers, size)
|
|
76
|
+
transport.request(
|
|
77
|
+
"POST",
|
|
78
|
+
f"/api/experiments/{experiment_id}/artifacts/confirm",
|
|
79
|
+
dict(declared),
|
|
80
|
+
timeout=60.0,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def iter_directory(
|
|
85
|
+
root: "str | os.PathLike[str]",
|
|
86
|
+
*,
|
|
87
|
+
recursive: bool = True,
|
|
88
|
+
include_hidden: bool = False,
|
|
89
|
+
) -> "list[tuple[Path, str]]":
|
|
90
|
+
"""Walk a directory tree: follow directories, skip symlinks and special
|
|
91
|
+
files. Hidden entries (name starting with ``.``) are excluded unless
|
|
92
|
+
``include_hidden``; subdirectories are not descended into when
|
|
93
|
+
``recursive`` is False. Returns (file_path, relative_posix_path)."""
|
|
94
|
+
base = Path(root)
|
|
95
|
+
out: list[tuple[Path, str]] = []
|
|
96
|
+
for dirpath, dirnames, filenames in os.walk(base, followlinks=False):
|
|
97
|
+
if not include_hidden:
|
|
98
|
+
dirnames[:] = [d for d in dirnames if not d.startswith(".")]
|
|
99
|
+
if not recursive:
|
|
100
|
+
dirnames[:] = []
|
|
101
|
+
for filename in filenames:
|
|
102
|
+
if not include_hidden and filename.startswith("."):
|
|
103
|
+
continue
|
|
104
|
+
full = Path(dirpath) / filename
|
|
105
|
+
try:
|
|
106
|
+
if full.is_symlink() or not full.is_file():
|
|
107
|
+
continue
|
|
108
|
+
rel = full.relative_to(base).as_posix()
|
|
109
|
+
except (OSError, ValueError):
|
|
110
|
+
continue
|
|
111
|
+
out.append((full, rel))
|
|
112
|
+
out.sort(key=lambda item: item[1])
|
|
113
|
+
return out
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def warn_upload_failed(path: str, exc: BaseException) -> None:
|
|
117
|
+
warnings.warn(f"[mlops] upload of '{path}' failed: {exc}", stacklevel=3)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
__all__ = ["upload_file", "iter_directory", "warn_upload_failed", "sha256_hex"]
|
dmlops/exceptions.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Public exception types (exactly four)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class MlopsError(Exception):
|
|
7
|
+
"""Base error: network, server, and usage failures.
|
|
8
|
+
|
|
9
|
+
``status`` carries the HTTP status code for server rejections;
|
|
10
|
+
``None`` for network-level failures and local usage errors.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
status: int | None = None
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MlopsAuthError(MlopsError):
|
|
17
|
+
"""401 at any point of the credential chain."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class MlopsCancelled(MlopsError):
|
|
21
|
+
"""The server cancelled this run; raised by the next ``Run.log_metric()`` call."""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class MlopsConflict(MlopsError):
|
|
25
|
+
"""409 from the server (e.g. finish after interrupt). ``code`` carries
|
|
26
|
+
the platform error code (``CANCELLED`` / ``CONFLICT``)."""
|
|
Binary file
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dmlops
|
|
3
|
+
Version: 0.2.10
|
|
4
|
+
Summary: Track MLOps platform experiments from any self-managed machine: metrics, artifacts, weights, and failure/cancel state reporting.
|
|
5
|
+
Project-URL: Homepage, https://gitee.com/rmkj/MLOps
|
|
6
|
+
Project-URL: Documentation, https://gitee.com/rmkj/MLOps/blob/master/documentation/docs/experiments/external-runs.md
|
|
7
|
+
License: Proprietary
|
|
8
|
+
Requires-Python: >=3.9
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# dmlops
|
|
12
|
+
|
|
13
|
+
Track MLOps platform experiments from any self-managed machine. Python ≥ 3.9, standard-library only.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
uv pip install dmlops
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick start
|
|
22
|
+
|
|
23
|
+
```python
|
|
24
|
+
import dmlops as mlops
|
|
25
|
+
|
|
26
|
+
mlops.login()
|
|
27
|
+
mlops.whoami()
|
|
28
|
+
runner = mlops.create_experiment(
|
|
29
|
+
job="train", # or mlops.Job.TRAIN; "val" / "export" also accepted
|
|
30
|
+
name="yolo-coco128", # optional — auto-generated when omitted
|
|
31
|
+
)
|
|
32
|
+
runner.log_metric({"loss": {"total": 1.2}, "lr": {"lr": 1e-3}}, epoch=0, split="train")
|
|
33
|
+
runner.log_metric(ap5095={"box": {"mean": 0.42}}, epoch=0, split="val")
|
|
34
|
+
runner.upload("weights/best.pt")
|
|
35
|
+
runner.finish()
|
|
36
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
dmlops/__init__.py,sha256=JyyAxVY3xMBok41Z_ahrMW5c0zH7-g8kOuaGojNLFY8,924
|
|
2
|
+
dmlops/_auth.py,sha256=aOI_rnE8hgBlwzmbFC9beMyFhrRvblubFbLNEERfX80,23840
|
|
3
|
+
dmlops/_envprobe.py,sha256=Mt5HhobtXwoNedQ6kNridQuxufHX7esywKnpLIGBa00,5544
|
|
4
|
+
dmlops/_metrics_clean.py,sha256=XBOBAu5sssorBwVJvAYMJQWFnVBs-nAakaz3DuWpO60,8068
|
|
5
|
+
dmlops/_resource.py,sha256=wRs09xnHEDDSQkKEVvznth6uTEqug1kwG-xI88hMSnw,5396
|
|
6
|
+
dmlops/_run.py,sha256=XnJ__GCVXcnQHCWNbyobg6wcDkOmp9SIhZdW_qwRDiY,30671
|
|
7
|
+
dmlops/_spool.py,sha256=y8iUmOc9lfxowD0RcSo21OUFCn9EQyvdUxsM3QgOGuI,14463
|
|
8
|
+
dmlops/_status.py,sha256=9eaQWWAkTJvN8VwAt5z2_f9msUWEVKlvhbRGTqB-M5k,3001
|
|
9
|
+
dmlops/_tee.py,sha256=qLPRIkdcsBod2qP06zkC7oOOUlms9b1FDpYSjlzE8pU,6692
|
|
10
|
+
dmlops/_transport.py,sha256=hNEWmglRp5o57D_tysSN07rwI9VNlbEhPVtImc-kVyo,5027
|
|
11
|
+
dmlops/_tui.py,sha256=neM0Ek90ZrKuwgoe9UdmIztLKphqCxJRtPuTGO8m0dw,20195
|
|
12
|
+
dmlops/_uploader.py,sha256=S-WEYaxZmJ7cR19qN8MymAsVeRMHDarZLiyqL5hUoS0,4001
|
|
13
|
+
dmlops/exceptions.py,sha256=Jy-uFX9jn2gD6UVDe-uLbc1JT3iWhyLzlbXOPWemz5k,723
|
|
14
|
+
dreamsports_mlops_client/__init__.py,sha256=cTwlPjoud5CWfypgrZ_d2xCzYaYAo_l--sOppOCuj7E,994
|
|
15
|
+
dmlops-0.2.10.dist-info/METADATA,sha256=tYaSilZmYOcY2ilwMUqToLjRMskPJcXmX_Yg6PjkIQg,1072
|
|
16
|
+
dmlops-0.2.10.dist-info/WHEEL,sha256=lpoBGaIUIidvvdZ4qRAP61bBKYJdt4FI3WXFL50Gzyo,94
|
|
17
|
+
dmlops-0.2.10.data/scripts/dmlops.exe,sha256=dy5266WQfa5w5STiO0Wvh0RIJZyk3UEhBzAOS7gAksQ,25566208
|
|
18
|
+
dmlops-0.2.10.dist-info/RECORD,,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""Deprecated alias for the ``dmlops`` package.
|
|
2
|
+
|
|
3
|
+
``dreamsports_mlops_client`` was renamed to ``dmlops``. This shim keeps old
|
|
4
|
+
code (``import dreamsports_mlops_client as mlops``) working after
|
|
5
|
+
``pip install dmlops``; new code should use ``import dmlops``.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import importlib
|
|
9
|
+
import sys
|
|
10
|
+
import warnings
|
|
11
|
+
|
|
12
|
+
warnings.warn(
|
|
13
|
+
"dreamsports_mlops_client has been renamed to dmlops; "
|
|
14
|
+
"please switch to `import dmlops`",
|
|
15
|
+
DeprecationWarning,
|
|
16
|
+
stacklevel=2,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
from dmlops import * # noqa: F401,F403
|
|
20
|
+
from dmlops import __version__ # noqa: F401
|
|
21
|
+
|
|
22
|
+
# Alias submodules so `dreamsports_mlops_client.exceptions` (and the private
|
|
23
|
+
# helpers old code may touch) resolve to the same module objects.
|
|
24
|
+
for _m in (
|
|
25
|
+
"exceptions",
|
|
26
|
+
"_auth",
|
|
27
|
+
"_envprobe",
|
|
28
|
+
"_metrics_clean",
|
|
29
|
+
"_resource",
|
|
30
|
+
"_run",
|
|
31
|
+
"_spool",
|
|
32
|
+
"_status",
|
|
33
|
+
"_tee",
|
|
34
|
+
"_transport",
|
|
35
|
+
"_tui",
|
|
36
|
+
"_uploader",
|
|
37
|
+
):
|
|
38
|
+
sys.modules[f"dreamsports_mlops_client.{_m}"] = importlib.import_module(f"dmlops.{_m}")
|
|
39
|
+
del _m
|