mlrun 1.7.2__py3-none-any.whl → 1.8.0rc1__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 +14 -12
- mlrun/__main__.py +3 -3
- mlrun/alerts/alert.py +19 -12
- mlrun/artifacts/__init__.py +0 -2
- mlrun/artifacts/base.py +34 -11
- mlrun/artifacts/dataset.py +16 -16
- mlrun/artifacts/manager.py +13 -13
- mlrun/artifacts/model.py +66 -53
- mlrun/common/constants.py +6 -0
- mlrun/common/formatters/__init__.py +1 -0
- mlrun/common/formatters/feature_set.py +1 -0
- mlrun/common/formatters/function.py +1 -0
- mlrun/common/formatters/model_endpoint.py +30 -0
- mlrun/common/formatters/pipeline.py +1 -2
- mlrun/common/model_monitoring/__init__.py +0 -3
- mlrun/common/model_monitoring/helpers.py +1 -1
- mlrun/common/runtimes/constants.py +1 -2
- mlrun/common/schemas/__init__.py +4 -2
- mlrun/common/schemas/artifact.py +0 -6
- mlrun/common/schemas/common.py +50 -0
- mlrun/common/schemas/model_monitoring/__init__.py +8 -1
- mlrun/common/schemas/model_monitoring/constants.py +62 -12
- mlrun/common/schemas/model_monitoring/model_endpoint_v2.py +149 -0
- mlrun/common/schemas/model_monitoring/model_endpoints.py +21 -5
- mlrun/common/schemas/partition.py +122 -0
- mlrun/config.py +43 -15
- mlrun/data_types/__init__.py +0 -2
- mlrun/data_types/data_types.py +0 -1
- mlrun/data_types/infer.py +3 -1
- mlrun/data_types/spark.py +4 -4
- mlrun/data_types/to_pandas.py +2 -11
- mlrun/datastore/__init__.py +0 -2
- mlrun/datastore/alibaba_oss.py +4 -1
- mlrun/datastore/azure_blob.py +4 -1
- mlrun/datastore/base.py +12 -4
- mlrun/datastore/datastore.py +9 -3
- mlrun/datastore/datastore_profile.py +1 -1
- 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 +4 -1
- mlrun/datastore/sources.py +51 -49
- mlrun/datastore/store_resources.py +0 -2
- mlrun/datastore/targets.py +22 -23
- mlrun/datastore/utils.py +2 -2
- mlrun/datastore/v3io.py +4 -1
- mlrun/datastore/wasbfs/fs.py +13 -12
- mlrun/db/base.py +126 -62
- mlrun/db/factory.py +3 -0
- mlrun/db/httpdb.py +767 -231
- mlrun/db/nopdb.py +126 -57
- mlrun/errors.py +2 -2
- mlrun/execution.py +55 -29
- mlrun/feature_store/__init__.py +0 -2
- mlrun/feature_store/api.py +40 -40
- mlrun/feature_store/common.py +9 -9
- mlrun/feature_store/feature_set.py +20 -18
- mlrun/feature_store/feature_vector.py +27 -24
- mlrun/feature_store/retrieval/base.py +14 -9
- mlrun/feature_store/retrieval/job.py +2 -1
- mlrun/feature_store/steps.py +2 -2
- 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 +29 -27
- 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/launcher/base.py +3 -4
- mlrun/launcher/local.py +1 -1
- mlrun/launcher/remote.py +1 -1
- mlrun/lists.py +4 -3
- mlrun/model.py +108 -44
- mlrun/model_monitoring/__init__.py +1 -2
- mlrun/model_monitoring/api.py +6 -6
- mlrun/model_monitoring/applications/_application_steps.py +13 -15
- mlrun/model_monitoring/applications/histogram_data_drift.py +41 -15
- mlrun/model_monitoring/applications/results.py +55 -3
- mlrun/model_monitoring/controller.py +185 -223
- mlrun/model_monitoring/db/_schedules.py +156 -0
- mlrun/model_monitoring/db/_stats.py +189 -0
- mlrun/model_monitoring/db/stores/__init__.py +1 -1
- mlrun/model_monitoring/db/stores/base/store.py +6 -65
- mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -25
- mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -97
- mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +2 -58
- mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -15
- mlrun/model_monitoring/db/stores/sqldb/sql_store.py +6 -257
- mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +9 -271
- mlrun/model_monitoring/db/tsdb/base.py +74 -22
- mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +66 -35
- mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +284 -51
- mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
- mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +35 -17
- mlrun/model_monitoring/helpers.py +97 -1
- mlrun/model_monitoring/model_endpoint.py +4 -2
- mlrun/model_monitoring/stream_processing.py +2 -2
- mlrun/model_monitoring/tracking_policy.py +10 -3
- mlrun/model_monitoring/writer.py +47 -26
- mlrun/package/__init__.py +3 -6
- mlrun/package/context_handler.py +1 -1
- 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 +31 -14
- mlrun/package/utils/__init__.py +0 -3
- mlrun/package/utils/_pickler.py +6 -6
- mlrun/platforms/__init__.py +3 -3
- mlrun/platforms/iguazio.py +4 -1
- mlrun/projects/__init__.py +1 -6
- mlrun/projects/operations.py +27 -27
- mlrun/projects/pipelines.py +85 -215
- mlrun/projects/project.py +444 -158
- mlrun/run.py +9 -9
- mlrun/runtimes/__init__.py +1 -3
- mlrun/runtimes/base.py +13 -10
- mlrun/runtimes/daskjob.py +9 -9
- mlrun/runtimes/generators.py +2 -1
- mlrun/runtimes/kubejob.py +4 -5
- 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 -11
- mlrun/runtimes/nuclio/function.py +14 -14
- mlrun/runtimes/nuclio/serving.py +9 -9
- mlrun/runtimes/pod.py +74 -29
- mlrun/runtimes/remotesparkjob.py +3 -2
- mlrun/runtimes/sparkjob/__init__.py +0 -2
- mlrun/runtimes/sparkjob/spark3job.py +21 -11
- mlrun/runtimes/utils.py +6 -5
- mlrun/serving/merger.py +6 -4
- mlrun/serving/remote.py +18 -17
- mlrun/serving/routers.py +27 -27
- mlrun/serving/server.py +1 -1
- mlrun/serving/states.py +76 -71
- mlrun/serving/utils.py +13 -2
- mlrun/serving/v1_serving.py +3 -2
- mlrun/serving/v2_serving.py +4 -4
- 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 +1 -1
- mlrun/utils/helpers.py +72 -28
- mlrun/utils/logger.py +104 -2
- mlrun/utils/notifications/notification/base.py +23 -4
- mlrun/utils/notifications/notification/console.py +1 -1
- mlrun/utils/notifications/notification/git.py +6 -6
- mlrun/utils/notifications/notification/ipython.py +5 -4
- mlrun/utils/notifications/notification/slack.py +1 -1
- mlrun/utils/notifications/notification/webhook.py +13 -17
- mlrun/utils/notifications/notification_pusher.py +23 -19
- mlrun/utils/regex.py +1 -1
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.7.2.dist-info → mlrun-1.8.0rc1.dist-info}/METADATA +187 -199
- mlrun-1.8.0rc1.dist-info/RECORD +356 -0
- {mlrun-1.7.2.dist-info → mlrun-1.8.0rc1.dist-info}/WHEEL +1 -1
- mlrun-1.7.2.dist-info/RECORD +0 -351
- {mlrun-1.7.2.dist-info → mlrun-1.8.0rc1.dist-info}/LICENSE +0 -0
- {mlrun-1.7.2.dist-info → mlrun-1.8.0rc1.dist-info}/entry_points.txt +0 -0
- {mlrun-1.7.2.dist-info → mlrun-1.8.0rc1.dist-info}/top_level.txt +0 -0
mlrun/projects/pipelines.py
CHANGED
|
@@ -20,16 +20,15 @@ import tempfile
|
|
|
20
20
|
import typing
|
|
21
21
|
import uuid
|
|
22
22
|
|
|
23
|
-
import mlrun_pipelines.common.models
|
|
24
|
-
import mlrun_pipelines.patcher
|
|
25
|
-
import mlrun_pipelines.utils
|
|
26
|
-
|
|
27
23
|
import mlrun
|
|
28
24
|
import mlrun.common.runtimes.constants
|
|
29
25
|
import mlrun.common.schemas
|
|
30
26
|
import mlrun.common.schemas.function
|
|
31
27
|
import mlrun.common.schemas.workflow
|
|
32
28
|
import mlrun.utils.notifications
|
|
29
|
+
import mlrun_pipelines.common.models
|
|
30
|
+
import mlrun_pipelines.patcher
|
|
31
|
+
import mlrun_pipelines.utils
|
|
33
32
|
from mlrun.errors import err_to_str
|
|
34
33
|
from mlrun.utils import (
|
|
35
34
|
get_ui_url,
|
|
@@ -317,7 +316,7 @@ def get_db_function(project, key) -> mlrun.runtimes.BaseRuntime:
|
|
|
317
316
|
def enrich_function_object(
|
|
318
317
|
project: mlrun.common.schemas.Project,
|
|
319
318
|
function: mlrun.runtimes.BaseRuntime,
|
|
320
|
-
decorator: typing.Callable = None,
|
|
319
|
+
decorator: typing.Optional[typing.Callable] = None,
|
|
321
320
|
copy_function: bool = True,
|
|
322
321
|
try_auto_mount: bool = True,
|
|
323
322
|
) -> mlrun.runtimes.BaseRuntime:
|
|
@@ -380,7 +379,7 @@ class _PipelineRunStatus:
|
|
|
380
379
|
project: "mlrun.projects.MlrunProject",
|
|
381
380
|
workflow: WorkflowSpec = None,
|
|
382
381
|
state: mlrun_pipelines.common.models.RunStatuses = "",
|
|
383
|
-
exc: Exception = None,
|
|
382
|
+
exc: typing.Optional[Exception] = None,
|
|
384
383
|
):
|
|
385
384
|
"""
|
|
386
385
|
:param run_id: unique id of the pipeline run
|
|
@@ -453,7 +452,7 @@ class _PipelineRunner(abc.ABC):
|
|
|
453
452
|
artifact_path=None,
|
|
454
453
|
namespace=None,
|
|
455
454
|
source=None,
|
|
456
|
-
notifications: list[mlrun.model.Notification] = None,
|
|
455
|
+
notifications: typing.Optional[list[mlrun.model.Notification]] = None,
|
|
457
456
|
) -> _PipelineRunStatus:
|
|
458
457
|
pass
|
|
459
458
|
|
|
@@ -463,7 +462,7 @@ class _PipelineRunner(abc.ABC):
|
|
|
463
462
|
run: "_PipelineRunStatus",
|
|
464
463
|
project: typing.Optional["mlrun.projects.MlrunProject"] = None,
|
|
465
464
|
timeout: typing.Optional[int] = None,
|
|
466
|
-
expected_statuses: list[str] = None,
|
|
465
|
+
expected_statuses: typing.Optional[list[str]] = None,
|
|
467
466
|
):
|
|
468
467
|
pass
|
|
469
468
|
|
|
@@ -577,7 +576,7 @@ class _KFPRunner(_PipelineRunner):
|
|
|
577
576
|
artifact_path=None,
|
|
578
577
|
namespace=None,
|
|
579
578
|
source=None,
|
|
580
|
-
notifications: list[mlrun.model.Notification] = None,
|
|
579
|
+
notifications: typing.Optional[list[mlrun.model.Notification]] = None,
|
|
581
580
|
) -> _PipelineRunStatus:
|
|
582
581
|
pipeline_context.set(project, workflow_spec)
|
|
583
582
|
workflow_handler = _PipelineRunner._get_handler(
|
|
@@ -641,7 +640,7 @@ class _KFPRunner(_PipelineRunner):
|
|
|
641
640
|
run: "_PipelineRunStatus",
|
|
642
641
|
project: typing.Optional["mlrun.projects.MlrunProject"] = None,
|
|
643
642
|
timeout: typing.Optional[int] = None,
|
|
644
|
-
expected_statuses: list[str] = None,
|
|
643
|
+
expected_statuses: typing.Optional[list[str]] = None,
|
|
645
644
|
):
|
|
646
645
|
project_name = project.metadata.name if project else ""
|
|
647
646
|
logger.info(
|
|
@@ -686,7 +685,7 @@ class _LocalRunner(_PipelineRunner):
|
|
|
686
685
|
artifact_path=None,
|
|
687
686
|
namespace=None,
|
|
688
687
|
source=None,
|
|
689
|
-
notifications: list[mlrun.model.Notification] = None,
|
|
688
|
+
notifications: typing.Optional[list[mlrun.model.Notification]] = None,
|
|
690
689
|
) -> _PipelineRunStatus:
|
|
691
690
|
pipeline_context.set(project, workflow_spec)
|
|
692
691
|
workflow_handler = _PipelineRunner._get_handler(
|
|
@@ -763,13 +762,13 @@ class _RemoteRunner(_PipelineRunner):
|
|
|
763
762
|
cls,
|
|
764
763
|
project: "mlrun.projects.MlrunProject",
|
|
765
764
|
workflow_spec: WorkflowSpec,
|
|
766
|
-
name: str = None,
|
|
767
|
-
workflow_handler: typing.Union[str, typing.Callable] = None,
|
|
765
|
+
name: typing.Optional[str] = None,
|
|
766
|
+
workflow_handler: typing.Optional[typing.Union[str, typing.Callable]] = None,
|
|
768
767
|
secrets: mlrun.secrets.SecretsStore = None,
|
|
769
|
-
artifact_path: str = None,
|
|
770
|
-
namespace: str = None,
|
|
771
|
-
source: str = None,
|
|
772
|
-
notifications: list[mlrun.model.Notification] = None,
|
|
768
|
+
artifact_path: typing.Optional[str] = None,
|
|
769
|
+
namespace: typing.Optional[str] = None,
|
|
770
|
+
source: typing.Optional[str] = None,
|
|
771
|
+
notifications: typing.Optional[list[mlrun.model.Notification]] = None,
|
|
773
772
|
) -> typing.Optional[_PipelineRunStatus]:
|
|
774
773
|
workflow_name = normalize_workflow_name(name=name, project_name=project.name)
|
|
775
774
|
workflow_id = None
|
|
@@ -890,7 +889,7 @@ class _RemoteRunner(_PipelineRunner):
|
|
|
890
889
|
timeout=None,
|
|
891
890
|
expected_statuses=None,
|
|
892
891
|
notifiers: mlrun.utils.notifications.CustomNotificationPusher = None,
|
|
893
|
-
inner_engine: type[_PipelineRunner] = None,
|
|
892
|
+
inner_engine: typing.Optional[type[_PipelineRunner]] = None,
|
|
894
893
|
):
|
|
895
894
|
inner_engine = inner_engine or _KFPRunner
|
|
896
895
|
if inner_engine.engine == _KFPRunner.engine:
|
|
@@ -984,43 +983,34 @@ def github_webhook(request):
|
|
|
984
983
|
return {"msg": "pushed"}
|
|
985
984
|
|
|
986
985
|
|
|
987
|
-
def load_and_run(
|
|
988
|
-
"""
|
|
989
|
-
This function serves as an alias to `load_and_run_workflow`,
|
|
990
|
-
allowing to continue using `load_and_run` without modifying existing workflows or exported runs.
|
|
991
|
-
This approach ensures backward compatibility,
|
|
992
|
-
while directing all new calls to the updated `load_and_run_workflow` function.
|
|
993
|
-
"""
|
|
994
|
-
kwargs.pop("load_only", None)
|
|
995
|
-
kwargs.pop("save", None)
|
|
996
|
-
load_and_run_workflow(context, *args, **kwargs)
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
def load_and_run_workflow(
|
|
986
|
+
def load_and_run(
|
|
1000
987
|
context: mlrun.execution.MLClientCtx,
|
|
1001
|
-
url: str = None,
|
|
988
|
+
url: typing.Optional[str] = None,
|
|
1002
989
|
project_name: str = "",
|
|
1003
|
-
init_git: bool = None,
|
|
1004
|
-
subpath: str = None,
|
|
990
|
+
init_git: typing.Optional[bool] = None,
|
|
991
|
+
subpath: typing.Optional[str] = None,
|
|
1005
992
|
clone: bool = False,
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
993
|
+
save: bool = True,
|
|
994
|
+
workflow_name: typing.Optional[str] = None,
|
|
995
|
+
workflow_path: typing.Optional[str] = None,
|
|
996
|
+
workflow_arguments: typing.Optional[dict[str, typing.Any]] = None,
|
|
997
|
+
artifact_path: typing.Optional[str] = None,
|
|
998
|
+
workflow_handler: typing.Optional[typing.Union[str, typing.Callable]] = None,
|
|
999
|
+
namespace: typing.Optional[str] = None,
|
|
1012
1000
|
sync: bool = False,
|
|
1013
1001
|
dirty: bool = False,
|
|
1014
|
-
engine: str = None,
|
|
1015
|
-
local: bool = None,
|
|
1002
|
+
engine: typing.Optional[str] = None,
|
|
1003
|
+
local: typing.Optional[bool] = None,
|
|
1016
1004
|
schedule: typing.Union[str, mlrun.common.schemas.ScheduleCronTrigger] = None,
|
|
1017
|
-
cleanup_ttl: int = None,
|
|
1005
|
+
cleanup_ttl: typing.Optional[int] = None,
|
|
1006
|
+
load_only: bool = False,
|
|
1018
1007
|
wait_for_completion: bool = False,
|
|
1019
|
-
project_context: str = None,
|
|
1008
|
+
project_context: typing.Optional[str] = None,
|
|
1020
1009
|
):
|
|
1021
1010
|
"""
|
|
1022
1011
|
Auxiliary function that the RemoteRunner run once or run every schedule.
|
|
1023
1012
|
This function loads a project from a given remote source and then runs the workflow.
|
|
1013
|
+
|
|
1024
1014
|
:param context: mlrun context.
|
|
1025
1015
|
:param url: remote url that represents the project's source.
|
|
1026
1016
|
See 'mlrun.load_project()' for details
|
|
@@ -1028,6 +1018,7 @@ def load_and_run_workflow(
|
|
|
1028
1018
|
:param init_git: if True, will git init the context dir
|
|
1029
1019
|
:param subpath: project subpath (within the archive)
|
|
1030
1020
|
:param clone: if True, always clone (delete any existing content)
|
|
1021
|
+
:param save: whether to save the created project and artifact in the DB
|
|
1031
1022
|
:param workflow_name: name of the workflow
|
|
1032
1023
|
:param workflow_path: url to a workflow file, if not a project workflow
|
|
1033
1024
|
:param workflow_arguments: kubeflow pipelines arguments (parameters)
|
|
@@ -1043,31 +1034,48 @@ def load_and_run_workflow(
|
|
|
1043
1034
|
:param schedule: ScheduleCronTrigger class instance or a standard crontab expression string
|
|
1044
1035
|
:param cleanup_ttl: pipeline cleanup ttl in secs (time to wait after workflow completion, at which point the
|
|
1045
1036
|
workflow and all its resources are deleted)
|
|
1037
|
+
:param load_only: for just loading the project, inner use.
|
|
1046
1038
|
:param wait_for_completion: wait for workflow completion before returning
|
|
1047
1039
|
:param project_context: project context path (used for loading the project)
|
|
1048
1040
|
"""
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1041
|
+
try:
|
|
1042
|
+
project = mlrun.load_project(
|
|
1043
|
+
context=project_context or f"./{project_name}",
|
|
1044
|
+
url=url,
|
|
1045
|
+
name=project_name,
|
|
1046
|
+
init_git=init_git,
|
|
1047
|
+
subpath=subpath,
|
|
1048
|
+
clone=clone,
|
|
1049
|
+
save=save,
|
|
1050
|
+
sync_functions=True,
|
|
1051
|
+
)
|
|
1052
|
+
except Exception as error:
|
|
1053
|
+
if schedule:
|
|
1054
|
+
notification_pusher = mlrun.utils.notifications.CustomNotificationPusher(
|
|
1055
|
+
["slack"]
|
|
1056
|
+
)
|
|
1057
|
+
url = get_ui_url(project_name, context.uid)
|
|
1058
|
+
link = f"<{url}|*view workflow job details*>"
|
|
1059
|
+
message = (
|
|
1060
|
+
f":x: Failed to run scheduled workflow {workflow_name} in Project {project_name} !\n"
|
|
1061
|
+
f"error: ```{error}```\n{link}"
|
|
1062
|
+
)
|
|
1063
|
+
# Sending Slack Notification without losing the original error:
|
|
1064
|
+
try:
|
|
1065
|
+
notification_pusher.push(
|
|
1066
|
+
message=message,
|
|
1067
|
+
severity=mlrun.common.schemas.NotificationSeverity.ERROR,
|
|
1068
|
+
)
|
|
1063
1069
|
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1070
|
+
except Exception as exc:
|
|
1071
|
+
logger.error("Failed to send slack notification", exc=err_to_str(exc))
|
|
1072
|
+
|
|
1073
|
+
raise error
|
|
1074
|
+
|
|
1075
|
+
context.logger.info(f"Loaded project {project.name} successfully")
|
|
1076
|
+
|
|
1077
|
+
if load_only:
|
|
1078
|
+
return
|
|
1071
1079
|
|
|
1072
1080
|
# extract "start" notification if exists
|
|
1073
1081
|
start_notifications = [
|
|
@@ -1100,156 +1108,18 @@ def load_and_run_workflow(
|
|
|
1100
1108
|
raise RuntimeError(f"Workflow {workflow_log_message} failed") from run.exc
|
|
1101
1109
|
|
|
1102
1110
|
if wait_for_completion:
|
|
1103
|
-
handle_workflow_completion(
|
|
1104
|
-
run=run,
|
|
1105
|
-
project=project,
|
|
1106
|
-
context=context,
|
|
1107
|
-
workflow_log_message=workflow_log_message,
|
|
1108
|
-
)
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
def pull_remote_project_files(
|
|
1112
|
-
context: mlrun.execution.MLClientCtx,
|
|
1113
|
-
project_context: str,
|
|
1114
|
-
url: str,
|
|
1115
|
-
project_name: str,
|
|
1116
|
-
init_git: typing.Optional[bool],
|
|
1117
|
-
subpath: typing.Optional[str],
|
|
1118
|
-
clone: bool,
|
|
1119
|
-
schedule: typing.Optional[
|
|
1120
|
-
typing.Union[str, mlrun.common.schemas.ScheduleCronTrigger]
|
|
1121
|
-
],
|
|
1122
|
-
workflow_name: typing.Optional[str],
|
|
1123
|
-
) -> None:
|
|
1124
|
-
"""
|
|
1125
|
-
Load the project to clone remote files if they exist.
|
|
1126
|
-
If an exception occurs during project loading, send a notification if the workflow is scheduled.
|
|
1127
|
-
|
|
1128
|
-
:param context: MLRun execution context.
|
|
1129
|
-
:param project_context: Path to the project context.
|
|
1130
|
-
:param url: URL of the project repository.
|
|
1131
|
-
:param project_name: Name of the project.
|
|
1132
|
-
:param init_git: Initialize a git repository.
|
|
1133
|
-
:param subpath: Project subpath within the repository.
|
|
1134
|
-
:param clone: Whether to clone the repository.
|
|
1135
|
-
:param schedule: Schedule for running the workflow.
|
|
1136
|
-
:param workflow_name: Name of the workflow to run.
|
|
1137
|
-
"""
|
|
1138
|
-
try:
|
|
1139
|
-
# Load the project to clone remote files if they exist.
|
|
1140
|
-
# Using save=False to avoid overriding changes from the database if it already exists.
|
|
1141
|
-
mlrun.load_project(
|
|
1142
|
-
context=project_context,
|
|
1143
|
-
url=url,
|
|
1144
|
-
name=project_name,
|
|
1145
|
-
init_git=init_git,
|
|
1146
|
-
subpath=subpath,
|
|
1147
|
-
clone=clone,
|
|
1148
|
-
save=False,
|
|
1149
|
-
)
|
|
1150
|
-
except Exception as error:
|
|
1151
|
-
notify_scheduled_workflow_failure(
|
|
1152
|
-
schedule=schedule,
|
|
1153
|
-
project_name=project_name,
|
|
1154
|
-
workflow_name=workflow_name,
|
|
1155
|
-
error=error,
|
|
1156
|
-
context_uid=context.uid,
|
|
1157
|
-
)
|
|
1158
|
-
raise error
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
def notify_scheduled_workflow_failure(
|
|
1162
|
-
schedule,
|
|
1163
|
-
project_name: str,
|
|
1164
|
-
workflow_name: str,
|
|
1165
|
-
error: Exception,
|
|
1166
|
-
context_uid: str,
|
|
1167
|
-
) -> None:
|
|
1168
|
-
if schedule:
|
|
1169
|
-
notification_pusher = mlrun.utils.notifications.CustomNotificationPusher(
|
|
1170
|
-
["slack"]
|
|
1171
|
-
)
|
|
1172
|
-
url = get_ui_url(project_name, context_uid)
|
|
1173
|
-
link = f"<{url}|*view workflow job details*>"
|
|
1174
|
-
message = (
|
|
1175
|
-
f":x: Failed to run scheduled workflow {workflow_name} "
|
|
1176
|
-
f"in Project {project_name}!\n"
|
|
1177
|
-
f"Error: ```{err_to_str(error)}```\n{link}"
|
|
1178
|
-
)
|
|
1179
|
-
# Sending Slack Notification without losing the original error:
|
|
1180
1111
|
try:
|
|
1181
|
-
|
|
1182
|
-
message=message,
|
|
1183
|
-
severity=mlrun.common.schemas.NotificationSeverity.ERROR,
|
|
1184
|
-
)
|
|
1185
|
-
|
|
1112
|
+
run.wait_for_completion()
|
|
1186
1113
|
except Exception as exc:
|
|
1187
|
-
logger.error(
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
project,
|
|
1193
|
-
context: mlrun.execution.MLClientCtx,
|
|
1194
|
-
workflow_log_message: str,
|
|
1195
|
-
) -> None:
|
|
1196
|
-
"""
|
|
1197
|
-
Handle workflow completion by waiting for it to finish and logging the final state.
|
|
1198
|
-
|
|
1199
|
-
:param run: Run object containing workflow execution details.
|
|
1200
|
-
:param project: MLRun project object.
|
|
1201
|
-
:param context: MLRun execution context.
|
|
1202
|
-
:param workflow_log_message: Message used for logging.
|
|
1203
|
-
"""
|
|
1204
|
-
try:
|
|
1205
|
-
run.wait_for_completion()
|
|
1206
|
-
except Exception as exc:
|
|
1207
|
-
mlrun.utils.logger.error(
|
|
1208
|
-
"Failed waiting for workflow completion",
|
|
1209
|
-
workflow=workflow_log_message,
|
|
1210
|
-
exc=err_to_str(exc),
|
|
1211
|
-
)
|
|
1212
|
-
|
|
1213
|
-
pipeline_state, _, _ = project.get_run_status(run)
|
|
1214
|
-
context.log_result(key="workflow_state", value=pipeline_state, commit=True)
|
|
1215
|
-
if pipeline_state != mlrun_pipelines.common.models.RunStatuses.succeeded:
|
|
1216
|
-
raise RuntimeError(
|
|
1217
|
-
f"Workflow {workflow_log_message} failed, state={pipeline_state}"
|
|
1218
|
-
)
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
def import_remote_project(
|
|
1222
|
-
context: mlrun.execution.MLClientCtx,
|
|
1223
|
-
url: str = None,
|
|
1224
|
-
project_name: str = "",
|
|
1225
|
-
init_git: bool = None,
|
|
1226
|
-
subpath: str = None,
|
|
1227
|
-
clone: bool = False,
|
|
1228
|
-
save: bool = True,
|
|
1229
|
-
project_context: str = None,
|
|
1230
|
-
):
|
|
1231
|
-
"""
|
|
1232
|
-
This function loads a project from a given remote source.
|
|
1233
|
-
|
|
1234
|
-
:param context: mlrun context.
|
|
1235
|
-
:param url: remote url that represents the project's source.
|
|
1236
|
-
See 'mlrun.load_project()' for details
|
|
1237
|
-
:param project_name: project name
|
|
1238
|
-
:param init_git: if True, will git init the context dir
|
|
1239
|
-
:param subpath: project subpath (within the archive)
|
|
1240
|
-
:param clone: if True, always clone (delete any existing content)
|
|
1241
|
-
:param save: whether to save the created project and artifact in the DB
|
|
1242
|
-
:param project_context: project context path (used for loading the project)
|
|
1243
|
-
"""
|
|
1244
|
-
project = mlrun.load_project(
|
|
1245
|
-
context=project_context or f"./{project_name}",
|
|
1246
|
-
url=url,
|
|
1247
|
-
name=project_name,
|
|
1248
|
-
init_git=init_git,
|
|
1249
|
-
subpath=subpath,
|
|
1250
|
-
clone=clone,
|
|
1251
|
-
save=save,
|
|
1252
|
-
sync_functions=True,
|
|
1253
|
-
)
|
|
1114
|
+
logger.error(
|
|
1115
|
+
"Failed waiting for workflow completion",
|
|
1116
|
+
workflow=workflow_log_message,
|
|
1117
|
+
exc=err_to_str(exc),
|
|
1118
|
+
)
|
|
1254
1119
|
|
|
1255
|
-
|
|
1120
|
+
pipeline_state, _, _ = project.get_run_status(run)
|
|
1121
|
+
context.log_result(key="workflow_state", value=pipeline_state, commit=True)
|
|
1122
|
+
if pipeline_state != mlrun_pipelines.common.models.RunStatuses.succeeded:
|
|
1123
|
+
raise RuntimeError(
|
|
1124
|
+
f"Workflow {workflow_log_message} failed, state={pipeline_state}"
|
|
1125
|
+
)
|