mlrun 1.4.0rc25__py3-none-any.whl → 1.5.0rc2__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.
Potentially problematic release.
This version of mlrun might be problematic. Click here for more details.
- mlrun/__init__.py +2 -35
- mlrun/__main__.py +3 -41
- mlrun/api/api/api.py +6 -0
- mlrun/api/api/endpoints/feature_store.py +0 -4
- mlrun/api/api/endpoints/files.py +14 -2
- mlrun/api/api/endpoints/frontend_spec.py +2 -1
- mlrun/api/api/endpoints/functions.py +95 -59
- mlrun/api/api/endpoints/grafana_proxy.py +9 -9
- mlrun/api/api/endpoints/logs.py +17 -3
- mlrun/api/api/endpoints/model_endpoints.py +3 -2
- mlrun/api/api/endpoints/pipelines.py +1 -5
- mlrun/api/api/endpoints/projects.py +88 -0
- mlrun/api/api/endpoints/runs.py +48 -6
- mlrun/api/api/endpoints/submit.py +2 -1
- mlrun/api/api/endpoints/workflows.py +355 -0
- mlrun/api/api/utils.py +3 -4
- mlrun/api/crud/__init__.py +1 -0
- mlrun/api/crud/client_spec.py +6 -2
- mlrun/api/crud/feature_store.py +5 -0
- mlrun/api/crud/model_monitoring/__init__.py +1 -0
- mlrun/api/crud/model_monitoring/deployment.py +497 -0
- mlrun/api/crud/model_monitoring/grafana.py +96 -42
- mlrun/api/crud/model_monitoring/helpers.py +159 -0
- mlrun/api/crud/model_monitoring/model_endpoints.py +202 -476
- mlrun/api/crud/notifications.py +9 -4
- mlrun/api/crud/pipelines.py +6 -11
- mlrun/api/crud/projects.py +2 -2
- mlrun/api/crud/runtime_resources.py +4 -3
- mlrun/api/crud/runtimes/nuclio/helpers.py +5 -1
- mlrun/api/crud/secrets.py +21 -0
- mlrun/api/crud/workflows.py +352 -0
- mlrun/api/db/base.py +16 -1
- mlrun/api/db/init_db.py +2 -4
- mlrun/api/db/session.py +1 -1
- mlrun/api/db/sqldb/db.py +129 -31
- mlrun/api/db/sqldb/models/models_mysql.py +15 -1
- mlrun/api/db/sqldb/models/models_sqlite.py +16 -2
- mlrun/api/launcher.py +38 -6
- mlrun/api/main.py +3 -2
- mlrun/api/rundb/__init__.py +13 -0
- mlrun/{db → api/rundb}/sqldb.py +36 -84
- mlrun/api/runtime_handlers/__init__.py +56 -0
- mlrun/api/runtime_handlers/base.py +1247 -0
- mlrun/api/runtime_handlers/daskjob.py +209 -0
- mlrun/api/runtime_handlers/kubejob.py +37 -0
- mlrun/api/runtime_handlers/mpijob.py +147 -0
- mlrun/api/runtime_handlers/remotesparkjob.py +29 -0
- mlrun/api/runtime_handlers/sparkjob.py +148 -0
- mlrun/api/schemas/__init__.py +17 -6
- mlrun/api/utils/builder.py +1 -4
- mlrun/api/utils/clients/chief.py +14 -0
- mlrun/api/utils/clients/iguazio.py +33 -33
- mlrun/api/utils/clients/nuclio.py +2 -2
- mlrun/api/utils/periodic.py +9 -2
- mlrun/api/utils/projects/follower.py +14 -7
- mlrun/api/utils/projects/leader.py +2 -1
- mlrun/api/utils/projects/remotes/nop_follower.py +2 -2
- mlrun/api/utils/projects/remotes/nop_leader.py +2 -2
- mlrun/api/utils/runtimes/__init__.py +14 -0
- mlrun/api/utils/runtimes/nuclio.py +43 -0
- mlrun/api/utils/scheduler.py +98 -15
- mlrun/api/utils/singletons/db.py +5 -1
- mlrun/api/utils/singletons/project_member.py +4 -1
- mlrun/api/utils/singletons/scheduler.py +1 -1
- mlrun/artifacts/base.py +6 -6
- mlrun/artifacts/dataset.py +4 -4
- mlrun/artifacts/manager.py +2 -3
- mlrun/artifacts/model.py +2 -2
- mlrun/artifacts/plots.py +8 -8
- mlrun/common/db/__init__.py +14 -0
- mlrun/common/helpers.py +37 -0
- mlrun/{mlutils → common/model_monitoring}/__init__.py +3 -2
- mlrun/common/model_monitoring/helpers.py +69 -0
- mlrun/common/schemas/__init__.py +13 -1
- mlrun/common/schemas/auth.py +4 -1
- mlrun/common/schemas/client_spec.py +1 -1
- mlrun/common/schemas/function.py +17 -0
- mlrun/common/schemas/model_monitoring/__init__.py +48 -0
- mlrun/common/{model_monitoring.py → schemas/model_monitoring/constants.py} +11 -23
- mlrun/common/schemas/model_monitoring/grafana.py +55 -0
- mlrun/common/schemas/{model_endpoints.py → model_monitoring/model_endpoints.py} +32 -65
- mlrun/common/schemas/notification.py +1 -0
- mlrun/common/schemas/object.py +4 -0
- mlrun/common/schemas/project.py +1 -0
- mlrun/common/schemas/regex.py +1 -1
- mlrun/common/schemas/runs.py +1 -8
- mlrun/common/schemas/schedule.py +1 -8
- mlrun/common/schemas/workflow.py +54 -0
- mlrun/config.py +45 -42
- mlrun/datastore/__init__.py +21 -0
- mlrun/datastore/base.py +1 -1
- mlrun/datastore/datastore.py +9 -0
- mlrun/datastore/dbfs_store.py +168 -0
- mlrun/datastore/helpers.py +18 -0
- mlrun/datastore/sources.py +1 -0
- mlrun/datastore/store_resources.py +2 -5
- mlrun/datastore/v3io.py +1 -2
- mlrun/db/__init__.py +4 -68
- mlrun/db/base.py +12 -0
- mlrun/db/factory.py +65 -0
- mlrun/db/httpdb.py +175 -20
- mlrun/db/nopdb.py +4 -2
- mlrun/execution.py +4 -2
- mlrun/feature_store/__init__.py +1 -0
- mlrun/feature_store/api.py +1 -2
- mlrun/feature_store/common.py +2 -1
- mlrun/feature_store/feature_set.py +1 -11
- mlrun/feature_store/feature_vector.py +340 -2
- mlrun/feature_store/ingestion.py +5 -10
- mlrun/feature_store/retrieval/base.py +118 -104
- mlrun/feature_store/retrieval/dask_merger.py +17 -10
- mlrun/feature_store/retrieval/job.py +4 -1
- mlrun/feature_store/retrieval/local_merger.py +18 -18
- mlrun/feature_store/retrieval/spark_merger.py +21 -14
- mlrun/feature_store/retrieval/storey_merger.py +22 -16
- mlrun/kfpops.py +3 -9
- mlrun/launcher/base.py +57 -53
- mlrun/launcher/client.py +5 -4
- mlrun/launcher/factory.py +24 -13
- mlrun/launcher/local.py +6 -6
- mlrun/launcher/remote.py +4 -4
- mlrun/lists.py +0 -11
- mlrun/model.py +11 -17
- mlrun/model_monitoring/__init__.py +2 -22
- mlrun/model_monitoring/features_drift_table.py +1 -1
- mlrun/model_monitoring/helpers.py +22 -210
- mlrun/model_monitoring/model_endpoint.py +1 -1
- mlrun/model_monitoring/model_monitoring_batch.py +127 -50
- mlrun/model_monitoring/prometheus.py +219 -0
- mlrun/model_monitoring/stores/__init__.py +16 -11
- mlrun/model_monitoring/stores/kv_model_endpoint_store.py +95 -23
- mlrun/model_monitoring/stores/models/mysql.py +47 -29
- mlrun/model_monitoring/stores/models/sqlite.py +47 -29
- mlrun/model_monitoring/stores/sql_model_endpoint_store.py +31 -19
- mlrun/model_monitoring/{stream_processing_fs.py → stream_processing.py} +206 -64
- mlrun/model_monitoring/tracking_policy.py +104 -0
- mlrun/package/packager.py +6 -8
- mlrun/package/packagers/default_packager.py +121 -10
- mlrun/package/packagers/numpy_packagers.py +1 -1
- mlrun/platforms/__init__.py +0 -2
- mlrun/platforms/iguazio.py +0 -56
- mlrun/projects/pipelines.py +53 -159
- mlrun/projects/project.py +10 -37
- mlrun/render.py +1 -1
- mlrun/run.py +8 -124
- mlrun/runtimes/__init__.py +6 -42
- mlrun/runtimes/base.py +29 -1249
- mlrun/runtimes/daskjob.py +2 -198
- mlrun/runtimes/funcdoc.py +0 -9
- mlrun/runtimes/function.py +25 -29
- mlrun/runtimes/kubejob.py +5 -29
- mlrun/runtimes/local.py +1 -1
- mlrun/runtimes/mpijob/__init__.py +2 -2
- mlrun/runtimes/mpijob/abstract.py +10 -1
- mlrun/runtimes/mpijob/v1.py +0 -76
- mlrun/runtimes/mpijob/v1alpha1.py +1 -74
- mlrun/runtimes/nuclio.py +3 -2
- mlrun/runtimes/pod.py +28 -18
- mlrun/runtimes/remotesparkjob.py +1 -15
- mlrun/runtimes/serving.py +14 -6
- mlrun/runtimes/sparkjob/__init__.py +0 -1
- mlrun/runtimes/sparkjob/abstract.py +4 -131
- mlrun/runtimes/utils.py +0 -26
- mlrun/serving/routers.py +7 -7
- mlrun/serving/server.py +11 -8
- mlrun/serving/states.py +7 -1
- mlrun/serving/v2_serving.py +6 -6
- mlrun/utils/helpers.py +23 -42
- mlrun/utils/notifications/notification/__init__.py +4 -0
- mlrun/utils/notifications/notification/webhook.py +61 -0
- mlrun/utils/notifications/notification_pusher.py +5 -25
- mlrun/utils/regex.py +7 -2
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.4.0rc25.dist-info → mlrun-1.5.0rc2.dist-info}/METADATA +26 -25
- {mlrun-1.4.0rc25.dist-info → mlrun-1.5.0rc2.dist-info}/RECORD +180 -158
- {mlrun-1.4.0rc25.dist-info → mlrun-1.5.0rc2.dist-info}/WHEEL +1 -1
- mlrun/mlutils/data.py +0 -160
- mlrun/mlutils/models.py +0 -78
- mlrun/mlutils/plots.py +0 -902
- mlrun/utils/model_monitoring.py +0 -249
- /mlrun/{api/db/sqldb/session.py → common/db/sql_session.py} +0 -0
- {mlrun-1.4.0rc25.dist-info → mlrun-1.5.0rc2.dist-info}/LICENSE +0 -0
- {mlrun-1.4.0rc25.dist-info → mlrun-1.5.0rc2.dist-info}/entry_points.txt +0 -0
- {mlrun-1.4.0rc25.dist-info → mlrun-1.5.0rc2.dist-info}/top_level.txt +0 -0
mlrun/mlutils/data.py
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
# Copyright 2023 Iguazio
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
#
|
|
15
|
-
from typing import Union
|
|
16
|
-
|
|
17
|
-
import pandas as pd
|
|
18
|
-
from deprecated import deprecated
|
|
19
|
-
from sklearn.model_selection import train_test_split
|
|
20
|
-
|
|
21
|
-
from ..datastore import DataItem
|
|
22
|
-
|
|
23
|
-
# TODO: remove mlutils in 1.5.0
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
@deprecated(
|
|
27
|
-
version="1.3.0",
|
|
28
|
-
reason="'mlrun.mlutils' will be removed in 1.5.0, use 'mlrun.framework' instead",
|
|
29
|
-
category=FutureWarning,
|
|
30
|
-
)
|
|
31
|
-
def get_sample(
|
|
32
|
-
src: Union[DataItem, pd.core.frame.DataFrame], sample: int, label: str, reader=None
|
|
33
|
-
):
|
|
34
|
-
"""generate data sample to be split (candidate for mlrun)
|
|
35
|
-
|
|
36
|
-
Return features matrix and header (x), and labels (y)
|
|
37
|
-
:param src: data artifact
|
|
38
|
-
:param sample: sample size from data source, use negative
|
|
39
|
-
integers to sample randomly, positive to
|
|
40
|
-
sample consecutively from the first row
|
|
41
|
-
:param label: label column title
|
|
42
|
-
"""
|
|
43
|
-
if type(src) == pd.core.frame.DataFrame:
|
|
44
|
-
table = src
|
|
45
|
-
else:
|
|
46
|
-
table = src.as_df()
|
|
47
|
-
|
|
48
|
-
# get sample
|
|
49
|
-
if (sample == -1) or (sample >= 1):
|
|
50
|
-
# get all rows, or contiguous sample starting at row 1.
|
|
51
|
-
raw = table.dropna()
|
|
52
|
-
labels = _get_label_from_raw(raw, label)
|
|
53
|
-
raw = raw.iloc[:sample, :]
|
|
54
|
-
labels = labels.iloc[:sample]
|
|
55
|
-
else:
|
|
56
|
-
# grab a random sample
|
|
57
|
-
raw = table.dropna().sample(sample * -1)
|
|
58
|
-
labels = _get_label_from_raw(raw, label)
|
|
59
|
-
|
|
60
|
-
return raw, labels, raw.columns.values
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def _get_label_from_raw(raw, label):
|
|
64
|
-
"""
|
|
65
|
-
Just a stupid wrapper so that nice error will be raised when users give wrong label
|
|
66
|
-
"""
|
|
67
|
-
if label not in raw:
|
|
68
|
-
raise ValueError(f"Specified label could not be found: {label}")
|
|
69
|
-
return raw.pop(label)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
@deprecated(
|
|
73
|
-
version="1.3.0",
|
|
74
|
-
reason="'mlrun.mlutils' will be removed in 1.5.0, use 'mlrun.framework' instead",
|
|
75
|
-
category=FutureWarning,
|
|
76
|
-
)
|
|
77
|
-
def get_splits(
|
|
78
|
-
raw,
|
|
79
|
-
labels,
|
|
80
|
-
n_ways: int = 3,
|
|
81
|
-
test_size: float = 0.15,
|
|
82
|
-
valid_size: float = 0.30,
|
|
83
|
-
label_names: list = ["labels"],
|
|
84
|
-
random_state: int = 1,
|
|
85
|
-
):
|
|
86
|
-
"""generate train and test sets (candidate for mlrun)
|
|
87
|
-
cross validation:
|
|
88
|
-
1. cut out a test set
|
|
89
|
-
2a. use the training set in a cross validation scheme, or
|
|
90
|
-
2b. make another split to generate a validation set
|
|
91
|
-
|
|
92
|
-
2 parts (n_ways=2): train and test set only
|
|
93
|
-
3 parts (n_ways=3): train, validation and test set
|
|
94
|
-
|
|
95
|
-
:param raw: dataframe or numpy array of raw features
|
|
96
|
-
:param labels: dataframe or numpy array of raw labels
|
|
97
|
-
:param n_ways: (3) split data into 2 or 3 parts
|
|
98
|
-
:param test_size: proportion of raw data to set asid as test data
|
|
99
|
-
:param valid_size: proportion of remaining data to be set as validation
|
|
100
|
-
:param label_names: label names
|
|
101
|
-
:param random_state: (1) random number seed
|
|
102
|
-
"""
|
|
103
|
-
x, xte, y, yte = train_test_split(
|
|
104
|
-
raw, labels, test_size=test_size, random_state=random_state
|
|
105
|
-
)
|
|
106
|
-
if n_ways == 2:
|
|
107
|
-
return (x, y), (xte, yte)
|
|
108
|
-
elif n_ways == 3:
|
|
109
|
-
xtr, xva, ytr, yva = train_test_split(
|
|
110
|
-
x, y, train_size=1 - valid_size, random_state=random_state
|
|
111
|
-
)
|
|
112
|
-
return (xtr, ytr), (xva, yva), (xte, yte)
|
|
113
|
-
else:
|
|
114
|
-
raise Exception("n_ways must be in the range [2,3]")
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
@deprecated(
|
|
118
|
-
version="1.3.0",
|
|
119
|
-
reason="'mlrun.mlutils' will be removed in 1.5.0, use 'mlrun.framework' instead",
|
|
120
|
-
category=FutureWarning,
|
|
121
|
-
)
|
|
122
|
-
def save_test_set(
|
|
123
|
-
context,
|
|
124
|
-
data: dict,
|
|
125
|
-
header: list,
|
|
126
|
-
label: str = "labels",
|
|
127
|
-
file_ext: str = "parquet",
|
|
128
|
-
index: bool = False,
|
|
129
|
-
debug: bool = False,
|
|
130
|
-
):
|
|
131
|
-
"""log a held out test set
|
|
132
|
-
:param context: the function execution context
|
|
133
|
-
:param data: dict with keys 'xtest'. 'ytest', and optionally
|
|
134
|
-
'xcal', 'ycal' if n_ways=4 in `get_splits`
|
|
135
|
-
:param header: ([])features header if required
|
|
136
|
-
:param label: ("labels") name of label column
|
|
137
|
-
:param file_ext: format of test set file
|
|
138
|
-
:param index: preserve index column
|
|
139
|
-
:param debug: (False)
|
|
140
|
-
"""
|
|
141
|
-
|
|
142
|
-
if all(x in data.keys() for x in ["xtest", "ytest"]):
|
|
143
|
-
test_set = pd.concat(
|
|
144
|
-
[
|
|
145
|
-
pd.DataFrame(data=data["xtest"], columns=header),
|
|
146
|
-
pd.DataFrame(data=data["ytest"].values, columns=[label]),
|
|
147
|
-
],
|
|
148
|
-
axis=1,
|
|
149
|
-
)
|
|
150
|
-
context.log_dataset("test_set", df=test_set, format=file_ext, index=index)
|
|
151
|
-
|
|
152
|
-
if all(x in data.keys() for x in ["xcal", "ycal"]):
|
|
153
|
-
cal_set = pd.concat(
|
|
154
|
-
[
|
|
155
|
-
pd.DataFrame(data=data["xcal"], columns=header),
|
|
156
|
-
pd.DataFrame(data=data["ycal"].values, columns=[label]),
|
|
157
|
-
],
|
|
158
|
-
axis=1,
|
|
159
|
-
)
|
|
160
|
-
context.log_dataset("calibration_set", df=cal_set, format=file_ext, index=index)
|
mlrun/mlutils/models.py
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
# Copyright 2023 Iguazio
|
|
2
|
-
#
|
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
# you may not use this file except in compliance with the License.
|
|
5
|
-
# You may obtain a copy of the License at
|
|
6
|
-
#
|
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
#
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
#
|
|
15
|
-
import json
|
|
16
|
-
from importlib import import_module
|
|
17
|
-
from inspect import _empty, signature
|
|
18
|
-
|
|
19
|
-
from deprecated import deprecated
|
|
20
|
-
|
|
21
|
-
# for backwards compatibility - can be removed when we separate the hub branches for 0.6.x ad 0.5.x
|
|
22
|
-
from .plots import eval_class_model, eval_model_v2 # noqa: F401
|
|
23
|
-
|
|
24
|
-
# TODO: remove mlutils in 1.5.0
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@deprecated(
|
|
28
|
-
version="1.3.0",
|
|
29
|
-
reason="'mlrun.mlutils' will be removed in 1.5.0, use 'mlrun.framework' instead",
|
|
30
|
-
category=FutureWarning,
|
|
31
|
-
)
|
|
32
|
-
def get_class_fit(module_pkg_class: str):
|
|
33
|
-
"""generate a model config
|
|
34
|
-
:param module_pkg_class: str description of model, e.g.
|
|
35
|
-
`sklearn.ensemble.RandomForestClassifier`
|
|
36
|
-
"""
|
|
37
|
-
splits = module_pkg_class.split(".")
|
|
38
|
-
model_ = getattr(import_module(".".join(splits[:-1])), splits[-1])
|
|
39
|
-
f = list(signature(model_().fit).parameters.items())
|
|
40
|
-
d = {}
|
|
41
|
-
for i in range(len(f)):
|
|
42
|
-
d.update({f[i][0]: None if f[i][1].default is _empty else f[i][1].default})
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
"CLASS": model_().get_params(),
|
|
46
|
-
"FIT": d,
|
|
47
|
-
"META": {
|
|
48
|
-
"pkg_version": import_module(splits[0]).__version__,
|
|
49
|
-
"class": module_pkg_class,
|
|
50
|
-
},
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
@deprecated(
|
|
55
|
-
version="1.3.0",
|
|
56
|
-
reason="'mlrun.mlutils' will be removed in 1.5.0, use 'mlrun.framework' instead",
|
|
57
|
-
category=FutureWarning,
|
|
58
|
-
)
|
|
59
|
-
def gen_sklearn_model(model_pkg, skparams):
|
|
60
|
-
"""generate an sklearn model configuration
|
|
61
|
-
|
|
62
|
-
input can be either a "package.module.class" or
|
|
63
|
-
a json file
|
|
64
|
-
"""
|
|
65
|
-
if model_pkg.endswith("json"):
|
|
66
|
-
model_config = json.load(open(model_pkg, "r"))
|
|
67
|
-
else:
|
|
68
|
-
model_config = get_class_fit(model_pkg)
|
|
69
|
-
|
|
70
|
-
# we used to use skparams as is (without .items()) so supporting both cases for backwards compatibility
|
|
71
|
-
skparams = skparams.items() if isinstance(skparams, dict) else skparams
|
|
72
|
-
for k, v in skparams:
|
|
73
|
-
if k.startswith("CLASS_"):
|
|
74
|
-
model_config["CLASS"][k[6:]] = v
|
|
75
|
-
if k.startswith("FIT_"):
|
|
76
|
-
model_config["FIT"][k[4:]] = v
|
|
77
|
-
|
|
78
|
-
return model_config
|