mlrun 1.7.2rc3__py3-none-any.whl → 1.8.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.
Potentially problematic release.
This version of mlrun might be problematic. Click here for more details.
- mlrun/__init__.py +26 -22
- mlrun/__main__.py +15 -16
- mlrun/alerts/alert.py +150 -15
- mlrun/api/schemas/__init__.py +1 -9
- mlrun/artifacts/__init__.py +2 -3
- mlrun/artifacts/base.py +62 -19
- mlrun/artifacts/dataset.py +17 -17
- mlrun/artifacts/document.py +454 -0
- mlrun/artifacts/manager.py +28 -18
- mlrun/artifacts/model.py +91 -59
- mlrun/artifacts/plots.py +2 -2
- mlrun/common/constants.py +8 -0
- mlrun/common/formatters/__init__.py +1 -0
- mlrun/common/formatters/artifact.py +1 -1
- mlrun/common/formatters/feature_set.py +2 -0
- mlrun/common/formatters/function.py +1 -0
- mlrun/{model_monitoring/db/stores/v3io_kv/__init__.py → common/formatters/model_endpoint.py} +17 -0
- mlrun/common/formatters/pipeline.py +1 -2
- mlrun/common/formatters/project.py +9 -0
- mlrun/common/model_monitoring/__init__.py +0 -5
- mlrun/common/model_monitoring/helpers.py +12 -62
- mlrun/common/runtimes/constants.py +25 -4
- mlrun/common/schemas/__init__.py +9 -5
- mlrun/common/schemas/alert.py +114 -19
- mlrun/common/schemas/api_gateway.py +3 -3
- mlrun/common/schemas/artifact.py +22 -9
- mlrun/common/schemas/auth.py +8 -4
- mlrun/common/schemas/background_task.py +7 -7
- mlrun/common/schemas/client_spec.py +4 -4
- mlrun/common/schemas/clusterization_spec.py +2 -2
- mlrun/common/schemas/common.py +53 -3
- mlrun/common/schemas/constants.py +15 -0
- mlrun/common/schemas/datastore_profile.py +1 -1
- mlrun/common/schemas/feature_store.py +9 -9
- mlrun/common/schemas/frontend_spec.py +4 -4
- mlrun/common/schemas/function.py +10 -10
- mlrun/common/schemas/hub.py +1 -1
- mlrun/common/schemas/k8s.py +3 -3
- mlrun/common/schemas/memory_reports.py +3 -3
- mlrun/common/schemas/model_monitoring/__init__.py +4 -8
- mlrun/common/schemas/model_monitoring/constants.py +127 -46
- mlrun/common/schemas/model_monitoring/grafana.py +18 -12
- mlrun/common/schemas/model_monitoring/model_endpoints.py +154 -160
- mlrun/common/schemas/notification.py +24 -3
- mlrun/common/schemas/object.py +1 -1
- mlrun/common/schemas/pagination.py +4 -4
- mlrun/common/schemas/partition.py +142 -0
- mlrun/common/schemas/pipeline.py +3 -3
- mlrun/common/schemas/project.py +26 -18
- mlrun/common/schemas/runs.py +3 -3
- mlrun/common/schemas/runtime_resource.py +5 -5
- mlrun/common/schemas/schedule.py +1 -1
- mlrun/common/schemas/secret.py +1 -1
- mlrun/{model_monitoring/db/stores/sqldb/__init__.py → common/schemas/serving.py} +10 -1
- mlrun/common/schemas/tag.py +3 -3
- mlrun/common/schemas/workflow.py +6 -5
- mlrun/common/types.py +1 -0
- mlrun/config.py +157 -89
- mlrun/data_types/__init__.py +5 -3
- mlrun/data_types/infer.py +13 -3
- mlrun/data_types/spark.py +2 -1
- mlrun/datastore/__init__.py +59 -18
- mlrun/datastore/alibaba_oss.py +4 -1
- mlrun/datastore/azure_blob.py +4 -1
- mlrun/datastore/base.py +19 -24
- mlrun/datastore/datastore.py +10 -4
- mlrun/datastore/datastore_profile.py +178 -45
- mlrun/datastore/dbfs_store.py +4 -1
- mlrun/datastore/filestore.py +4 -1
- mlrun/datastore/google_cloud_storage.py +4 -1
- mlrun/datastore/hdfs.py +4 -1
- mlrun/datastore/inmem.py +4 -1
- mlrun/datastore/redis.py +4 -1
- mlrun/datastore/s3.py +14 -3
- mlrun/datastore/sources.py +89 -92
- mlrun/datastore/store_resources.py +7 -4
- mlrun/datastore/storeytargets.py +51 -16
- mlrun/datastore/targets.py +38 -31
- mlrun/datastore/utils.py +87 -4
- mlrun/datastore/v3io.py +4 -1
- mlrun/datastore/vectorstore.py +291 -0
- mlrun/datastore/wasbfs/fs.py +13 -12
- mlrun/db/base.py +286 -100
- mlrun/db/httpdb.py +1562 -490
- mlrun/db/nopdb.py +250 -83
- mlrun/errors.py +6 -2
- mlrun/execution.py +194 -50
- mlrun/feature_store/__init__.py +2 -10
- mlrun/feature_store/api.py +20 -458
- mlrun/feature_store/common.py +9 -9
- mlrun/feature_store/feature_set.py +20 -18
- mlrun/feature_store/feature_vector.py +105 -479
- mlrun/feature_store/feature_vector_utils.py +466 -0
- mlrun/feature_store/retrieval/base.py +15 -11
- mlrun/feature_store/retrieval/job.py +2 -1
- mlrun/feature_store/retrieval/storey_merger.py +1 -1
- mlrun/feature_store/steps.py +3 -3
- mlrun/features.py +30 -13
- mlrun/frameworks/__init__.py +1 -2
- mlrun/frameworks/_common/__init__.py +1 -2
- mlrun/frameworks/_common/artifacts_library.py +2 -2
- mlrun/frameworks/_common/mlrun_interface.py +10 -6
- mlrun/frameworks/_common/model_handler.py +31 -31
- mlrun/frameworks/_common/producer.py +3 -1
- mlrun/frameworks/_dl_common/__init__.py +1 -2
- mlrun/frameworks/_dl_common/loggers/__init__.py +1 -2
- mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +4 -4
- mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +3 -3
- mlrun/frameworks/_ml_common/__init__.py +1 -2
- mlrun/frameworks/_ml_common/loggers/__init__.py +1 -2
- mlrun/frameworks/_ml_common/model_handler.py +21 -21
- mlrun/frameworks/_ml_common/plans/__init__.py +1 -2
- mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +3 -1
- mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
- mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
- mlrun/frameworks/auto_mlrun/__init__.py +1 -2
- mlrun/frameworks/auto_mlrun/auto_mlrun.py +22 -15
- mlrun/frameworks/huggingface/__init__.py +1 -2
- mlrun/frameworks/huggingface/model_server.py +9 -9
- mlrun/frameworks/lgbm/__init__.py +47 -44
- mlrun/frameworks/lgbm/callbacks/__init__.py +1 -2
- mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -2
- mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -2
- mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -2
- mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +5 -5
- mlrun/frameworks/lgbm/model_handler.py +15 -11
- mlrun/frameworks/lgbm/model_server.py +11 -7
- mlrun/frameworks/lgbm/utils.py +2 -2
- mlrun/frameworks/onnx/__init__.py +1 -2
- mlrun/frameworks/onnx/dataset.py +3 -3
- mlrun/frameworks/onnx/mlrun_interface.py +2 -2
- mlrun/frameworks/onnx/model_handler.py +7 -5
- mlrun/frameworks/onnx/model_server.py +8 -6
- mlrun/frameworks/parallel_coordinates.py +11 -11
- mlrun/frameworks/pytorch/__init__.py +22 -23
- mlrun/frameworks/pytorch/callbacks/__init__.py +1 -2
- mlrun/frameworks/pytorch/callbacks/callback.py +2 -1
- mlrun/frameworks/pytorch/callbacks/logging_callback.py +15 -8
- mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +19 -12
- mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +22 -15
- mlrun/frameworks/pytorch/callbacks_handler.py +36 -30
- mlrun/frameworks/pytorch/mlrun_interface.py +17 -17
- mlrun/frameworks/pytorch/model_handler.py +21 -17
- mlrun/frameworks/pytorch/model_server.py +13 -9
- mlrun/frameworks/sklearn/__init__.py +19 -18
- mlrun/frameworks/sklearn/estimator.py +2 -2
- mlrun/frameworks/sklearn/metric.py +3 -3
- mlrun/frameworks/sklearn/metrics_library.py +8 -6
- mlrun/frameworks/sklearn/mlrun_interface.py +3 -2
- mlrun/frameworks/sklearn/model_handler.py +4 -3
- mlrun/frameworks/tf_keras/__init__.py +11 -12
- mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -2
- mlrun/frameworks/tf_keras/callbacks/logging_callback.py +17 -14
- mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +15 -12
- mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +21 -18
- mlrun/frameworks/tf_keras/model_handler.py +17 -13
- mlrun/frameworks/tf_keras/model_server.py +12 -8
- mlrun/frameworks/xgboost/__init__.py +19 -18
- mlrun/frameworks/xgboost/model_handler.py +13 -9
- mlrun/k8s_utils.py +2 -5
- mlrun/launcher/base.py +3 -4
- mlrun/launcher/client.py +2 -2
- mlrun/launcher/local.py +6 -2
- mlrun/launcher/remote.py +1 -1
- mlrun/lists.py +8 -4
- mlrun/model.py +132 -46
- mlrun/model_monitoring/__init__.py +3 -5
- mlrun/model_monitoring/api.py +113 -98
- mlrun/model_monitoring/applications/__init__.py +0 -5
- mlrun/model_monitoring/applications/_application_steps.py +81 -50
- mlrun/model_monitoring/applications/base.py +467 -14
- mlrun/model_monitoring/applications/context.py +212 -134
- mlrun/model_monitoring/{db/stores/base → applications/evidently}/__init__.py +6 -2
- mlrun/model_monitoring/applications/evidently/base.py +146 -0
- mlrun/model_monitoring/applications/histogram_data_drift.py +89 -56
- mlrun/model_monitoring/applications/results.py +67 -15
- mlrun/model_monitoring/controller.py +701 -315
- mlrun/model_monitoring/db/__init__.py +0 -2
- mlrun/model_monitoring/db/_schedules.py +242 -0
- mlrun/model_monitoring/db/_stats.py +189 -0
- mlrun/model_monitoring/db/tsdb/__init__.py +33 -22
- mlrun/model_monitoring/db/tsdb/base.py +243 -49
- mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +76 -36
- mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connection.py +213 -0
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +534 -88
- mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
- mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +436 -106
- mlrun/model_monitoring/helpers.py +356 -114
- mlrun/model_monitoring/stream_processing.py +190 -345
- mlrun/model_monitoring/tracking_policy.py +11 -4
- mlrun/model_monitoring/writer.py +49 -90
- mlrun/package/__init__.py +3 -6
- mlrun/package/context_handler.py +2 -2
- mlrun/package/packager.py +12 -9
- mlrun/package/packagers/__init__.py +0 -2
- mlrun/package/packagers/default_packager.py +14 -11
- mlrun/package/packagers/numpy_packagers.py +16 -7
- mlrun/package/packagers/pandas_packagers.py +18 -18
- mlrun/package/packagers/python_standard_library_packagers.py +25 -11
- mlrun/package/packagers_manager.py +35 -32
- mlrun/package/utils/__init__.py +0 -3
- mlrun/package/utils/_pickler.py +6 -6
- mlrun/platforms/__init__.py +47 -16
- mlrun/platforms/iguazio.py +4 -1
- mlrun/projects/operations.py +30 -30
- mlrun/projects/pipelines.py +116 -47
- mlrun/projects/project.py +1292 -329
- mlrun/render.py +5 -9
- mlrun/run.py +57 -14
- mlrun/runtimes/__init__.py +1 -3
- mlrun/runtimes/base.py +30 -22
- mlrun/runtimes/daskjob.py +9 -9
- mlrun/runtimes/databricks_job/databricks_runtime.py +6 -5
- mlrun/runtimes/function_reference.py +5 -2
- mlrun/runtimes/generators.py +3 -2
- mlrun/runtimes/kubejob.py +6 -7
- mlrun/runtimes/mounts.py +574 -0
- mlrun/runtimes/mpijob/__init__.py +0 -2
- mlrun/runtimes/mpijob/abstract.py +7 -6
- mlrun/runtimes/nuclio/api_gateway.py +7 -7
- mlrun/runtimes/nuclio/application/application.py +11 -13
- mlrun/runtimes/nuclio/application/reverse_proxy.go +66 -64
- mlrun/runtimes/nuclio/function.py +127 -70
- mlrun/runtimes/nuclio/serving.py +105 -37
- mlrun/runtimes/pod.py +159 -54
- mlrun/runtimes/remotesparkjob.py +3 -2
- mlrun/runtimes/sparkjob/__init__.py +0 -2
- mlrun/runtimes/sparkjob/spark3job.py +22 -12
- mlrun/runtimes/utils.py +7 -6
- mlrun/secrets.py +2 -2
- mlrun/serving/__init__.py +8 -0
- mlrun/serving/merger.py +7 -5
- mlrun/serving/remote.py +35 -22
- mlrun/serving/routers.py +186 -240
- mlrun/serving/server.py +41 -10
- mlrun/serving/states.py +432 -118
- mlrun/serving/utils.py +13 -2
- mlrun/serving/v1_serving.py +3 -2
- mlrun/serving/v2_serving.py +161 -203
- mlrun/track/__init__.py +1 -1
- mlrun/track/tracker.py +2 -2
- mlrun/track/trackers/mlflow_tracker.py +6 -5
- mlrun/utils/async_http.py +35 -22
- mlrun/utils/clones.py +7 -4
- mlrun/utils/helpers.py +511 -58
- mlrun/utils/logger.py +119 -13
- mlrun/utils/notifications/notification/__init__.py +22 -19
- mlrun/utils/notifications/notification/base.py +39 -15
- mlrun/utils/notifications/notification/console.py +6 -6
- mlrun/utils/notifications/notification/git.py +11 -11
- mlrun/utils/notifications/notification/ipython.py +10 -9
- mlrun/utils/notifications/notification/mail.py +176 -0
- mlrun/utils/notifications/notification/slack.py +16 -8
- mlrun/utils/notifications/notification/webhook.py +24 -8
- mlrun/utils/notifications/notification_pusher.py +191 -200
- mlrun/utils/regex.py +12 -2
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0.dist-info}/METADATA +81 -54
- mlrun-1.8.0.dist-info/RECORD +351 -0
- {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0.dist-info}/WHEEL +1 -1
- mlrun/model_monitoring/applications/evidently_base.py +0 -137
- mlrun/model_monitoring/db/stores/__init__.py +0 -136
- mlrun/model_monitoring/db/stores/base/store.py +0 -213
- mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -71
- mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -190
- mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +0 -103
- mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -40
- mlrun/model_monitoring/db/stores/sqldb/sql_store.py +0 -659
- mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +0 -726
- mlrun/model_monitoring/model_endpoint.py +0 -118
- mlrun-1.7.2rc3.dist-info/RECORD +0 -351
- {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0.dist-info}/entry_points.txt +0 -0
- {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0.dist-info/licenses}/LICENSE +0 -0
- {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0.dist-info}/top_level.txt +0 -0
mlrun/execution.py
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
import logging
|
|
16
16
|
import os
|
|
17
17
|
import uuid
|
|
18
|
+
import warnings
|
|
18
19
|
from copy import deepcopy
|
|
19
|
-
from typing import Union
|
|
20
|
+
from typing import Optional, Union, cast
|
|
20
21
|
|
|
21
22
|
import numpy as np
|
|
22
23
|
import yaml
|
|
@@ -25,17 +26,23 @@ from dateutil import parser
|
|
|
25
26
|
import mlrun
|
|
26
27
|
import mlrun.common.constants as mlrun_constants
|
|
27
28
|
import mlrun.common.formatters
|
|
28
|
-
from mlrun.artifacts import
|
|
29
|
+
from mlrun.artifacts import (
|
|
30
|
+
Artifact,
|
|
31
|
+
DatasetArtifact,
|
|
32
|
+
DocumentArtifact,
|
|
33
|
+
DocumentLoaderSpec,
|
|
34
|
+
ModelArtifact,
|
|
35
|
+
)
|
|
29
36
|
from mlrun.datastore.store_resources import get_store_resource
|
|
30
37
|
from mlrun.errors import MLRunInvalidArgumentError
|
|
31
38
|
|
|
32
|
-
from .artifacts import DatasetArtifact
|
|
33
39
|
from .artifacts.manager import ArtifactManager, dict_to_artifact, extend_artifact_path
|
|
34
40
|
from .datastore import store_manager
|
|
35
41
|
from .features import Feature
|
|
36
42
|
from .model import HyperParamOptions
|
|
37
43
|
from .secrets import SecretsStore
|
|
38
44
|
from .utils import (
|
|
45
|
+
Logger,
|
|
39
46
|
RunKeys,
|
|
40
47
|
dict_to_json,
|
|
41
48
|
dict_to_yaml,
|
|
@@ -152,7 +159,7 @@ class MLClientCtx:
|
|
|
152
159
|
return self._project
|
|
153
160
|
|
|
154
161
|
@property
|
|
155
|
-
def logger(self):
|
|
162
|
+
def logger(self) -> Logger:
|
|
156
163
|
"""Built-in logger interface
|
|
157
164
|
|
|
158
165
|
Example::
|
|
@@ -194,6 +201,11 @@ class MLClientCtx:
|
|
|
194
201
|
"""Dictionary of artifacts (read-only)"""
|
|
195
202
|
return deepcopy(self._artifacts_manager.artifact_list())
|
|
196
203
|
|
|
204
|
+
@property
|
|
205
|
+
def artifact_uris(self):
|
|
206
|
+
"""Dictionary of artifact URIs (read-only)"""
|
|
207
|
+
return deepcopy(self._artifacts_manager.artifact_uris)
|
|
208
|
+
|
|
197
209
|
@property
|
|
198
210
|
def in_path(self):
|
|
199
211
|
"""Default input path for data objects"""
|
|
@@ -296,7 +308,7 @@ class MLClientCtx:
|
|
|
296
308
|
)
|
|
297
309
|
self._parent.log_iteration_results(self._iteration, None, self.to_dict())
|
|
298
310
|
|
|
299
|
-
def get_store_resource(self, url, secrets: dict = None):
|
|
311
|
+
def get_store_resource(self, url, secrets: Optional[dict] = None):
|
|
300
312
|
"""Get mlrun data resource (feature set/vector, artifact, item) from url.
|
|
301
313
|
|
|
302
314
|
Example::
|
|
@@ -317,7 +329,7 @@ class MLClientCtx:
|
|
|
317
329
|
data_store_secrets=secrets,
|
|
318
330
|
)
|
|
319
331
|
|
|
320
|
-
def get_dataitem(self, url, secrets: dict = None):
|
|
332
|
+
def get_dataitem(self, url, secrets: Optional[dict] = None):
|
|
321
333
|
"""Get mlrun dataitem from url
|
|
322
334
|
|
|
323
335
|
Example::
|
|
@@ -425,8 +437,11 @@ class MLClientCtx:
|
|
|
425
437
|
self._results = status.get("results", self._results)
|
|
426
438
|
for artifact in status.get("artifacts", []):
|
|
427
439
|
artifact_obj = dict_to_artifact(artifact)
|
|
428
|
-
key =
|
|
429
|
-
|
|
440
|
+
self._artifacts_manager.artifact_uris[artifact_obj.key] = (
|
|
441
|
+
artifact_obj.uri
|
|
442
|
+
)
|
|
443
|
+
for key, uri in status.get("artifact_uris", {}).items():
|
|
444
|
+
self._artifacts_manager.artifact_uris[key] = uri
|
|
430
445
|
self._state = status.get("state", self._state)
|
|
431
446
|
|
|
432
447
|
# No need to store the run for every worker
|
|
@@ -486,11 +501,11 @@ class MLClientCtx:
|
|
|
486
501
|
return default
|
|
487
502
|
return self._parameters[key]
|
|
488
503
|
|
|
489
|
-
def get_project_object(self):
|
|
504
|
+
def get_project_object(self) -> Optional["mlrun.MlrunProject"]:
|
|
490
505
|
"""
|
|
491
506
|
Get the MLRun project object by the project name set in the context.
|
|
492
507
|
|
|
493
|
-
:
|
|
508
|
+
:returns: The project object or None if it couldn't be retrieved.
|
|
494
509
|
"""
|
|
495
510
|
return self._load_project_object()
|
|
496
511
|
|
|
@@ -573,22 +588,25 @@ class MLClientCtx:
|
|
|
573
588
|
"""Reserved for internal use"""
|
|
574
589
|
|
|
575
590
|
if best:
|
|
591
|
+
# Recreate the best iteration context for the interface of getting its artifacts
|
|
592
|
+
best_context = MLClientCtx.from_dict(
|
|
593
|
+
task, store_run=False, include_status=True
|
|
594
|
+
)
|
|
576
595
|
self._results["best_iteration"] = best
|
|
577
|
-
for
|
|
578
|
-
self._results[
|
|
579
|
-
for
|
|
580
|
-
self._artifacts_manager.
|
|
581
|
-
|
|
582
|
-
)
|
|
596
|
+
for key, result in best_context.results.items():
|
|
597
|
+
self._results[key] = result
|
|
598
|
+
for key, artifact_uri in best_context.artifact_uris.items():
|
|
599
|
+
self._artifacts_manager.artifact_uris[key] = artifact_uri
|
|
600
|
+
artifact = best_context.get_artifact(key)
|
|
583
601
|
self._artifacts_manager.link_artifact(
|
|
584
602
|
self.project,
|
|
585
603
|
self.name,
|
|
586
604
|
self.tag,
|
|
587
|
-
|
|
605
|
+
key,
|
|
588
606
|
self.iteration,
|
|
589
|
-
artifact
|
|
607
|
+
artifact.target_path,
|
|
608
|
+
db_key=artifact.db_key,
|
|
590
609
|
link_iteration=best,
|
|
591
|
-
db_key=artifact["spec"]["db_key"],
|
|
592
610
|
)
|
|
593
611
|
|
|
594
612
|
if summary is not None:
|
|
@@ -611,7 +629,7 @@ class MLClientCtx:
|
|
|
611
629
|
format=None,
|
|
612
630
|
db_key=None,
|
|
613
631
|
**kwargs,
|
|
614
|
-
):
|
|
632
|
+
) -> Artifact:
|
|
615
633
|
"""Log an output artifact and optionally upload it to datastore
|
|
616
634
|
|
|
617
635
|
Example::
|
|
@@ -679,9 +697,9 @@ class MLClientCtx:
|
|
|
679
697
|
db_key=None,
|
|
680
698
|
target_path="",
|
|
681
699
|
extra_data=None,
|
|
682
|
-
label_column: str = None,
|
|
700
|
+
label_column: Optional[str] = None,
|
|
683
701
|
**kwargs,
|
|
684
|
-
):
|
|
702
|
+
) -> DatasetArtifact:
|
|
685
703
|
"""Log a dataset artifact and optionally upload it to datastore
|
|
686
704
|
|
|
687
705
|
If the dataset exists with the same key and tag, it will be overwritten.
|
|
@@ -719,7 +737,7 @@ class MLClientCtx:
|
|
|
719
737
|
:param db_key: The key to use in the artifact DB table, by default its run name + '_' + key
|
|
720
738
|
db_key=False will not register it in the artifacts table
|
|
721
739
|
|
|
722
|
-
:returns:
|
|
740
|
+
:returns: Dataset artifact object
|
|
723
741
|
"""
|
|
724
742
|
ds = DatasetArtifact(
|
|
725
743
|
key,
|
|
@@ -732,16 +750,19 @@ class MLClientCtx:
|
|
|
732
750
|
**kwargs,
|
|
733
751
|
)
|
|
734
752
|
|
|
735
|
-
item =
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
753
|
+
item = cast(
|
|
754
|
+
DatasetArtifact,
|
|
755
|
+
self._artifacts_manager.log_artifact(
|
|
756
|
+
self,
|
|
757
|
+
ds,
|
|
758
|
+
local_path=local_path,
|
|
759
|
+
artifact_path=extend_artifact_path(artifact_path, self.artifact_path),
|
|
760
|
+
target_path=target_path,
|
|
761
|
+
tag=tag,
|
|
762
|
+
upload=upload,
|
|
763
|
+
db_key=db_key,
|
|
764
|
+
labels=labels,
|
|
765
|
+
),
|
|
745
766
|
)
|
|
746
767
|
self._update_run()
|
|
747
768
|
return item
|
|
@@ -760,16 +781,16 @@ class MLClientCtx:
|
|
|
760
781
|
artifact_path=None,
|
|
761
782
|
upload=True,
|
|
762
783
|
labels=None,
|
|
763
|
-
inputs: list[Feature] = None,
|
|
764
|
-
outputs: list[Feature] = None,
|
|
765
|
-
feature_vector: str = None,
|
|
766
|
-
feature_weights: list = None,
|
|
784
|
+
inputs: Optional[list[Feature]] = None,
|
|
785
|
+
outputs: Optional[list[Feature]] = None,
|
|
786
|
+
feature_vector: Optional[str] = None,
|
|
787
|
+
feature_weights: Optional[list] = None,
|
|
767
788
|
training_set=None,
|
|
768
|
-
label_column: Union[str, list] = None,
|
|
789
|
+
label_column: Optional[Union[str, list]] = None,
|
|
769
790
|
extra_data=None,
|
|
770
791
|
db_key=None,
|
|
771
792
|
**kwargs,
|
|
772
|
-
):
|
|
793
|
+
) -> ModelArtifact:
|
|
773
794
|
"""Log a model artifact and optionally upload it to datastore
|
|
774
795
|
|
|
775
796
|
Example::
|
|
@@ -788,7 +809,7 @@ class MLClientCtx:
|
|
|
788
809
|
:param key: Artifact key or artifact class ()
|
|
789
810
|
:param body: Will use the body as the artifact content
|
|
790
811
|
:param model_file: Path to the local model file we upload (see also model_dir)
|
|
791
|
-
or to a model file data url (e.g. http://host/path/model.pkl)
|
|
812
|
+
or to a model file data url (e.g. `http://host/path/model.pkl`)
|
|
792
813
|
:param model_dir: Path to the local dir holding the model file and extra files
|
|
793
814
|
:param artifact_path: Target artifact path (when not using the default)
|
|
794
815
|
to define a subpath under the default location use:
|
|
@@ -811,7 +832,7 @@ class MLClientCtx:
|
|
|
811
832
|
:param db_key: The key to use in the artifact DB table, by default its run name + '_' + key
|
|
812
833
|
db_key=False will not register it in the artifacts table
|
|
813
834
|
|
|
814
|
-
:returns:
|
|
835
|
+
:returns: Model artifact object
|
|
815
836
|
"""
|
|
816
837
|
|
|
817
838
|
if training_set is not None and inputs:
|
|
@@ -838,24 +859,140 @@ class MLClientCtx:
|
|
|
838
859
|
if training_set is not None:
|
|
839
860
|
model.infer_from_df(training_set, label_column)
|
|
840
861
|
|
|
862
|
+
item = cast(
|
|
863
|
+
ModelArtifact,
|
|
864
|
+
self._artifacts_manager.log_artifact(
|
|
865
|
+
self,
|
|
866
|
+
model,
|
|
867
|
+
artifact_path=extend_artifact_path(artifact_path, self.artifact_path),
|
|
868
|
+
tag=tag,
|
|
869
|
+
upload=upload,
|
|
870
|
+
db_key=db_key,
|
|
871
|
+
labels=labels,
|
|
872
|
+
),
|
|
873
|
+
)
|
|
874
|
+
self._update_run()
|
|
875
|
+
return item
|
|
876
|
+
|
|
877
|
+
def log_document(
|
|
878
|
+
self,
|
|
879
|
+
key: str = "",
|
|
880
|
+
tag: str = "",
|
|
881
|
+
local_path: str = "",
|
|
882
|
+
artifact_path: Optional[str] = None,
|
|
883
|
+
document_loader_spec: DocumentLoaderSpec = DocumentLoaderSpec(),
|
|
884
|
+
upload: Optional[bool] = False,
|
|
885
|
+
labels: Optional[dict[str, str]] = None,
|
|
886
|
+
target_path: Optional[str] = None,
|
|
887
|
+
db_key: Optional[str] = None,
|
|
888
|
+
**kwargs,
|
|
889
|
+
) -> DocumentArtifact:
|
|
890
|
+
"""
|
|
891
|
+
Log a document as an artifact.
|
|
892
|
+
|
|
893
|
+
:param key: Optional artifact key. If not provided, will be derived from local_path
|
|
894
|
+
or target_path using DocumentArtifact.key_from_source()
|
|
895
|
+
:param tag: Version tag
|
|
896
|
+
:param local_path: path to the local file we upload, will also be use
|
|
897
|
+
as the destination subpath (under "artifact_path")
|
|
898
|
+
:param artifact_path: Target artifact path (when not using the default)
|
|
899
|
+
to define a subpath under the default location use:
|
|
900
|
+
`artifact_path=context.artifact_subpath('data')`
|
|
901
|
+
:param document_loader_spec: Spec to use to load the artifact as langchain document.
|
|
902
|
+
|
|
903
|
+
By default, uses DocumentLoaderSpec() which initializes with:
|
|
904
|
+
|
|
905
|
+
* loader_class_name="langchain_community.document_loaders.TextLoader"
|
|
906
|
+
* src_name="file_path"
|
|
907
|
+
* kwargs=None
|
|
908
|
+
|
|
909
|
+
Can be customized for different document types, e.g.::
|
|
910
|
+
|
|
911
|
+
DocumentLoaderSpec(
|
|
912
|
+
loader_class_name="langchain_community.document_loaders.PDFLoader",
|
|
913
|
+
src_name="file_path",
|
|
914
|
+
kwargs={"extract_images": True}
|
|
915
|
+
)
|
|
916
|
+
:param upload: Whether to upload the artifact
|
|
917
|
+
:param labels: Key-value labels. A 'source' label is automatically added using either
|
|
918
|
+
local_path or target_path to facilitate easier document searching.
|
|
919
|
+
:param target_path: Path to the local file
|
|
920
|
+
:param db_key: The key to use in the artifact DB table, by default its run name + '_' + key
|
|
921
|
+
db_key=False will not register it in the artifacts table
|
|
922
|
+
:param kwargs: Additional keyword arguments
|
|
923
|
+
:return: DocumentArtifact object
|
|
924
|
+
|
|
925
|
+
Example:
|
|
926
|
+
>>> # Log a PDF document with custom loader
|
|
927
|
+
>>> project.log_document(
|
|
928
|
+
... local_path="path/to/doc.pdf",
|
|
929
|
+
... document_loader_spec=DocumentLoaderSpec(
|
|
930
|
+
... loader_class_name="langchain_community.document_loaders.PDFLoader",
|
|
931
|
+
... src_name="file_path",
|
|
932
|
+
... kwargs={"extract_images": True},
|
|
933
|
+
... ),
|
|
934
|
+
... )
|
|
935
|
+
"""
|
|
936
|
+
original_source = local_path or target_path
|
|
937
|
+
|
|
938
|
+
if not key and not original_source:
|
|
939
|
+
raise ValueError(
|
|
940
|
+
"Must provide either 'key' parameter or 'local_path'/'target_path' to derive the key from"
|
|
941
|
+
)
|
|
942
|
+
if not key:
|
|
943
|
+
key = DocumentArtifact.key_from_source(original_source)
|
|
944
|
+
|
|
945
|
+
doc_artifact = DocumentArtifact(
|
|
946
|
+
key=key,
|
|
947
|
+
original_source=original_source,
|
|
948
|
+
document_loader_spec=document_loader_spec,
|
|
949
|
+
collections=kwargs.pop("collections", None),
|
|
950
|
+
**kwargs,
|
|
951
|
+
)
|
|
952
|
+
|
|
953
|
+
# limit label to a max of 255 characters (for db reasons)
|
|
954
|
+
max_length = 255
|
|
955
|
+
labels = labels or {}
|
|
956
|
+
labels["source"] = (
|
|
957
|
+
original_source[: max_length - 3] + "..."
|
|
958
|
+
if len(original_source) > max_length
|
|
959
|
+
else original_source
|
|
960
|
+
)
|
|
961
|
+
|
|
841
962
|
item = self._artifacts_manager.log_artifact(
|
|
842
963
|
self,
|
|
843
|
-
|
|
964
|
+
doc_artifact,
|
|
844
965
|
artifact_path=extend_artifact_path(artifact_path, self.artifact_path),
|
|
845
966
|
tag=tag,
|
|
846
967
|
upload=upload,
|
|
847
|
-
db_key=db_key,
|
|
848
968
|
labels=labels,
|
|
969
|
+
local_path=local_path,
|
|
970
|
+
target_path=target_path,
|
|
971
|
+
db_key=db_key,
|
|
849
972
|
)
|
|
850
973
|
self._update_run()
|
|
851
974
|
return item
|
|
852
975
|
|
|
853
976
|
def get_cached_artifact(self, key):
|
|
854
977
|
"""Return a logged artifact from cache (for potential updates)"""
|
|
855
|
-
|
|
978
|
+
warnings.warn(
|
|
979
|
+
"get_cached_artifact is deprecated in 1.8.0 and will be removed in 1.11.0. Use get_artifact instead.",
|
|
980
|
+
FutureWarning,
|
|
981
|
+
)
|
|
982
|
+
return self.get_artifact(key)
|
|
983
|
+
|
|
984
|
+
def get_artifact(
|
|
985
|
+
self, key, tag=None, iter=None, tree=None, uid=None
|
|
986
|
+
) -> Optional[Artifact]:
|
|
987
|
+
cached_artifact_uri = self._artifacts_manager.artifact_uris.get(key, None)
|
|
988
|
+
if tag or iter or tree or uid or (not cached_artifact_uri):
|
|
989
|
+
project = self.get_project_object()
|
|
990
|
+
return project.get_artifact(key=key, tag=tag, iter=iter, tree=tree, uid=uid)
|
|
991
|
+
else:
|
|
992
|
+
return self.get_store_resource(cached_artifact_uri)
|
|
856
993
|
|
|
857
|
-
def update_artifact(self, artifact_object):
|
|
858
|
-
"""Update an artifact object in the
|
|
994
|
+
def update_artifact(self, artifact_object: Artifact):
|
|
995
|
+
"""Update an artifact object in the DB and the cached uri"""
|
|
859
996
|
self._artifacts_manager.update_artifact(self, artifact_object)
|
|
860
997
|
|
|
861
998
|
def commit(self, message: str = "", completed=False):
|
|
@@ -885,7 +1022,12 @@ class MLClientCtx:
|
|
|
885
1022
|
if completed and not self.iteration:
|
|
886
1023
|
mlrun.runtimes.utils.global_context.set(None)
|
|
887
1024
|
|
|
888
|
-
def set_state(
|
|
1025
|
+
def set_state(
|
|
1026
|
+
self,
|
|
1027
|
+
execution_state: Optional[str] = None,
|
|
1028
|
+
error: Optional[str] = None,
|
|
1029
|
+
commit=True,
|
|
1030
|
+
):
|
|
889
1031
|
"""
|
|
890
1032
|
Modify and store the execution state or mark an error and update the run state accordingly.
|
|
891
1033
|
This method allows to set the run state to 'completed' in the DB which is discouraged.
|
|
@@ -1013,7 +1155,7 @@ class MLClientCtx:
|
|
|
1013
1155
|
set_if_not_none(struct["status"], "commit", self._commit)
|
|
1014
1156
|
set_if_not_none(struct["status"], "iterations", self._iteration_results)
|
|
1015
1157
|
|
|
1016
|
-
struct["status"][RunKeys.
|
|
1158
|
+
struct["status"][RunKeys.artifact_uris] = self._artifacts_manager.artifact_uris
|
|
1017
1159
|
self._data_stores.to_dict(struct["spec"])
|
|
1018
1160
|
return struct
|
|
1019
1161
|
|
|
@@ -1107,7 +1249,9 @@ class MLClientCtx:
|
|
|
1107
1249
|
set_if_not_none(struct, "status.commit", self._commit)
|
|
1108
1250
|
set_if_not_none(struct, "status.iterations", self._iteration_results)
|
|
1109
1251
|
|
|
1110
|
-
struct[f"status.{RunKeys.
|
|
1252
|
+
struct[f"status.{RunKeys.artifact_uris}"] = (
|
|
1253
|
+
self._artifacts_manager.artifact_uris
|
|
1254
|
+
)
|
|
1111
1255
|
return struct
|
|
1112
1256
|
|
|
1113
1257
|
def _init_dbs(self, rundb):
|
|
@@ -1121,7 +1265,7 @@ class MLClientCtx:
|
|
|
1121
1265
|
self._data_stores = store_manager.set(self._secrets_manager, db=self._rundb)
|
|
1122
1266
|
self._artifacts_manager = ArtifactManager(db=self._rundb)
|
|
1123
1267
|
|
|
1124
|
-
def _load_project_object(self):
|
|
1268
|
+
def _load_project_object(self) -> Optional["mlrun.MlrunProject"]:
|
|
1125
1269
|
if not self._project_object:
|
|
1126
1270
|
if not self._project:
|
|
1127
1271
|
self.logger.warning(
|
mlrun/feature_store/__init__.py
CHANGED
|
@@ -12,14 +12,8 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
# flake8: noqa
|
|
16
|
-
|
|
17
15
|
__all__ = [
|
|
18
|
-
"get_offline_features",
|
|
19
|
-
"get_online_feature_service",
|
|
20
16
|
"ingest",
|
|
21
|
-
"preview",
|
|
22
|
-
"deploy_ingestion_service_v2",
|
|
23
17
|
"delete_feature_set",
|
|
24
18
|
"delete_feature_vector",
|
|
25
19
|
"get_feature_set",
|
|
@@ -40,19 +34,17 @@ from ..features import Entity, Feature
|
|
|
40
34
|
from .api import (
|
|
41
35
|
delete_feature_set,
|
|
42
36
|
delete_feature_vector,
|
|
43
|
-
deploy_ingestion_service_v2,
|
|
44
37
|
get_feature_set,
|
|
45
38
|
get_feature_vector,
|
|
46
|
-
get_offline_features,
|
|
47
|
-
get_online_feature_service,
|
|
48
39
|
ingest,
|
|
49
|
-
preview,
|
|
50
40
|
)
|
|
51
41
|
from .common import RunConfig
|
|
52
42
|
from .feature_set import FeatureSet
|
|
53
43
|
from .feature_vector import (
|
|
54
44
|
FeatureVector,
|
|
55
45
|
FixedWindowType,
|
|
46
|
+
)
|
|
47
|
+
from .feature_vector_utils import (
|
|
56
48
|
JoinGraph,
|
|
57
49
|
OfflineVectorResponse,
|
|
58
50
|
OnlineVectorService,
|