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/projects/pipelines.py
CHANGED
|
@@ -20,19 +20,18 @@ 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_workflow_url,
|
|
36
35
|
logger,
|
|
37
36
|
normalize_workflow_name,
|
|
38
37
|
retry_until_successful,
|
|
@@ -40,7 +39,7 @@ from mlrun.utils import (
|
|
|
40
39
|
|
|
41
40
|
from ..common.helpers import parse_versioned_object_uri
|
|
42
41
|
from ..config import config
|
|
43
|
-
from ..run import _run_pipeline, wait_for_pipeline_completion
|
|
42
|
+
from ..run import _run_pipeline, retry_pipeline, wait_for_pipeline_completion
|
|
44
43
|
from ..runtimes.pod import AutoMountType
|
|
45
44
|
|
|
46
45
|
|
|
@@ -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
|
|
@@ -422,6 +421,13 @@ class _PipelineRunStatus:
|
|
|
422
421
|
self._state = returned_state
|
|
423
422
|
return self._state
|
|
424
423
|
|
|
424
|
+
def retry(self) -> str:
|
|
425
|
+
run_id = self._engine.retry(
|
|
426
|
+
self,
|
|
427
|
+
project=self.project,
|
|
428
|
+
)
|
|
429
|
+
return run_id
|
|
430
|
+
|
|
425
431
|
def __str__(self):
|
|
426
432
|
return str(self.run_id)
|
|
427
433
|
|
|
@@ -441,6 +447,17 @@ class _PipelineRunner(abc.ABC):
|
|
|
441
447
|
f"Save operation not supported in {cls.engine} pipeline engine"
|
|
442
448
|
)
|
|
443
449
|
|
|
450
|
+
@classmethod
|
|
451
|
+
@abc.abstractmethod
|
|
452
|
+
def retry(
|
|
453
|
+
cls,
|
|
454
|
+
run: "_PipelineRunStatus",
|
|
455
|
+
project: typing.Optional["mlrun.projects.MlrunProject"] = None,
|
|
456
|
+
) -> str:
|
|
457
|
+
raise NotImplementedError(
|
|
458
|
+
f"Retry operation not supported in {cls.engine} pipeline engine"
|
|
459
|
+
)
|
|
460
|
+
|
|
444
461
|
@classmethod
|
|
445
462
|
@abc.abstractmethod
|
|
446
463
|
def run(
|
|
@@ -453,7 +470,8 @@ class _PipelineRunner(abc.ABC):
|
|
|
453
470
|
artifact_path=None,
|
|
454
471
|
namespace=None,
|
|
455
472
|
source=None,
|
|
456
|
-
notifications: list[mlrun.model.Notification] = None,
|
|
473
|
+
notifications: typing.Optional[list[mlrun.model.Notification]] = None,
|
|
474
|
+
context: typing.Optional[mlrun.execution.MLClientCtx] = None,
|
|
457
475
|
) -> _PipelineRunStatus:
|
|
458
476
|
pass
|
|
459
477
|
|
|
@@ -463,7 +481,7 @@ class _PipelineRunner(abc.ABC):
|
|
|
463
481
|
run: "_PipelineRunStatus",
|
|
464
482
|
project: typing.Optional["mlrun.projects.MlrunProject"] = None,
|
|
465
483
|
timeout: typing.Optional[int] = None,
|
|
466
|
-
expected_statuses: list[str] = None,
|
|
484
|
+
expected_statuses: typing.Optional[list[str]] = None,
|
|
467
485
|
):
|
|
468
486
|
pass
|
|
469
487
|
|
|
@@ -505,11 +523,12 @@ class _PipelineRunner(abc.ABC):
|
|
|
505
523
|
text = _PipelineRunner._generate_workflow_finished_message(
|
|
506
524
|
run.run_id, errors_counter, run._state
|
|
507
525
|
)
|
|
508
|
-
|
|
509
526
|
notifiers = notifiers or project.notifiers
|
|
510
527
|
if notifiers:
|
|
511
528
|
notifiers.push(text, "info", runs)
|
|
512
529
|
|
|
530
|
+
project.push_pipeline_notification_kfp_runner(run.run_id, run._state, text)
|
|
531
|
+
|
|
513
532
|
if raise_error:
|
|
514
533
|
raise raise_error
|
|
515
534
|
return state or run._state, errors_counter, text
|
|
@@ -577,7 +596,8 @@ class _KFPRunner(_PipelineRunner):
|
|
|
577
596
|
artifact_path=None,
|
|
578
597
|
namespace=None,
|
|
579
598
|
source=None,
|
|
580
|
-
notifications: list[mlrun.model.Notification] = None,
|
|
599
|
+
notifications: typing.Optional[list[mlrun.model.Notification]] = None,
|
|
600
|
+
context: typing.Optional[mlrun.execution.MLClientCtx] = None,
|
|
581
601
|
) -> _PipelineRunStatus:
|
|
582
602
|
pipeline_context.set(project, workflow_spec)
|
|
583
603
|
workflow_handler = _PipelineRunner._get_handler(
|
|
@@ -595,11 +615,21 @@ class _KFPRunner(_PipelineRunner):
|
|
|
595
615
|
"Notifications will only be sent if you wait for pipeline completion. "
|
|
596
616
|
"Some of the features (like setting message or severity level) are not supported."
|
|
597
617
|
)
|
|
598
|
-
# for start message, fallback to old notification behavior
|
|
599
618
|
for notification in notifications or []:
|
|
600
619
|
params = notification.params
|
|
601
620
|
params.update(notification.secret_params)
|
|
602
|
-
project.notifiers.add_notification(
|
|
621
|
+
project.notifiers.add_notification(
|
|
622
|
+
notification_type=notification.kind,
|
|
623
|
+
params=params,
|
|
624
|
+
name=notification.name,
|
|
625
|
+
message=notification.message,
|
|
626
|
+
severity=notification.severity,
|
|
627
|
+
when=notification.when,
|
|
628
|
+
condition=notification.condition,
|
|
629
|
+
secret_params=notification.secret_params,
|
|
630
|
+
)
|
|
631
|
+
|
|
632
|
+
project.spec.notifications = project.notifiers.server_notifications
|
|
603
633
|
|
|
604
634
|
run_id = _run_pipeline(
|
|
605
635
|
workflow_handler,
|
|
@@ -627,21 +657,51 @@ class _KFPRunner(_PipelineRunner):
|
|
|
627
657
|
func_name=func.metadata.name,
|
|
628
658
|
exc_info=err_to_str(exc),
|
|
629
659
|
)
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
run_id
|
|
634
|
-
True,
|
|
660
|
+
|
|
661
|
+
# Pushing only relevant notification for the client (ipython and console)
|
|
662
|
+
project.notifiers.push_pipeline_start_message_from_client(
|
|
663
|
+
project.metadata.name, pipeline_id=run_id
|
|
635
664
|
)
|
|
665
|
+
|
|
666
|
+
if context:
|
|
667
|
+
project.notifiers.push_pipeline_start_message(
|
|
668
|
+
project.metadata.name,
|
|
669
|
+
context.uid,
|
|
670
|
+
)
|
|
671
|
+
else:
|
|
672
|
+
project.push_pipeline_notification_kfp_runner(
|
|
673
|
+
run_id,
|
|
674
|
+
mlrun_pipelines.common.models.RunStatuses.running,
|
|
675
|
+
f"Workflow {run_id} started in project {project.metadata.name}",
|
|
676
|
+
notifications,
|
|
677
|
+
)
|
|
636
678
|
pipeline_context.clear()
|
|
637
679
|
return _PipelineRunStatus(run_id, cls, project=project, workflow=workflow_spec)
|
|
638
680
|
|
|
681
|
+
@classmethod
|
|
682
|
+
def retry(
|
|
683
|
+
cls,
|
|
684
|
+
run: "_PipelineRunStatus",
|
|
685
|
+
project: typing.Optional["mlrun.projects.MlrunProject"] = None,
|
|
686
|
+
) -> str:
|
|
687
|
+
project_name = project.metadata.name if project else ""
|
|
688
|
+
logger.info(
|
|
689
|
+
"Retrying pipeline",
|
|
690
|
+
run_id=run.run_id,
|
|
691
|
+
project=project_name,
|
|
692
|
+
)
|
|
693
|
+
run_id = retry_pipeline(
|
|
694
|
+
run.run_id,
|
|
695
|
+
project=project_name,
|
|
696
|
+
)
|
|
697
|
+
return run_id
|
|
698
|
+
|
|
639
699
|
@staticmethod
|
|
640
700
|
def wait_for_completion(
|
|
641
701
|
run: "_PipelineRunStatus",
|
|
642
702
|
project: typing.Optional["mlrun.projects.MlrunProject"] = None,
|
|
643
703
|
timeout: typing.Optional[int] = None,
|
|
644
|
-
expected_statuses: list[str] = None,
|
|
704
|
+
expected_statuses: typing.Optional[list[str]] = None,
|
|
645
705
|
):
|
|
646
706
|
project_name = project.metadata.name if project else ""
|
|
647
707
|
logger.info(
|
|
@@ -686,7 +746,8 @@ class _LocalRunner(_PipelineRunner):
|
|
|
686
746
|
artifact_path=None,
|
|
687
747
|
namespace=None,
|
|
688
748
|
source=None,
|
|
689
|
-
notifications: list[mlrun.model.Notification] = None,
|
|
749
|
+
notifications: typing.Optional[list[mlrun.model.Notification]] = None,
|
|
750
|
+
context: typing.Optional[mlrun.execution.MLClientCtx] = None,
|
|
690
751
|
) -> _PipelineRunStatus:
|
|
691
752
|
pipeline_context.set(project, workflow_spec)
|
|
692
753
|
workflow_handler = _PipelineRunner._get_handler(
|
|
@@ -708,7 +769,8 @@ class _LocalRunner(_PipelineRunner):
|
|
|
708
769
|
project.set_source(source=source)
|
|
709
770
|
pipeline_context.workflow_artifact_path = artifact_path
|
|
710
771
|
|
|
711
|
-
|
|
772
|
+
# TODO: we should create endpoint for sending custom notification from BE
|
|
773
|
+
project.notifiers.push_pipeline_start_message_from_client(
|
|
712
774
|
project.metadata.name, pipeline_id=workflow_id
|
|
713
775
|
)
|
|
714
776
|
err = None
|
|
@@ -763,13 +825,14 @@ class _RemoteRunner(_PipelineRunner):
|
|
|
763
825
|
cls,
|
|
764
826
|
project: "mlrun.projects.MlrunProject",
|
|
765
827
|
workflow_spec: WorkflowSpec,
|
|
766
|
-
name: str = None,
|
|
767
|
-
workflow_handler: typing.Union[str, typing.Callable] = None,
|
|
828
|
+
name: typing.Optional[str] = None,
|
|
829
|
+
workflow_handler: typing.Optional[typing.Union[str, typing.Callable]] = None,
|
|
768
830
|
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,
|
|
831
|
+
artifact_path: typing.Optional[str] = None,
|
|
832
|
+
namespace: typing.Optional[str] = None,
|
|
833
|
+
source: typing.Optional[str] = None,
|
|
834
|
+
notifications: typing.Optional[list[mlrun.model.Notification]] = None,
|
|
835
|
+
context: typing.Optional[mlrun.execution.MLClientCtx] = None,
|
|
773
836
|
) -> typing.Optional[_PipelineRunStatus]:
|
|
774
837
|
workflow_name = normalize_workflow_name(name=name, project_name=project.name)
|
|
775
838
|
workflow_id = None
|
|
@@ -890,7 +953,7 @@ class _RemoteRunner(_PipelineRunner):
|
|
|
890
953
|
timeout=None,
|
|
891
954
|
expected_statuses=None,
|
|
892
955
|
notifiers: mlrun.utils.notifications.CustomNotificationPusher = None,
|
|
893
|
-
inner_engine: type[_PipelineRunner] = None,
|
|
956
|
+
inner_engine: typing.Optional[type[_PipelineRunner]] = None,
|
|
894
957
|
):
|
|
895
958
|
inner_engine = inner_engine or _KFPRunner
|
|
896
959
|
if inner_engine.engine == _KFPRunner.engine:
|
|
@@ -998,25 +1061,25 @@ def load_and_run(context, *args, **kwargs):
|
|
|
998
1061
|
|
|
999
1062
|
def load_and_run_workflow(
|
|
1000
1063
|
context: mlrun.execution.MLClientCtx,
|
|
1001
|
-
url: str = None,
|
|
1064
|
+
url: typing.Optional[str] = None,
|
|
1002
1065
|
project_name: str = "",
|
|
1003
|
-
init_git: bool = None,
|
|
1004
|
-
subpath: str = None,
|
|
1066
|
+
init_git: typing.Optional[bool] = None,
|
|
1067
|
+
subpath: typing.Optional[str] = None,
|
|
1005
1068
|
clone: bool = False,
|
|
1006
|
-
workflow_name: str = None,
|
|
1007
|
-
workflow_path: str = None,
|
|
1008
|
-
workflow_arguments: dict[str, typing.Any] = None,
|
|
1009
|
-
artifact_path: str = None,
|
|
1010
|
-
workflow_handler: typing.Union[str, typing.Callable] = None,
|
|
1011
|
-
namespace: str = None,
|
|
1069
|
+
workflow_name: typing.Optional[str] = None,
|
|
1070
|
+
workflow_path: typing.Optional[str] = None,
|
|
1071
|
+
workflow_arguments: typing.Optional[dict[str, typing.Any]] = None,
|
|
1072
|
+
artifact_path: typing.Optional[str] = None,
|
|
1073
|
+
workflow_handler: typing.Optional[typing.Union[str, typing.Callable]] = None,
|
|
1074
|
+
namespace: typing.Optional[str] = None,
|
|
1012
1075
|
sync: bool = False,
|
|
1013
1076
|
dirty: bool = False,
|
|
1014
|
-
engine: str = None,
|
|
1015
|
-
local: bool = None,
|
|
1077
|
+
engine: typing.Optional[str] = None,
|
|
1078
|
+
local: typing.Optional[bool] = None,
|
|
1016
1079
|
schedule: typing.Union[str, mlrun.common.schemas.ScheduleCronTrigger] = None,
|
|
1017
|
-
cleanup_ttl: int = None,
|
|
1080
|
+
cleanup_ttl: typing.Optional[int] = None,
|
|
1018
1081
|
wait_for_completion: bool = False,
|
|
1019
|
-
project_context: str = None,
|
|
1082
|
+
project_context: typing.Optional[str] = None,
|
|
1020
1083
|
):
|
|
1021
1084
|
"""
|
|
1022
1085
|
Auxiliary function that the RemoteRunner run once or run every schedule.
|
|
@@ -1076,6 +1139,11 @@ def load_and_run_workflow(
|
|
|
1076
1139
|
if "running" in notification.when
|
|
1077
1140
|
]
|
|
1078
1141
|
|
|
1142
|
+
# Prevent redundant notifications for run completion by ensuring that notifications are only triggered when the run
|
|
1143
|
+
# reaches the "running" state, as the server already handles the completion notifications.
|
|
1144
|
+
for notification in start_notifications:
|
|
1145
|
+
notification.when = ["running"]
|
|
1146
|
+
|
|
1079
1147
|
workflow_log_message = workflow_name or workflow_path
|
|
1080
1148
|
context.logger.info(f"Running workflow {workflow_log_message} from remote")
|
|
1081
1149
|
run = project.run(
|
|
@@ -1092,6 +1160,7 @@ def load_and_run_workflow(
|
|
|
1092
1160
|
engine=engine,
|
|
1093
1161
|
local=local,
|
|
1094
1162
|
notifications=start_notifications,
|
|
1163
|
+
context=context,
|
|
1095
1164
|
)
|
|
1096
1165
|
context.log_result(key="workflow_id", value=run.run_id)
|
|
1097
1166
|
context.log_result(key="engine", value=run._engine.engine, commit=True)
|
|
@@ -1169,7 +1238,7 @@ def notify_scheduled_workflow_failure(
|
|
|
1169
1238
|
notification_pusher = mlrun.utils.notifications.CustomNotificationPusher(
|
|
1170
1239
|
["slack"]
|
|
1171
1240
|
)
|
|
1172
|
-
url =
|
|
1241
|
+
url = get_workflow_url(project_name, context_uid)
|
|
1173
1242
|
link = f"<{url}|*view workflow job details*>"
|
|
1174
1243
|
message = (
|
|
1175
1244
|
f":x: Failed to run scheduled workflow {workflow_name} "
|
|
@@ -1220,13 +1289,13 @@ def handle_workflow_completion(
|
|
|
1220
1289
|
|
|
1221
1290
|
def import_remote_project(
|
|
1222
1291
|
context: mlrun.execution.MLClientCtx,
|
|
1223
|
-
url: str = None,
|
|
1292
|
+
url: typing.Optional[str] = None,
|
|
1224
1293
|
project_name: str = "",
|
|
1225
|
-
init_git: bool = None,
|
|
1226
|
-
subpath: str = None,
|
|
1294
|
+
init_git: typing.Optional[bool] = None,
|
|
1295
|
+
subpath: typing.Optional[str] = None,
|
|
1227
1296
|
clone: bool = False,
|
|
1228
1297
|
save: bool = True,
|
|
1229
|
-
project_context: str = None,
|
|
1298
|
+
project_context: typing.Optional[str] = None,
|
|
1230
1299
|
):
|
|
1231
1300
|
"""
|
|
1232
1301
|
This function loads a project from a given remote source.
|