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
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import os
|
|
16
16
|
import pathlib
|
|
17
17
|
import tempfile
|
|
18
|
-
from typing import Union
|
|
18
|
+
from typing import Optional, Union
|
|
19
19
|
|
|
20
20
|
from mlrun.artifacts import Artifact
|
|
21
21
|
from mlrun.datastore import DataItem
|
|
@@ -140,7 +140,7 @@ class StrPackager(DefaultPackager):
|
|
|
140
140
|
self,
|
|
141
141
|
data_item: DataItem,
|
|
142
142
|
is_directory: bool = False,
|
|
143
|
-
archive_format: str = None,
|
|
143
|
+
archive_format: Optional[str] = None,
|
|
144
144
|
) -> str:
|
|
145
145
|
"""
|
|
146
146
|
Unpack a data item representing a path string. If the path is of a file, the file is downloaded to a local
|
|
@@ -222,7 +222,7 @@ class _BuiltinCollectionPackager(DefaultPackager):
|
|
|
222
222
|
return artifact, instructions
|
|
223
223
|
|
|
224
224
|
def unpack_file(
|
|
225
|
-
self, data_item: DataItem, file_format: str = None
|
|
225
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
226
226
|
) -> Union[dict, list]:
|
|
227
227
|
"""
|
|
228
228
|
Unpack a builtin collection from file.
|
|
@@ -259,7 +259,9 @@ class DictPackager(_BuiltinCollectionPackager):
|
|
|
259
259
|
|
|
260
260
|
PACKABLE_OBJECT_TYPE = dict
|
|
261
261
|
|
|
262
|
-
def unpack_file(
|
|
262
|
+
def unpack_file(
|
|
263
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
264
|
+
) -> dict:
|
|
263
265
|
"""
|
|
264
266
|
Unpack a dictionary from file.
|
|
265
267
|
|
|
@@ -285,7 +287,9 @@ class ListPackager(_BuiltinCollectionPackager):
|
|
|
285
287
|
|
|
286
288
|
PACKABLE_OBJECT_TYPE = list
|
|
287
289
|
|
|
288
|
-
def unpack_file(
|
|
290
|
+
def unpack_file(
|
|
291
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
292
|
+
) -> list:
|
|
289
293
|
"""
|
|
290
294
|
Unpack a list from file.
|
|
291
295
|
|
|
@@ -355,7 +359,9 @@ class TuplePackager(ListPackager):
|
|
|
355
359
|
"""
|
|
356
360
|
return super().pack_file(obj=list(obj), key=key, file_format=file_format)
|
|
357
361
|
|
|
358
|
-
def unpack_file(
|
|
362
|
+
def unpack_file(
|
|
363
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
364
|
+
) -> tuple:
|
|
359
365
|
"""
|
|
360
366
|
Unpack a tuple from file.
|
|
361
367
|
|
|
@@ -400,7 +406,9 @@ class SetPackager(ListPackager):
|
|
|
400
406
|
"""
|
|
401
407
|
return super().pack_file(obj=list(obj), key=key, file_format=file_format)
|
|
402
408
|
|
|
403
|
-
def unpack_file(
|
|
409
|
+
def unpack_file(
|
|
410
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
411
|
+
) -> set:
|
|
404
412
|
"""
|
|
405
413
|
Unpack a set from file.
|
|
406
414
|
|
|
@@ -434,7 +442,9 @@ class FrozensetPackager(SetPackager):
|
|
|
434
442
|
"""
|
|
435
443
|
return super().pack_file(obj=set(obj), key=key, file_format=file_format)
|
|
436
444
|
|
|
437
|
-
def unpack_file(
|
|
445
|
+
def unpack_file(
|
|
446
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
447
|
+
) -> frozenset:
|
|
438
448
|
"""
|
|
439
449
|
Unpack a frozenset from file.
|
|
440
450
|
|
|
@@ -481,7 +491,9 @@ class BytesPackager(ListPackager):
|
|
|
481
491
|
"""
|
|
482
492
|
return super().pack_file(obj=list(obj), key=key, file_format=file_format)
|
|
483
493
|
|
|
484
|
-
def unpack_file(
|
|
494
|
+
def unpack_file(
|
|
495
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
496
|
+
) -> bytes:
|
|
485
497
|
"""
|
|
486
498
|
Unpack a bytes from file.
|
|
487
499
|
|
|
@@ -526,7 +538,9 @@ class BytearrayPackager(BytesPackager):
|
|
|
526
538
|
"""
|
|
527
539
|
return super().pack_file(obj=bytes(obj), key=key, file_format=file_format)
|
|
528
540
|
|
|
529
|
-
def unpack_file(
|
|
541
|
+
def unpack_file(
|
|
542
|
+
self, data_item: DataItem, file_format: Optional[str] = None
|
|
543
|
+
) -> bytearray:
|
|
530
544
|
"""
|
|
531
545
|
Unpack a bytearray from file.
|
|
532
546
|
|
|
@@ -585,7 +599,7 @@ class PathPackager(StrPackager):
|
|
|
585
599
|
self,
|
|
586
600
|
data_item: DataItem,
|
|
587
601
|
is_directory: bool = False,
|
|
588
|
-
archive_format: str = None,
|
|
602
|
+
archive_format: Optional[str] = None,
|
|
589
603
|
) -> pathlib.Path:
|
|
590
604
|
"""
|
|
591
605
|
Unpack a data item representing a `Path`. If the path is of a file, the file is downloaded to a local
|
|
@@ -17,10 +17,11 @@ import inspect
|
|
|
17
17
|
import os
|
|
18
18
|
import shutil
|
|
19
19
|
import traceback
|
|
20
|
-
from typing import Any, Union
|
|
20
|
+
from typing import Any, Optional, Union
|
|
21
21
|
|
|
22
|
+
import mlrun.errors
|
|
22
23
|
from mlrun.artifacts import Artifact
|
|
23
|
-
from mlrun.datastore import DataItem, store_manager
|
|
24
|
+
from mlrun.datastore import DataItem, get_store_resource, store_manager
|
|
24
25
|
from mlrun.errors import MLRunInvalidArgumentError
|
|
25
26
|
from mlrun.utils import logger
|
|
26
27
|
|
|
@@ -41,7 +42,7 @@ class PackagersManager:
|
|
|
41
42
|
It prepares the instructions / log hint configurations and then looks for the first packager that fits the task.
|
|
42
43
|
"""
|
|
43
44
|
|
|
44
|
-
def __init__(self, default_packager: type[Packager] = None):
|
|
45
|
+
def __init__(self, default_packager: Optional[type[Packager]] = None):
|
|
45
46
|
"""
|
|
46
47
|
Initialize a packagers manager.
|
|
47
48
|
|
|
@@ -302,18 +303,17 @@ class PackagersManager:
|
|
|
302
303
|
|
|
303
304
|
def link_packages(
|
|
304
305
|
self,
|
|
305
|
-
|
|
306
|
+
additional_artifact_uris: dict,
|
|
306
307
|
additional_results: dict,
|
|
307
308
|
):
|
|
308
309
|
"""
|
|
309
310
|
Link packages to each other according to the provided extra data and metrics spec keys. A future link is
|
|
310
311
|
marked with ellipses (...). If no link is found, None is used and a warning is printed.
|
|
311
312
|
|
|
312
|
-
:param
|
|
313
|
-
:param additional_results:
|
|
313
|
+
:param additional_artifact_uris: Additional artifact URIs to link (should come from an `mlrun.MLClientCtx`).
|
|
314
|
+
:param additional_results: Additional results to link (should come from an `mlrun.MLClientCtx`).
|
|
314
315
|
"""
|
|
315
316
|
# Join the manager's artifacts and results with the additional ones to look for a link in all of them:
|
|
316
|
-
joined_artifacts = [*additional_artifacts, *self.artifacts]
|
|
317
317
|
joined_results = {**additional_results, **self.results}
|
|
318
318
|
|
|
319
319
|
# Go over the artifacts and link:
|
|
@@ -324,7 +324,10 @@ class PackagersManager:
|
|
|
324
324
|
if artifact.spec.extra_data[key] is ...:
|
|
325
325
|
# Look for an artifact or result with this key to link it:
|
|
326
326
|
extra_data = self._look_for_extra_data(
|
|
327
|
-
key=key,
|
|
327
|
+
key=key,
|
|
328
|
+
artifacts=self.artifacts,
|
|
329
|
+
artifact_uris=additional_artifact_uris,
|
|
330
|
+
results=joined_results,
|
|
328
331
|
)
|
|
329
332
|
# Print a warning if a link is missing:
|
|
330
333
|
if extra_data is None:
|
|
@@ -398,8 +401,8 @@ class PackagersManager:
|
|
|
398
401
|
def _get_packager_for_packing(
|
|
399
402
|
self,
|
|
400
403
|
obj: Any,
|
|
401
|
-
artifact_type: str = None,
|
|
402
|
-
configurations: dict = None,
|
|
404
|
+
artifact_type: Optional[str] = None,
|
|
405
|
+
configurations: Optional[dict] = None,
|
|
403
406
|
) -> Union[Packager, None]:
|
|
404
407
|
"""
|
|
405
408
|
Look for a packager that can pack the provided object as the provided artifact type.
|
|
@@ -426,7 +429,7 @@ class PackagersManager:
|
|
|
426
429
|
self,
|
|
427
430
|
data_item: Any,
|
|
428
431
|
type_hint: type,
|
|
429
|
-
artifact_type: str = None,
|
|
432
|
+
artifact_type: Optional[str] = None,
|
|
430
433
|
) -> Union[Packager, None]:
|
|
431
434
|
"""
|
|
432
435
|
Look for a packager that can unpack the data item of the given type hint as the provided artifact type.
|
|
@@ -664,16 +667,9 @@ class PackagersManager:
|
|
|
664
667
|
data_item=data_item,
|
|
665
668
|
instructions={},
|
|
666
669
|
)
|
|
667
|
-
except Exception
|
|
670
|
+
except Exception:
|
|
668
671
|
# Could not unpack as the reduced type hint, collect the exception and go to the next one:
|
|
669
|
-
|
|
670
|
-
traceback.format_exception(
|
|
671
|
-
etype=type(exception),
|
|
672
|
-
value=exception,
|
|
673
|
-
tb=exception.__traceback__,
|
|
674
|
-
)
|
|
675
|
-
)
|
|
676
|
-
found_packagers.append((packager, exception_string))
|
|
672
|
+
found_packagers.append((packager, traceback.format_exc()))
|
|
677
673
|
# Reduce the type hint list and continue:
|
|
678
674
|
possible_type_hints = TypeHintUtils.reduce_type_hint(
|
|
679
675
|
type_hint=possible_type_hints
|
|
@@ -689,15 +685,8 @@ class PackagersManager:
|
|
|
689
685
|
artifact_type=None,
|
|
690
686
|
instructions={},
|
|
691
687
|
)
|
|
692
|
-
except Exception
|
|
693
|
-
|
|
694
|
-
traceback.format_exception(
|
|
695
|
-
etype=type(exception),
|
|
696
|
-
value=exception,
|
|
697
|
-
tb=exception.__traceback__,
|
|
698
|
-
)
|
|
699
|
-
)
|
|
700
|
-
found_packagers.append((self._default_packager, exception_string))
|
|
688
|
+
except Exception:
|
|
689
|
+
found_packagers.append((self._default_packager, traceback.format_exc()))
|
|
701
690
|
|
|
702
691
|
# The method did not return until this point, raise an error:
|
|
703
692
|
raise MLRunPackageUnpackingError(
|
|
@@ -715,17 +704,31 @@ class PackagersManager:
|
|
|
715
704
|
def _look_for_extra_data(
|
|
716
705
|
key: str,
|
|
717
706
|
artifacts: list[Artifact],
|
|
707
|
+
artifact_uris: dict,
|
|
718
708
|
results: dict,
|
|
719
709
|
) -> Union[Artifact, str, int, float, None]:
|
|
720
710
|
"""
|
|
721
711
|
Look for an extra data item (artifact or result) by given key. If not found, None is returned.
|
|
722
712
|
|
|
723
|
-
:param key:
|
|
724
|
-
:param artifacts:
|
|
725
|
-
:param
|
|
713
|
+
:param key: Key to look for.
|
|
714
|
+
:param artifacts: Artifacts to look in.
|
|
715
|
+
:param artifact_uris: Artifacts URIs to look in.
|
|
716
|
+
:param results: Results to look in.
|
|
726
717
|
|
|
727
718
|
:return: The artifact or result with the same key or None if not found.
|
|
728
719
|
"""
|
|
720
|
+
artifact_uris = artifact_uris or {}
|
|
721
|
+
for _key, uri in artifact_uris.items():
|
|
722
|
+
if key == _key:
|
|
723
|
+
try:
|
|
724
|
+
return get_store_resource(uri)
|
|
725
|
+
except mlrun.errors.MLRunNotFoundError as exc:
|
|
726
|
+
logger.warn(
|
|
727
|
+
f"Artifact {key=} not found when looking for extra data",
|
|
728
|
+
exc=mlrun.errors.err_to_str(exc),
|
|
729
|
+
)
|
|
730
|
+
return None
|
|
731
|
+
|
|
729
732
|
# Look in the artifacts:
|
|
730
733
|
for artifact in artifacts:
|
|
731
734
|
if key == artifact.key:
|
mlrun/package/utils/__init__.py
CHANGED
|
@@ -11,9 +11,6 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
-
#
|
|
15
|
-
|
|
16
|
-
# flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
|
|
17
14
|
|
|
18
15
|
from ._archiver import ArchiveSupportedFormat
|
|
19
16
|
from ._formatter import StructFileSupportedFormat
|
mlrun/package/utils/_pickler.py
CHANGED
|
@@ -19,7 +19,7 @@ import sys
|
|
|
19
19
|
import tempfile
|
|
20
20
|
import warnings
|
|
21
21
|
from types import ModuleType
|
|
22
|
-
from typing import Any, Union
|
|
22
|
+
from typing import Any, Optional, Union
|
|
23
23
|
|
|
24
24
|
from mlrun.errors import MLRunInvalidArgumentError
|
|
25
25
|
from mlrun.utils import logger
|
|
@@ -34,7 +34,7 @@ class Pickler:
|
|
|
34
34
|
|
|
35
35
|
@staticmethod
|
|
36
36
|
def pickle(
|
|
37
|
-
obj: Any, pickle_module_name: str, output_path: str = None
|
|
37
|
+
obj: Any, pickle_module_name: str, output_path: Optional[str] = None
|
|
38
38
|
) -> tuple[str, dict[str, Union[str, None]]]:
|
|
39
39
|
"""
|
|
40
40
|
Pickle an object using the given module. The pickled object will be saved to file to the given output path.
|
|
@@ -91,10 +91,10 @@ class Pickler:
|
|
|
91
91
|
def unpickle(
|
|
92
92
|
pickle_path: str,
|
|
93
93
|
pickle_module_name: str,
|
|
94
|
-
object_module_name: str = None,
|
|
95
|
-
python_version: str = None,
|
|
96
|
-
pickle_module_version: str = None,
|
|
97
|
-
object_module_version: str = None,
|
|
94
|
+
object_module_name: Optional[str] = None,
|
|
95
|
+
python_version: Optional[str] = None,
|
|
96
|
+
pickle_module_version: Optional[str] = None,
|
|
97
|
+
object_module_version: Optional[str] = None,
|
|
98
98
|
) -> Any:
|
|
99
99
|
"""
|
|
100
100
|
Unpickle an object using the given instructions. Warnings may be raised in case any of the versions are
|
mlrun/platforms/__init__.py
CHANGED
|
@@ -12,23 +12,11 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
# flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
|
|
16
15
|
import json
|
|
16
|
+
import warnings
|
|
17
17
|
from pprint import pprint
|
|
18
18
|
from time import sleep
|
|
19
|
-
|
|
20
|
-
from mlrun_pipelines.common.mounts import VolumeMount
|
|
21
|
-
from mlrun_pipelines.mounts import (
|
|
22
|
-
auto_mount,
|
|
23
|
-
mount_configmap,
|
|
24
|
-
mount_hostpath,
|
|
25
|
-
mount_pvc,
|
|
26
|
-
mount_s3,
|
|
27
|
-
mount_secret,
|
|
28
|
-
mount_v3io,
|
|
29
|
-
set_env_variables,
|
|
30
|
-
v3io_cred,
|
|
31
|
-
)
|
|
19
|
+
from typing import Optional
|
|
32
20
|
|
|
33
21
|
from .iguazio import (
|
|
34
22
|
V3ioStreamClient,
|
|
@@ -37,10 +25,53 @@ from .iguazio import (
|
|
|
37
25
|
)
|
|
38
26
|
|
|
39
27
|
|
|
28
|
+
class _DeprecationHelper:
|
|
29
|
+
"""A helper class to deprecate old schemas"""
|
|
30
|
+
|
|
31
|
+
def __init__(self, new_target: str, version="1.8.0"):
|
|
32
|
+
self._new_target = new_target
|
|
33
|
+
self._version = version
|
|
34
|
+
|
|
35
|
+
def __call__(self, *args, **kwargs):
|
|
36
|
+
self._warn()
|
|
37
|
+
return self._lazy_load()(*args, **kwargs)
|
|
38
|
+
|
|
39
|
+
def __getattr__(self, attr):
|
|
40
|
+
self._warn()
|
|
41
|
+
return getattr(self._lazy_load(), attr)
|
|
42
|
+
|
|
43
|
+
def _lazy_load(self, *args, **kwargs):
|
|
44
|
+
import mlrun.runtimes.mounts as mlrun_mounts
|
|
45
|
+
|
|
46
|
+
return getattr(mlrun_mounts, self._new_target)
|
|
47
|
+
|
|
48
|
+
def _warn(self):
|
|
49
|
+
warnings.warn(
|
|
50
|
+
f"mlrun.platforms.{self._new_target} is deprecated since version {self._version}, "
|
|
51
|
+
f"and will be removed in 1.10. Use mlrun.runtimes.mounts.{self._new_target} instead.",
|
|
52
|
+
FutureWarning,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# TODO: Remove in 1.10
|
|
57
|
+
# For backwards compatibility
|
|
58
|
+
VolumeMount = _DeprecationHelper("VolumeMount")
|
|
59
|
+
auto_mount = _DeprecationHelper("auto_mount")
|
|
60
|
+
mount_configmap = _DeprecationHelper("mount_configmap")
|
|
61
|
+
mount_hostpath = _DeprecationHelper("mount_hostpath")
|
|
62
|
+
mount_pvc = _DeprecationHelper("mount_pvc")
|
|
63
|
+
mount_s3 = _DeprecationHelper("mount_s3")
|
|
64
|
+
mount_secret = _DeprecationHelper("mount_secret")
|
|
65
|
+
mount_v3io = _DeprecationHelper("mount_v3io")
|
|
66
|
+
set_env_variables = _DeprecationHelper("set_env_variables")
|
|
67
|
+
v3io_cred = _DeprecationHelper("v3io_cred")
|
|
68
|
+
# eof 'For backwards compatibility'
|
|
69
|
+
|
|
70
|
+
|
|
40
71
|
def watch_stream(
|
|
41
72
|
url,
|
|
42
|
-
shard_ids: list = None,
|
|
43
|
-
seek_to: str = None,
|
|
73
|
+
shard_ids: Optional[list] = None,
|
|
74
|
+
seek_to: Optional[str] = None,
|
|
44
75
|
interval=None,
|
|
45
76
|
is_json=False,
|
|
46
77
|
**kwargs,
|
mlrun/platforms/iguazio.py
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import json
|
|
16
16
|
import os
|
|
17
17
|
import urllib
|
|
18
|
+
from typing import Optional
|
|
18
19
|
from urllib.parse import urlparse
|
|
19
20
|
|
|
20
21
|
import requests
|
|
@@ -250,7 +251,9 @@ class KafkaOutputStream:
|
|
|
250
251
|
|
|
251
252
|
|
|
252
253
|
class V3ioStreamClient:
|
|
253
|
-
def __init__(
|
|
254
|
+
def __init__(
|
|
255
|
+
self, url: str, shard_id: int = 0, seek_to: Optional[str] = None, **kwargs
|
|
256
|
+
):
|
|
254
257
|
endpoint, stream_path = parse_path(url)
|
|
255
258
|
seek_options = ["EARLIEST", "LATEST", "TIME", "SEQUENCE"]
|
|
256
259
|
seek_to = seek_to or "LATEST"
|
mlrun/projects/operations.py
CHANGED
|
@@ -12,16 +12,16 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
#
|
|
15
|
+
import typing
|
|
15
16
|
import warnings
|
|
16
17
|
from typing import Optional, Union
|
|
17
18
|
|
|
18
|
-
import mlrun_pipelines.common.models
|
|
19
|
-
import mlrun_pipelines.models
|
|
20
|
-
|
|
21
19
|
import mlrun
|
|
22
20
|
import mlrun.common.constants as mlrun_constants
|
|
23
21
|
import mlrun.common.schemas.function
|
|
24
22
|
import mlrun.common.schemas.workflow
|
|
23
|
+
import mlrun_pipelines.common.models
|
|
24
|
+
import mlrun_pipelines.models
|
|
25
25
|
from mlrun.utils import hub_prefix
|
|
26
26
|
|
|
27
27
|
from .pipelines import enrich_function_object, pipeline_context
|
|
@@ -59,25 +59,25 @@ def _get_engine_and_function(function, project=None):
|
|
|
59
59
|
|
|
60
60
|
def run_function(
|
|
61
61
|
function: Union[str, mlrun.runtimes.BaseRuntime],
|
|
62
|
-
handler: str = None,
|
|
62
|
+
handler: Optional[Union[str, typing.Callable]] = None,
|
|
63
63
|
name: str = "",
|
|
64
|
-
params: dict = None,
|
|
65
|
-
hyperparams: dict = None,
|
|
64
|
+
params: Optional[dict] = None,
|
|
65
|
+
hyperparams: Optional[dict] = None,
|
|
66
66
|
hyper_param_options: mlrun.model.HyperParamOptions = None,
|
|
67
|
-
inputs: dict = None,
|
|
68
|
-
outputs: list[str] = None,
|
|
67
|
+
inputs: Optional[dict] = None,
|
|
68
|
+
outputs: Optional[list[str]] = None,
|
|
69
69
|
workdir: str = "",
|
|
70
|
-
labels: dict = None,
|
|
70
|
+
labels: Optional[dict] = None,
|
|
71
71
|
base_task: mlrun.model.RunTemplate = None,
|
|
72
72
|
watch: bool = True,
|
|
73
|
-
local: bool = None,
|
|
74
|
-
verbose: bool = None,
|
|
75
|
-
selector: str = None,
|
|
73
|
+
local: Optional[bool] = None,
|
|
74
|
+
verbose: Optional[bool] = None,
|
|
75
|
+
selector: Optional[str] = None,
|
|
76
76
|
project_object=None,
|
|
77
|
-
auto_build: bool = None,
|
|
77
|
+
auto_build: Optional[bool] = None,
|
|
78
78
|
schedule: Union[str, mlrun.common.schemas.ScheduleCronTrigger] = None,
|
|
79
|
-
artifact_path: str = None,
|
|
80
|
-
notifications: list[mlrun.model.Notification] = None,
|
|
79
|
+
artifact_path: Optional[str] = None,
|
|
80
|
+
notifications: Optional[list[mlrun.model.Notification]] = None,
|
|
81
81
|
returns: Optional[list[Union[str, dict[str, str]]]] = None,
|
|
82
82
|
builder_env: Optional[list] = None,
|
|
83
83
|
reset_on_run: Optional[bool] = None,
|
|
@@ -255,19 +255,19 @@ class BuildStatus:
|
|
|
255
255
|
|
|
256
256
|
def build_function(
|
|
257
257
|
function: Union[str, mlrun.runtimes.BaseRuntime],
|
|
258
|
-
with_mlrun: bool = None,
|
|
258
|
+
with_mlrun: Optional[bool] = None,
|
|
259
259
|
skip_deployed: bool = False,
|
|
260
260
|
image=None,
|
|
261
261
|
base_image=None,
|
|
262
|
-
commands: list = None,
|
|
262
|
+
commands: Optional[list] = None,
|
|
263
263
|
secret_name=None,
|
|
264
|
-
requirements: Union[str, list[str]] = None,
|
|
265
|
-
requirements_file: str = None,
|
|
264
|
+
requirements: Optional[Union[str, list[str]]] = None,
|
|
265
|
+
requirements_file: Optional[str] = None,
|
|
266
266
|
mlrun_version_specifier=None,
|
|
267
|
-
builder_env: dict = None,
|
|
267
|
+
builder_env: Optional[dict] = None,
|
|
268
268
|
project_object=None,
|
|
269
269
|
overwrite_build_params: bool = False,
|
|
270
|
-
extra_args: str = None,
|
|
270
|
+
extra_args: Optional[str] = None,
|
|
271
271
|
force_build: bool = False,
|
|
272
272
|
) -> Union[BuildStatus, mlrun_pipelines.models.PipelineNodeWrapper]:
|
|
273
273
|
"""deploy ML function, build container with its dependencies
|
|
@@ -294,9 +294,9 @@ def build_function(
|
|
|
294
294
|
:param force_build: Force building the image, even when no changes were made
|
|
295
295
|
"""
|
|
296
296
|
if not overwrite_build_params:
|
|
297
|
-
# TODO: change overwrite_build_params default to True in 1.
|
|
297
|
+
# TODO: change overwrite_build_params default to True in 1.10.0
|
|
298
298
|
warnings.warn(
|
|
299
|
-
"The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.
|
|
299
|
+
"The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.10.0.",
|
|
300
300
|
mlrun.utils.OverwriteBuildParamsWarning,
|
|
301
301
|
)
|
|
302
302
|
|
|
@@ -325,7 +325,7 @@ def build_function(
|
|
|
325
325
|
skip_deployed=skip_deployed,
|
|
326
326
|
)
|
|
327
327
|
else:
|
|
328
|
-
# TODO: remove filter once overwrite_build_params default is changed to True in 1.
|
|
328
|
+
# TODO: remove filter once overwrite_build_params default is changed to True in 1.10.0
|
|
329
329
|
with warnings.catch_warnings():
|
|
330
330
|
warnings.simplefilter(
|
|
331
331
|
"ignore", category=mlrun.utils.OverwriteBuildParamsWarning
|
|
@@ -371,13 +371,13 @@ class DeployStatus:
|
|
|
371
371
|
|
|
372
372
|
def deploy_function(
|
|
373
373
|
function: Union[str, mlrun.runtimes.BaseRuntime],
|
|
374
|
-
models: list = None,
|
|
375
|
-
env: dict = None,
|
|
376
|
-
tag: str = None,
|
|
377
|
-
verbose: bool = None,
|
|
378
|
-
builder_env: dict = None,
|
|
374
|
+
models: Optional[list] = None,
|
|
375
|
+
env: Optional[dict] = None,
|
|
376
|
+
tag: Optional[str] = None,
|
|
377
|
+
verbose: Optional[bool] = None,
|
|
378
|
+
builder_env: Optional[dict] = None,
|
|
379
379
|
project_object=None,
|
|
380
|
-
mock: bool = None,
|
|
380
|
+
mock: Optional[bool] = None,
|
|
381
381
|
) -> Union[DeployStatus, mlrun_pipelines.models.PipelineNodeWrapper]:
|
|
382
382
|
"""deploy real-time (nuclio based) functions
|
|
383
383
|
|