mlrun 1.8.0rc1__py3-none-any.whl → 1.8.0rc3__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 +5 -7
- mlrun/__main__.py +1 -1
- mlrun/artifacts/__init__.py +1 -0
- mlrun/artifacts/document.py +313 -0
- mlrun/artifacts/manager.py +2 -0
- mlrun/common/formatters/project.py +9 -0
- mlrun/common/schemas/__init__.py +4 -0
- mlrun/common/schemas/alert.py +31 -18
- mlrun/common/schemas/api_gateway.py +3 -3
- mlrun/common/schemas/artifact.py +7 -7
- mlrun/common/schemas/auth.py +6 -4
- mlrun/common/schemas/background_task.py +7 -7
- mlrun/common/schemas/client_spec.py +2 -2
- mlrun/common/schemas/clusterization_spec.py +2 -2
- mlrun/common/schemas/common.py +5 -5
- 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/grafana.py +1 -1
- mlrun/common/schemas/model_monitoring/model_endpoint_v2.py +1 -1
- mlrun/common/schemas/model_monitoring/model_endpoints.py +1 -1
- mlrun/common/schemas/notification.py +18 -3
- mlrun/common/schemas/object.py +1 -1
- mlrun/common/schemas/pagination.py +4 -4
- mlrun/common/schemas/partition.py +16 -1
- mlrun/common/schemas/pipeline.py +2 -2
- mlrun/common/schemas/project.py +22 -17
- mlrun/common/schemas/runs.py +2 -2
- mlrun/common/schemas/runtime_resource.py +5 -5
- mlrun/common/schemas/schedule.py +1 -1
- mlrun/common/schemas/secret.py +1 -1
- mlrun/common/schemas/tag.py +3 -3
- mlrun/common/schemas/workflow.py +5 -5
- mlrun/config.py +23 -1
- mlrun/datastore/datastore_profile.py +38 -19
- mlrun/datastore/vectorstore.py +186 -0
- mlrun/db/base.py +58 -6
- mlrun/db/httpdb.py +267 -15
- mlrun/db/nopdb.py +44 -5
- mlrun/execution.py +47 -1
- mlrun/model.py +2 -2
- mlrun/model_monitoring/applications/results.py +2 -2
- mlrun/model_monitoring/db/tsdb/base.py +2 -2
- mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +37 -13
- mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +32 -40
- mlrun/model_monitoring/helpers.py +4 -10
- mlrun/model_monitoring/stream_processing.py +14 -11
- mlrun/platforms/__init__.py +44 -13
- mlrun/projects/__init__.py +6 -1
- mlrun/projects/pipelines.py +184 -55
- mlrun/projects/project.py +309 -33
- mlrun/run.py +4 -1
- mlrun/runtimes/base.py +2 -1
- mlrun/runtimes/mounts.py +572 -0
- mlrun/runtimes/nuclio/function.py +1 -2
- mlrun/runtimes/pod.py +82 -18
- mlrun/runtimes/remotesparkjob.py +1 -1
- mlrun/runtimes/sparkjob/spark3job.py +1 -1
- mlrun/utils/clones.py +1 -1
- mlrun/utils/helpers.py +12 -2
- mlrun/utils/logger.py +2 -2
- mlrun/utils/notifications/notification/__init__.py +22 -19
- mlrun/utils/notifications/notification/base.py +12 -12
- mlrun/utils/notifications/notification/console.py +6 -6
- mlrun/utils/notifications/notification/git.py +6 -6
- mlrun/utils/notifications/notification/ipython.py +6 -6
- mlrun/utils/notifications/notification/mail.py +149 -0
- mlrun/utils/notifications/notification/slack.py +6 -6
- mlrun/utils/notifications/notification/webhook.py +6 -6
- mlrun/utils/notifications/notification_pusher.py +20 -12
- mlrun/utils/regex.py +2 -0
- mlrun/utils/version/version.json +2 -2
- {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/METADATA +190 -186
- {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/RECORD +83 -79
- {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/WHEEL +1 -1
- {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/LICENSE +0 -0
- {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/entry_points.txt +0 -0
- {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/top_level.txt +0 -0
mlrun/projects/pipelines.py
CHANGED
|
@@ -983,14 +983,25 @@ def github_webhook(request):
|
|
|
983
983
|
return {"msg": "pushed"}
|
|
984
984
|
|
|
985
985
|
|
|
986
|
-
def load_and_run(
|
|
986
|
+
def load_and_run(context, *args, **kwargs):
|
|
987
|
+
"""
|
|
988
|
+
This function serves as an alias to `load_and_run_workflow`,
|
|
989
|
+
allowing to continue using `load_and_run` without modifying existing workflows or exported runs.
|
|
990
|
+
This approach ensures backward compatibility,
|
|
991
|
+
while directing all new calls to the updated `load_and_run_workflow` function.
|
|
992
|
+
"""
|
|
993
|
+
kwargs.pop("load_only", None)
|
|
994
|
+
kwargs.pop("save", None)
|
|
995
|
+
load_and_run_workflow(context, *args, **kwargs)
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
def load_and_run_workflow(
|
|
987
999
|
context: mlrun.execution.MLClientCtx,
|
|
988
1000
|
url: typing.Optional[str] = None,
|
|
989
1001
|
project_name: str = "",
|
|
990
1002
|
init_git: typing.Optional[bool] = None,
|
|
991
1003
|
subpath: typing.Optional[str] = None,
|
|
992
1004
|
clone: bool = False,
|
|
993
|
-
save: bool = True,
|
|
994
1005
|
workflow_name: typing.Optional[str] = None,
|
|
995
1006
|
workflow_path: typing.Optional[str] = None,
|
|
996
1007
|
workflow_arguments: typing.Optional[dict[str, typing.Any]] = None,
|
|
@@ -1003,14 +1014,12 @@ def load_and_run(
|
|
|
1003
1014
|
local: typing.Optional[bool] = None,
|
|
1004
1015
|
schedule: typing.Union[str, mlrun.common.schemas.ScheduleCronTrigger] = None,
|
|
1005
1016
|
cleanup_ttl: typing.Optional[int] = None,
|
|
1006
|
-
load_only: bool = False,
|
|
1007
1017
|
wait_for_completion: bool = False,
|
|
1008
1018
|
project_context: typing.Optional[str] = None,
|
|
1009
1019
|
):
|
|
1010
1020
|
"""
|
|
1011
1021
|
Auxiliary function that the RemoteRunner run once or run every schedule.
|
|
1012
1022
|
This function loads a project from a given remote source and then runs the workflow.
|
|
1013
|
-
|
|
1014
1023
|
:param context: mlrun context.
|
|
1015
1024
|
:param url: remote url that represents the project's source.
|
|
1016
1025
|
See 'mlrun.load_project()' for details
|
|
@@ -1018,7 +1027,6 @@ def load_and_run(
|
|
|
1018
1027
|
:param init_git: if True, will git init the context dir
|
|
1019
1028
|
:param subpath: project subpath (within the archive)
|
|
1020
1029
|
:param clone: if True, always clone (delete any existing content)
|
|
1021
|
-
:param save: whether to save the created project and artifact in the DB
|
|
1022
1030
|
:param workflow_name: name of the workflow
|
|
1023
1031
|
:param workflow_path: url to a workflow file, if not a project workflow
|
|
1024
1032
|
:param workflow_arguments: kubeflow pipelines arguments (parameters)
|
|
@@ -1034,48 +1042,31 @@ def load_and_run(
|
|
|
1034
1042
|
:param schedule: ScheduleCronTrigger class instance or a standard crontab expression string
|
|
1035
1043
|
:param cleanup_ttl: pipeline cleanup ttl in secs (time to wait after workflow completion, at which point the
|
|
1036
1044
|
workflow and all its resources are deleted)
|
|
1037
|
-
:param load_only: for just loading the project, inner use.
|
|
1038
1045
|
:param wait_for_completion: wait for workflow completion before returning
|
|
1039
1046
|
:param project_context: project context path (used for loading the project)
|
|
1040
1047
|
"""
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
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
|
-
)
|
|
1069
|
-
|
|
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")
|
|
1048
|
+
project_context = project_context or f"./{project_name}"
|
|
1049
|
+
|
|
1050
|
+
# Load the project to fetch files which the runner needs, such as remote source files
|
|
1051
|
+
pull_remote_project_files(
|
|
1052
|
+
context=context,
|
|
1053
|
+
project_context=project_context,
|
|
1054
|
+
url=url,
|
|
1055
|
+
project_name=project_name,
|
|
1056
|
+
init_git=init_git,
|
|
1057
|
+
subpath=subpath,
|
|
1058
|
+
clone=clone,
|
|
1059
|
+
schedule=schedule,
|
|
1060
|
+
workflow_name=workflow_name,
|
|
1061
|
+
)
|
|
1076
1062
|
|
|
1077
|
-
|
|
1078
|
-
|
|
1063
|
+
# Retrieve the project object:
|
|
1064
|
+
# - If the project exists in the MLRun database, it will be loaded from there.
|
|
1065
|
+
# - If it doesn't exist in the database, it will be created from the previously loaded local directory.
|
|
1066
|
+
project = mlrun.get_or_create_project(
|
|
1067
|
+
context=project_context or f"./{project_name}",
|
|
1068
|
+
name=project_name,
|
|
1069
|
+
)
|
|
1079
1070
|
|
|
1080
1071
|
# extract "start" notification if exists
|
|
1081
1072
|
start_notifications = [
|
|
@@ -1108,18 +1099,156 @@ def load_and_run(
|
|
|
1108
1099
|
raise RuntimeError(f"Workflow {workflow_log_message} failed") from run.exc
|
|
1109
1100
|
|
|
1110
1101
|
if wait_for_completion:
|
|
1102
|
+
handle_workflow_completion(
|
|
1103
|
+
run=run,
|
|
1104
|
+
project=project,
|
|
1105
|
+
context=context,
|
|
1106
|
+
workflow_log_message=workflow_log_message,
|
|
1107
|
+
)
|
|
1108
|
+
|
|
1109
|
+
|
|
1110
|
+
def pull_remote_project_files(
|
|
1111
|
+
context: mlrun.execution.MLClientCtx,
|
|
1112
|
+
project_context: str,
|
|
1113
|
+
url: str,
|
|
1114
|
+
project_name: str,
|
|
1115
|
+
init_git: typing.Optional[bool],
|
|
1116
|
+
subpath: typing.Optional[str],
|
|
1117
|
+
clone: bool,
|
|
1118
|
+
schedule: typing.Optional[
|
|
1119
|
+
typing.Union[str, mlrun.common.schemas.ScheduleCronTrigger]
|
|
1120
|
+
],
|
|
1121
|
+
workflow_name: typing.Optional[str],
|
|
1122
|
+
) -> None:
|
|
1123
|
+
"""
|
|
1124
|
+
Load the project to clone remote files if they exist.
|
|
1125
|
+
If an exception occurs during project loading, send a notification if the workflow is scheduled.
|
|
1126
|
+
|
|
1127
|
+
:param context: MLRun execution context.
|
|
1128
|
+
:param project_context: Path to the project context.
|
|
1129
|
+
:param url: URL of the project repository.
|
|
1130
|
+
:param project_name: Name of the project.
|
|
1131
|
+
:param init_git: Initialize a git repository.
|
|
1132
|
+
:param subpath: Project subpath within the repository.
|
|
1133
|
+
:param clone: Whether to clone the repository.
|
|
1134
|
+
:param schedule: Schedule for running the workflow.
|
|
1135
|
+
:param workflow_name: Name of the workflow to run.
|
|
1136
|
+
"""
|
|
1137
|
+
try:
|
|
1138
|
+
# Load the project to clone remote files if they exist.
|
|
1139
|
+
# Using save=False to avoid overriding changes from the database if it already exists.
|
|
1140
|
+
mlrun.load_project(
|
|
1141
|
+
context=project_context,
|
|
1142
|
+
url=url,
|
|
1143
|
+
name=project_name,
|
|
1144
|
+
init_git=init_git,
|
|
1145
|
+
subpath=subpath,
|
|
1146
|
+
clone=clone,
|
|
1147
|
+
save=False,
|
|
1148
|
+
)
|
|
1149
|
+
except Exception as error:
|
|
1150
|
+
notify_scheduled_workflow_failure(
|
|
1151
|
+
schedule=schedule,
|
|
1152
|
+
project_name=project_name,
|
|
1153
|
+
workflow_name=workflow_name,
|
|
1154
|
+
error=error,
|
|
1155
|
+
context_uid=context.uid,
|
|
1156
|
+
)
|
|
1157
|
+
raise error
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
def notify_scheduled_workflow_failure(
|
|
1161
|
+
schedule,
|
|
1162
|
+
project_name: str,
|
|
1163
|
+
workflow_name: str,
|
|
1164
|
+
error: Exception,
|
|
1165
|
+
context_uid: str,
|
|
1166
|
+
) -> None:
|
|
1167
|
+
if schedule:
|
|
1168
|
+
notification_pusher = mlrun.utils.notifications.CustomNotificationPusher(
|
|
1169
|
+
["slack"]
|
|
1170
|
+
)
|
|
1171
|
+
url = get_ui_url(project_name, context_uid)
|
|
1172
|
+
link = f"<{url}|*view workflow job details*>"
|
|
1173
|
+
message = (
|
|
1174
|
+
f":x: Failed to run scheduled workflow {workflow_name} "
|
|
1175
|
+
f"in Project {project_name}!\n"
|
|
1176
|
+
f"Error: ```{err_to_str(error)}```\n{link}"
|
|
1177
|
+
)
|
|
1178
|
+
# Sending Slack Notification without losing the original error:
|
|
1111
1179
|
try:
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
"Failed waiting for workflow completion",
|
|
1116
|
-
workflow=workflow_log_message,
|
|
1117
|
-
exc=err_to_str(exc),
|
|
1180
|
+
notification_pusher.push(
|
|
1181
|
+
message=message,
|
|
1182
|
+
severity=mlrun.common.schemas.NotificationSeverity.ERROR,
|
|
1118
1183
|
)
|
|
1119
1184
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1185
|
+
except Exception as exc:
|
|
1186
|
+
logger.error("Failed to send slack notification", exc=err_to_str(exc))
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
def handle_workflow_completion(
|
|
1190
|
+
run: _PipelineRunStatus,
|
|
1191
|
+
project,
|
|
1192
|
+
context: mlrun.execution.MLClientCtx,
|
|
1193
|
+
workflow_log_message: str,
|
|
1194
|
+
) -> None:
|
|
1195
|
+
"""
|
|
1196
|
+
Handle workflow completion by waiting for it to finish and logging the final state.
|
|
1197
|
+
|
|
1198
|
+
:param run: Run object containing workflow execution details.
|
|
1199
|
+
:param project: MLRun project object.
|
|
1200
|
+
:param context: MLRun execution context.
|
|
1201
|
+
:param workflow_log_message: Message used for logging.
|
|
1202
|
+
"""
|
|
1203
|
+
try:
|
|
1204
|
+
run.wait_for_completion()
|
|
1205
|
+
except Exception as exc:
|
|
1206
|
+
mlrun.utils.logger.error(
|
|
1207
|
+
"Failed waiting for workflow completion",
|
|
1208
|
+
workflow=workflow_log_message,
|
|
1209
|
+
exc=err_to_str(exc),
|
|
1210
|
+
)
|
|
1211
|
+
|
|
1212
|
+
pipeline_state, _, _ = project.get_run_status(run)
|
|
1213
|
+
context.log_result(key="workflow_state", value=pipeline_state, commit=True)
|
|
1214
|
+
if pipeline_state != mlrun_pipelines.common.models.RunStatuses.succeeded:
|
|
1215
|
+
raise RuntimeError(
|
|
1216
|
+
f"Workflow {workflow_log_message} failed, state={pipeline_state}"
|
|
1217
|
+
)
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
def import_remote_project(
|
|
1221
|
+
context: mlrun.execution.MLClientCtx,
|
|
1222
|
+
url: typing.Optional[str] = None,
|
|
1223
|
+
project_name: str = "",
|
|
1224
|
+
init_git: typing.Optional[bool] = None,
|
|
1225
|
+
subpath: typing.Optional[str] = None,
|
|
1226
|
+
clone: bool = False,
|
|
1227
|
+
save: bool = True,
|
|
1228
|
+
project_context: typing.Optional[str] = None,
|
|
1229
|
+
):
|
|
1230
|
+
"""
|
|
1231
|
+
This function loads a project from a given remote source.
|
|
1232
|
+
|
|
1233
|
+
:param context: mlrun context.
|
|
1234
|
+
:param url: remote url that represents the project's source.
|
|
1235
|
+
See 'mlrun.load_project()' for details
|
|
1236
|
+
:param project_name: project name
|
|
1237
|
+
:param init_git: if True, will git init the context dir
|
|
1238
|
+
:param subpath: project subpath (within the archive)
|
|
1239
|
+
:param clone: if True, always clone (delete any existing content)
|
|
1240
|
+
:param save: whether to save the created project and artifact in the DB
|
|
1241
|
+
:param project_context: project context path (used for loading the project)
|
|
1242
|
+
"""
|
|
1243
|
+
project = mlrun.load_project(
|
|
1244
|
+
context=project_context or f"./{project_name}",
|
|
1245
|
+
url=url,
|
|
1246
|
+
name=project_name,
|
|
1247
|
+
init_git=init_git,
|
|
1248
|
+
subpath=subpath,
|
|
1249
|
+
clone=clone,
|
|
1250
|
+
save=save,
|
|
1251
|
+
sync_functions=True,
|
|
1252
|
+
)
|
|
1253
|
+
|
|
1254
|
+
context.logger.info(f"Loaded project {project.name} successfully")
|