modelzone-sdk 0.1.1.dev0__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.
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/PKG-INFO +2 -3
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/README.md +1 -1
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/azureml/backend.py +4 -3
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/core/predict_context.py +3 -3
- modelzone_sdk-0.2.0/modelzone/core/protocols.py +25 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/training/backend.py +3 -4
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/training/context.py +3 -3
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/training/db.py +9 -9
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/pyproject.toml +2 -20
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/__init__.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/azureml/__init__.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/cli.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/core/__init__.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/core/constants.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/core/model.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/core/record.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/core/trained_model.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/core/training_result.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/predict.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/training/__init__.py +0 -0
- {modelzone_sdk-0.1.1.dev0 → modelzone_sdk-0.2.0}/modelzone/training/delta_client.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: modelzone-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Modelzone SDK – a slim model training and serving toolkit
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
Author: Team Enigma
|
|
@@ -14,10 +14,8 @@ Provides-Extra: azureml
|
|
|
14
14
|
Provides-Extra: training
|
|
15
15
|
Requires-Dist: azure-ai-ml ; extra == "azureml"
|
|
16
16
|
Requires-Dist: azure-identity ; extra == "azureml"
|
|
17
|
-
Requires-Dist: datamazing (>=7,<8)
|
|
18
17
|
Requires-Dist: deltalake (>=1) ; extra == "training"
|
|
19
18
|
Requires-Dist: mlflow (>=3) ; extra == "azureml"
|
|
20
|
-
Requires-Dist: pandas (>=2,<3)
|
|
21
19
|
Description-Content-Type: text/markdown
|
|
22
20
|
|
|
23
21
|
# Modelzone SDK
|
|
@@ -114,3 +112,4 @@ modelzone fetch my_model_package --output-dir .model
|
|
|
114
112
|
poetry install --with dev,test
|
|
115
113
|
pytest
|
|
116
114
|
```
|
|
115
|
+
|
|
@@ -17,9 +17,10 @@ import shutil
|
|
|
17
17
|
import tempfile
|
|
18
18
|
from typing import Any
|
|
19
19
|
|
|
20
|
-
import datamazing.pandas as pdz
|
|
21
20
|
import requests
|
|
22
21
|
|
|
22
|
+
from modelzone.core.protocols import Database
|
|
23
|
+
|
|
23
24
|
from modelzone.core.constants import RECORD_FILENAME, TRAINED_MODEL_FILENAME
|
|
24
25
|
from modelzone.core import Model, RunRecord, TrainedModel, TrainingResult
|
|
25
26
|
from modelzone.training import Backend, TrainingContext
|
|
@@ -245,7 +246,7 @@ class AzureMLBackend(Backend):
|
|
|
245
246
|
seed: int | None = None,
|
|
246
247
|
params: dict[str, Any] | None = None,
|
|
247
248
|
tags: dict[str, str] | None = None,
|
|
248
|
-
db:
|
|
249
|
+
db: Database | None = None,
|
|
249
250
|
source_dir: str | None = None,
|
|
250
251
|
) -> TrainingResult:
|
|
251
252
|
"""Execute a training run tracked by AzureML via MLflow."""
|
|
@@ -293,7 +294,7 @@ class AzureMLBackend(Backend):
|
|
|
293
294
|
run_dir: str,
|
|
294
295
|
seed: int,
|
|
295
296
|
params: dict[str, Any] | None,
|
|
296
|
-
db:
|
|
297
|
+
db: Database | None,
|
|
297
298
|
) -> _AzureMLTrainingContext:
|
|
298
299
|
"""Return an MLflow-aware context and log params/seed eagerly."""
|
|
299
300
|
if params:
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from typing import Any
|
|
6
|
-
import datamazing.pandas as pdz
|
|
7
6
|
|
|
7
|
+
from modelzone.core.protocols import Database, TimeInterval
|
|
8
8
|
from modelzone.core.trained_model import TrainedModel
|
|
9
9
|
|
|
10
10
|
|
|
@@ -23,8 +23,8 @@ class PredictContext:
|
|
|
23
23
|
def __init__(
|
|
24
24
|
self,
|
|
25
25
|
trained_model: TrainedModel,
|
|
26
|
-
db:
|
|
27
|
-
time_interval:
|
|
26
|
+
db: Database,
|
|
27
|
+
time_interval: TimeInterval | None = None,
|
|
28
28
|
identifier: str | None = None,
|
|
29
29
|
) -> None:
|
|
30
30
|
self.trained_model = trained_model
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""Structural (Protocol) types shared across modelzone.
|
|
2
|
+
|
|
3
|
+
These exist so that modules can annotate parameters that accept
|
|
4
|
+
datamazing.pandas.Database / TimeInterval (or any structurally
|
|
5
|
+
compatible object) without depending on the datamazing package itself.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any, Protocol, runtime_checkable
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@runtime_checkable
|
|
14
|
+
class TimeInterval(Protocol):
|
|
15
|
+
"""Any object exposing ``.left`` and ``.right`` bound attributes."""
|
|
16
|
+
|
|
17
|
+
left: Any
|
|
18
|
+
right: Any
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@runtime_checkable
|
|
22
|
+
class Database(Protocol):
|
|
23
|
+
"""Structural type for a database that can execute queries."""
|
|
24
|
+
|
|
25
|
+
def query(self, table_name: str, **kwargs: Any) -> Any: ...
|
|
@@ -11,8 +11,7 @@ import uuid
|
|
|
11
11
|
from abc import ABC, abstractmethod
|
|
12
12
|
from typing import Any
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
from modelzone.core.protocols import Database
|
|
16
15
|
from modelzone.core.constants import CODE_DIR, RECORD_FILENAME, TRAINED_MODEL_FILENAME
|
|
17
16
|
from modelzone.core import Model, RunRecord, TrainedModel, TrainingResult
|
|
18
17
|
from modelzone.training.context import TrainingContext
|
|
@@ -55,7 +54,7 @@ class Backend(ABC):
|
|
|
55
54
|
seed: int | None = None,
|
|
56
55
|
params: dict[str, Any] | None = None,
|
|
57
56
|
tags: dict[str, str] | None = None,
|
|
58
|
-
db:
|
|
57
|
+
db: Database | None = None,
|
|
59
58
|
source_dir: str | None = None,
|
|
60
59
|
) -> TrainingResult:
|
|
61
60
|
"""Execute a training run.
|
|
@@ -126,7 +125,7 @@ class Backend(ABC):
|
|
|
126
125
|
run_dir: str,
|
|
127
126
|
seed: int,
|
|
128
127
|
params: dict[str, Any] | None,
|
|
129
|
-
db:
|
|
128
|
+
db: Database | None,
|
|
130
129
|
) -> TrainingContext:
|
|
131
130
|
"""Create the :class:`TrainingContext` for a training run.
|
|
132
131
|
|
|
@@ -13,10 +13,10 @@ import json
|
|
|
13
13
|
import os
|
|
14
14
|
from typing import Any
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
from modelzone.core.protocols import Database
|
|
18
17
|
from modelzone.core.record import Metric, RunRecord
|
|
19
18
|
|
|
19
|
+
|
|
20
20
|
# Subdirectories / files inside the run directory
|
|
21
21
|
_METRICS_FILE = "metrics.jsonl"
|
|
22
22
|
_LOG_FILE = "output.log"
|
|
@@ -43,7 +43,7 @@ class TrainingContext:
|
|
|
43
43
|
run_dir: str,
|
|
44
44
|
seed: int,
|
|
45
45
|
params: dict[str, Any] | None = None,
|
|
46
|
-
db:
|
|
46
|
+
db: Database | None = None,
|
|
47
47
|
) -> None:
|
|
48
48
|
self.run_dir = run_dir
|
|
49
49
|
self.seed = seed
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"""Modelzone training – database client for accessing training data.
|
|
2
2
|
|
|
3
3
|
Wraps a :class:`~modelzone.training.delta_client.DeltaClient` and
|
|
4
|
-
implements :class
|
|
5
|
-
interchangeably wherever a ``
|
|
4
|
+
implements :class:`~modelzone.core.protocols.Database` so it can be used
|
|
5
|
+
interchangeably wherever a ``Database`` is expected (including
|
|
6
6
|
:class:`~modelzone.core.PredictContext`).
|
|
7
7
|
"""
|
|
8
8
|
|
|
@@ -13,17 +13,17 @@ import json
|
|
|
13
13
|
import os
|
|
14
14
|
from typing import Optional
|
|
15
15
|
|
|
16
|
-
import datamazing.pandas as pdz
|
|
17
16
|
import pandas as pd
|
|
18
17
|
|
|
18
|
+
from modelzone.core.protocols import TimeInterval
|
|
19
19
|
from modelzone.training.delta_client import DeltaClient
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
class ModelzoneDatabase
|
|
22
|
+
class ModelzoneDatabase:
|
|
23
23
|
"""Database client for loading training (and prediction) data.
|
|
24
24
|
|
|
25
25
|
Thin wrapper around :class:`DeltaClient` that
|
|
26
|
-
implements the :class
|
|
26
|
+
implements the :class:`~modelzone.core.protocols.Database` protocol.
|
|
27
27
|
|
|
28
28
|
When *cache_dir* is set, query results are saved as local parquet
|
|
29
29
|
files keyed by the query parameters. This avoids repeated reads
|
|
@@ -88,7 +88,7 @@ class ModelzoneDatabase(pdz.Database):
|
|
|
88
88
|
@staticmethod
|
|
89
89
|
def _cache_key(
|
|
90
90
|
table_name: str,
|
|
91
|
-
time_interval:
|
|
91
|
+
time_interval: TimeInterval | None,
|
|
92
92
|
filters: dict[str, object] | None,
|
|
93
93
|
columns: list[str] | None,
|
|
94
94
|
) -> str:
|
|
@@ -108,19 +108,19 @@ class ModelzoneDatabase(pdz.Database):
|
|
|
108
108
|
return hashlib.sha256(blob).hexdigest()[:16]
|
|
109
109
|
|
|
110
110
|
# ------------------------------------------------------------------
|
|
111
|
-
#
|
|
111
|
+
# Database protocol interface
|
|
112
112
|
# ------------------------------------------------------------------
|
|
113
113
|
|
|
114
114
|
def query(
|
|
115
115
|
self,
|
|
116
116
|
table_name: str,
|
|
117
|
-
time_interval: Optional[
|
|
117
|
+
time_interval: Optional[TimeInterval] = None,
|
|
118
118
|
filters: Optional[dict[str, object]] = None,
|
|
119
119
|
columns: Optional[list[str]] = None,
|
|
120
120
|
) -> pd.DataFrame:
|
|
121
121
|
"""Query a table and return a DataFrame.
|
|
122
122
|
|
|
123
|
-
Implements :meth
|
|
123
|
+
Implements :meth:`~modelzone.core.protocols.Database.query`.
|
|
124
124
|
When *cache_dir* is configured, results are read from / written
|
|
125
125
|
to a local parquet file to speed up repeated queries.
|
|
126
126
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "modelzone-sdk"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
description = "Modelzone SDK – a slim model training and serving toolkit"
|
|
5
5
|
authors = [{ name = "Team Enigma", email = "enigma@energinet.dk" }]
|
|
6
6
|
requires-python = ">=3.13"
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
license = "Apache-2.0"
|
|
9
|
-
dependencies = [
|
|
9
|
+
dependencies = []
|
|
10
10
|
classifiers = [
|
|
11
11
|
"Development Status :: 3 - Alpha",
|
|
12
12
|
"Intended Audience :: Developers",
|
|
@@ -25,17 +25,6 @@ modelzone = "modelzone.cli:main"
|
|
|
25
25
|
packages = [{ include = "modelzone" }]
|
|
26
26
|
requires-poetry = ">=2.2"
|
|
27
27
|
|
|
28
|
-
[tool.poetry.dependencies]
|
|
29
|
-
datamazing = "^7.0.1"
|
|
30
|
-
pandas = ">=2.3.3,<3"
|
|
31
|
-
|
|
32
|
-
[tool.poetry.group.training.dependencies]
|
|
33
|
-
deltalake = ">=1"
|
|
34
|
-
|
|
35
|
-
[tool.poetry.group.dev.dependencies]
|
|
36
|
-
pre-commit = ">=2.20.0"
|
|
37
|
-
ruff = ">=0.4"
|
|
38
|
-
|
|
39
28
|
[tool.poetry.group.test.dependencies]
|
|
40
29
|
pytest = ">=8"
|
|
41
30
|
pytest-cov = ">=3.0.0"
|
|
@@ -48,13 +37,6 @@ build-backend = "poetry.core.masonry.api"
|
|
|
48
37
|
[tool.black]
|
|
49
38
|
line-length = 88
|
|
50
39
|
|
|
51
|
-
[tool.ruff]
|
|
52
|
-
line-length = 88
|
|
53
|
-
target-version = "py313"
|
|
54
|
-
|
|
55
|
-
[tool.ruff.lint]
|
|
56
|
-
select = ["E", "F", "I", "W"]
|
|
57
|
-
|
|
58
40
|
[tool.mypy]
|
|
59
41
|
ignore_missing_imports = true
|
|
60
42
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|