mlrun 1.7.0rc14__py3-none-any.whl → 1.7.0rc22__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.

Files changed (160) hide show
  1. mlrun/__init__.py +10 -1
  2. mlrun/__main__.py +23 -111
  3. mlrun/alerts/__init__.py +15 -0
  4. mlrun/alerts/alert.py +169 -0
  5. mlrun/api/schemas/__init__.py +4 -3
  6. mlrun/artifacts/__init__.py +8 -3
  7. mlrun/artifacts/base.py +36 -253
  8. mlrun/artifacts/dataset.py +9 -190
  9. mlrun/artifacts/manager.py +46 -42
  10. mlrun/artifacts/model.py +9 -141
  11. mlrun/artifacts/plots.py +14 -375
  12. mlrun/common/constants.py +65 -3
  13. mlrun/common/formatters/__init__.py +19 -0
  14. mlrun/{runtimes/mpijob/v1alpha1.py → common/formatters/artifact.py} +6 -14
  15. mlrun/common/formatters/base.py +113 -0
  16. mlrun/common/formatters/function.py +46 -0
  17. mlrun/common/formatters/pipeline.py +53 -0
  18. mlrun/common/formatters/project.py +51 -0
  19. mlrun/{runtimes → common/runtimes}/constants.py +32 -4
  20. mlrun/common/schemas/__init__.py +10 -5
  21. mlrun/common/schemas/alert.py +92 -11
  22. mlrun/common/schemas/api_gateway.py +56 -0
  23. mlrun/common/schemas/artifact.py +15 -5
  24. mlrun/common/schemas/auth.py +2 -0
  25. mlrun/common/schemas/client_spec.py +1 -0
  26. mlrun/common/schemas/frontend_spec.py +1 -0
  27. mlrun/common/schemas/function.py +4 -0
  28. mlrun/common/schemas/model_monitoring/__init__.py +15 -3
  29. mlrun/common/schemas/model_monitoring/constants.py +58 -7
  30. mlrun/common/schemas/model_monitoring/grafana.py +9 -5
  31. mlrun/common/schemas/model_monitoring/model_endpoints.py +86 -2
  32. mlrun/common/schemas/pipeline.py +0 -9
  33. mlrun/common/schemas/project.py +5 -11
  34. mlrun/common/types.py +1 -0
  35. mlrun/config.py +30 -9
  36. mlrun/data_types/to_pandas.py +9 -9
  37. mlrun/datastore/base.py +41 -9
  38. mlrun/datastore/datastore.py +6 -2
  39. mlrun/datastore/datastore_profile.py +56 -4
  40. mlrun/datastore/inmem.py +2 -2
  41. mlrun/datastore/redis.py +2 -2
  42. mlrun/datastore/s3.py +5 -0
  43. mlrun/datastore/sources.py +147 -7
  44. mlrun/datastore/store_resources.py +7 -7
  45. mlrun/datastore/targets.py +110 -42
  46. mlrun/datastore/utils.py +42 -0
  47. mlrun/db/base.py +54 -10
  48. mlrun/db/httpdb.py +282 -79
  49. mlrun/db/nopdb.py +52 -10
  50. mlrun/errors.py +11 -0
  51. mlrun/execution.py +26 -9
  52. mlrun/feature_store/__init__.py +0 -2
  53. mlrun/feature_store/api.py +12 -47
  54. mlrun/feature_store/feature_set.py +9 -0
  55. mlrun/feature_store/feature_vector.py +8 -0
  56. mlrun/feature_store/ingestion.py +7 -6
  57. mlrun/feature_store/retrieval/base.py +9 -4
  58. mlrun/feature_store/retrieval/conversion.py +9 -9
  59. mlrun/feature_store/retrieval/dask_merger.py +2 -0
  60. mlrun/feature_store/retrieval/job.py +9 -3
  61. mlrun/feature_store/retrieval/local_merger.py +2 -0
  62. mlrun/feature_store/retrieval/spark_merger.py +16 -0
  63. mlrun/frameworks/__init__.py +6 -0
  64. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +7 -12
  65. mlrun/frameworks/parallel_coordinates.py +2 -1
  66. mlrun/frameworks/tf_keras/__init__.py +4 -1
  67. mlrun/k8s_utils.py +10 -11
  68. mlrun/launcher/base.py +4 -3
  69. mlrun/launcher/client.py +5 -3
  70. mlrun/launcher/local.py +12 -2
  71. mlrun/launcher/remote.py +9 -2
  72. mlrun/lists.py +6 -2
  73. mlrun/model.py +47 -21
  74. mlrun/model_monitoring/__init__.py +1 -1
  75. mlrun/model_monitoring/api.py +42 -18
  76. mlrun/model_monitoring/application.py +5 -305
  77. mlrun/model_monitoring/applications/__init__.py +11 -0
  78. mlrun/model_monitoring/applications/_application_steps.py +157 -0
  79. mlrun/model_monitoring/applications/base.py +280 -0
  80. mlrun/model_monitoring/applications/context.py +214 -0
  81. mlrun/model_monitoring/applications/evidently_base.py +211 -0
  82. mlrun/model_monitoring/applications/histogram_data_drift.py +132 -91
  83. mlrun/model_monitoring/applications/results.py +99 -0
  84. mlrun/model_monitoring/controller.py +3 -1
  85. mlrun/model_monitoring/db/__init__.py +2 -0
  86. mlrun/model_monitoring/db/stores/__init__.py +0 -2
  87. mlrun/model_monitoring/db/stores/base/store.py +22 -37
  88. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +43 -21
  89. mlrun/model_monitoring/db/stores/sqldb/models/base.py +39 -8
  90. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +27 -7
  91. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +5 -0
  92. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +246 -224
  93. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +232 -216
  94. mlrun/model_monitoring/db/tsdb/__init__.py +100 -0
  95. mlrun/model_monitoring/db/tsdb/base.py +316 -0
  96. mlrun/model_monitoring/db/tsdb/helpers.py +30 -0
  97. mlrun/model_monitoring/db/tsdb/tdengine/__init__.py +15 -0
  98. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +240 -0
  99. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +45 -0
  100. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +401 -0
  101. mlrun/model_monitoring/db/tsdb/v3io/__init__.py +15 -0
  102. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +117 -0
  103. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +658 -0
  104. mlrun/model_monitoring/evidently_application.py +6 -118
  105. mlrun/model_monitoring/helpers.py +63 -1
  106. mlrun/model_monitoring/model_endpoint.py +3 -2
  107. mlrun/model_monitoring/stream_processing.py +57 -216
  108. mlrun/model_monitoring/writer.py +134 -124
  109. mlrun/package/__init__.py +13 -1
  110. mlrun/package/packagers/__init__.py +6 -1
  111. mlrun/package/utils/_formatter.py +2 -2
  112. mlrun/platforms/__init__.py +10 -9
  113. mlrun/platforms/iguazio.py +21 -202
  114. mlrun/projects/operations.py +24 -12
  115. mlrun/projects/pipelines.py +79 -102
  116. mlrun/projects/project.py +271 -103
  117. mlrun/render.py +15 -14
  118. mlrun/run.py +16 -46
  119. mlrun/runtimes/__init__.py +6 -3
  120. mlrun/runtimes/base.py +14 -7
  121. mlrun/runtimes/daskjob.py +1 -0
  122. mlrun/runtimes/databricks_job/databricks_runtime.py +1 -0
  123. mlrun/runtimes/databricks_job/databricks_wrapper.py +1 -1
  124. mlrun/runtimes/funcdoc.py +0 -28
  125. mlrun/runtimes/kubejob.py +2 -1
  126. mlrun/runtimes/local.py +12 -3
  127. mlrun/runtimes/mpijob/__init__.py +0 -20
  128. mlrun/runtimes/mpijob/v1.py +1 -1
  129. mlrun/runtimes/nuclio/api_gateway.py +194 -84
  130. mlrun/runtimes/nuclio/application/application.py +170 -8
  131. mlrun/runtimes/nuclio/function.py +39 -49
  132. mlrun/runtimes/pod.py +16 -36
  133. mlrun/runtimes/remotesparkjob.py +9 -3
  134. mlrun/runtimes/sparkjob/spark3job.py +1 -1
  135. mlrun/runtimes/utils.py +6 -45
  136. mlrun/serving/__init__.py +8 -1
  137. mlrun/serving/server.py +2 -1
  138. mlrun/serving/states.py +51 -8
  139. mlrun/serving/utils.py +19 -11
  140. mlrun/serving/v2_serving.py +5 -1
  141. mlrun/track/tracker.py +2 -1
  142. mlrun/utils/async_http.py +25 -5
  143. mlrun/utils/helpers.py +157 -83
  144. mlrun/utils/logger.py +39 -7
  145. mlrun/utils/notifications/notification/__init__.py +14 -9
  146. mlrun/utils/notifications/notification/base.py +1 -1
  147. mlrun/utils/notifications/notification/slack.py +34 -7
  148. mlrun/utils/notifications/notification/webhook.py +1 -1
  149. mlrun/utils/notifications/notification_pusher.py +147 -16
  150. mlrun/utils/regex.py +9 -0
  151. mlrun/utils/v3io_clients.py +0 -1
  152. mlrun/utils/version/version.json +2 -2
  153. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc22.dist-info}/METADATA +14 -6
  154. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc22.dist-info}/RECORD +158 -138
  155. mlrun/kfpops.py +0 -865
  156. mlrun/platforms/other.py +0 -305
  157. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc22.dist-info}/LICENSE +0 -0
  158. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc22.dist-info}/WHEEL +0 -0
  159. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc22.dist-info}/entry_points.txt +0 -0
  160. {mlrun-1.7.0rc14.dist-info → mlrun-1.7.0rc22.dist-info}/top_level.txt +0 -0
mlrun/render.py CHANGED
@@ -121,20 +121,12 @@ def artifacts_html(
121
121
  html = ""
122
122
 
123
123
  for artifact in artifacts:
124
- # TODO: remove this in 1.7.0 once we no longer support legacy format
125
- if mlrun.utils.is_legacy_artifact(artifact):
126
- attribute_value = artifact.get(attribute_name)
127
- else:
128
- attribute_value = artifact["spec"].get(attribute_name)
129
-
130
- if mlrun.utils.is_legacy_artifact(artifact):
131
- key = artifact["key"]
132
- else:
133
- key = artifact["metadata"]["key"]
124
+ attribute_value = artifact["spec"].get(attribute_name)
125
+ key = artifact["metadata"]["key"]
134
126
 
135
127
  if not attribute_value:
136
128
  mlrun.utils.logger.warning(
137
- "Artifact is incomplete, omitting from output (most likely due to a failed artifact logging)",
129
+ f"Artifact required attribute {attribute_name} is missing, omitting from output",
138
130
  artifact_key=key,
139
131
  )
140
132
  continue
@@ -404,12 +396,21 @@ def runs_to_html(
404
396
  df.drop("labels", axis=1, inplace=True)
405
397
  df.drop("inputs", axis=1, inplace=True)
406
398
  df.drop("artifacts", axis=1, inplace=True)
399
+ df.drop("artifact_uris", axis=1, inplace=True)
407
400
  else:
408
401
  df["labels"] = df["labels"].apply(dict_html)
409
402
  df["inputs"] = df["inputs"].apply(inputs_html)
410
- df["artifacts"] = df["artifacts"].apply(
411
- lambda artifacts: artifacts_html(artifacts, "target_path"),
412
- )
403
+ if df["artifacts"][0]:
404
+ df["artifacts"] = df["artifacts"].apply(
405
+ lambda artifacts: artifacts_html(artifacts, "target_path"),
406
+ )
407
+ df.drop("artifact_uris", axis=1, inplace=True)
408
+ elif df["artifact_uris"][0]:
409
+ df["artifact_uris"] = df["artifact_uris"].apply(dict_html)
410
+ df.drop("artifacts", axis=1, inplace=True)
411
+ else:
412
+ df.drop("artifacts", axis=1, inplace=True)
413
+ df.drop("artifact_uris", axis=1, inplace=True)
413
414
 
414
415
  def expand_error(x):
415
416
  if x["state"] == "error":
mlrun/run.py CHANGED
@@ -29,11 +29,14 @@ from typing import Optional, Union
29
29
  import nuclio
30
30
  import yaml
31
31
  from kfp import Client
32
+ from mlrun_pipelines.common.models import RunStatuses
33
+ from mlrun_pipelines.common.ops import format_summary_from_kfp_run, show_kfp_run
32
34
 
35
+ import mlrun.common.constants as mlrun_constants
36
+ import mlrun.common.formatters
33
37
  import mlrun.common.schemas
34
38
  import mlrun.errors
35
39
  import mlrun.utils.helpers
36
- from mlrun.kfpops import format_summary_from_kfp_run, show_kfp_run
37
40
 
38
41
  from .common.helpers import parse_versioned_object_uri
39
42
  from .config import config as mlconf
@@ -47,7 +50,6 @@ from .runtimes import (
47
50
  KubejobRuntime,
48
51
  LocalRuntime,
49
52
  MpiRuntimeV1,
50
- MpiRuntimeV1Alpha1,
51
53
  RemoteRuntime,
52
54
  RemoteSparkRuntime,
53
55
  RuntimeKinds,
@@ -69,41 +71,6 @@ from .utils import (
69
71
  )
70
72
 
71
73
 
72
- class RunStatuses:
73
- succeeded = "Succeeded"
74
- failed = "Failed"
75
- skipped = "Skipped"
76
- error = "Error"
77
- running = "Running"
78
-
79
- @staticmethod
80
- def all():
81
- return [
82
- RunStatuses.succeeded,
83
- RunStatuses.failed,
84
- RunStatuses.skipped,
85
- RunStatuses.error,
86
- RunStatuses.running,
87
- ]
88
-
89
- @staticmethod
90
- def stable_statuses():
91
- return [
92
- RunStatuses.succeeded,
93
- RunStatuses.failed,
94
- RunStatuses.skipped,
95
- RunStatuses.error,
96
- ]
97
-
98
- @staticmethod
99
- def transient_statuses():
100
- return [
101
- status
102
- for status in RunStatuses.all()
103
- if status not in RunStatuses.stable_statuses()
104
- ]
105
-
106
-
107
74
  def function_to_module(code="", workdir=None, secrets=None, silent=False):
108
75
  """Load code, notebook or mlrun function as .py module
109
76
  this function can import a local/remote py file or notebook
@@ -326,6 +293,10 @@ def get_or_create_ctx(
326
293
  newspec["metadata"]["project"] = (
327
294
  newspec["metadata"].get("project") or project or mlconf.default_project
328
295
  )
296
+ newspec["metadata"].setdefault("labels", {})
297
+ newspec["metadata"]["labels"] = {
298
+ mlrun_constants.MLRunInternalLabels.kind: RuntimeKinds.local
299
+ }
329
300
 
330
301
  ctx = MLClientCtx.from_dict(
331
302
  newspec, rundb=out, autocommit=autocommit, tmp=tmp, host=socket.gethostname()
@@ -606,7 +577,6 @@ def code_to_function(
606
577
  ignored_tags: Optional[str] = None,
607
578
  requirements_file: Optional[str] = "",
608
579
  ) -> Union[
609
- MpiRuntimeV1Alpha1,
610
580
  MpiRuntimeV1,
611
581
  RemoteRuntime,
612
582
  ServingRuntime,
@@ -1008,8 +978,8 @@ def get_pipeline(
1008
978
  run_id,
1009
979
  namespace=None,
1010
980
  format_: Union[
1011
- str, mlrun.common.schemas.PipelinesFormat
1012
- ] = mlrun.common.schemas.PipelinesFormat.summary,
981
+ str, mlrun.common.formatters.PipelineFormat
982
+ ] = mlrun.common.formatters.PipelineFormat.summary,
1013
983
  project: str = None,
1014
984
  remote: bool = True,
1015
985
  ):
@@ -1023,7 +993,7 @@ def get_pipeline(
1023
993
  :param project: the project of the pipeline run
1024
994
  :param remote: read kfp data from mlrun service (default=True)
1025
995
 
1026
- :return: kfp run dict
996
+ :return: kfp run
1027
997
  """
1028
998
  namespace = namespace or mlconf.namespace
1029
999
  if remote:
@@ -1045,9 +1015,9 @@ def get_pipeline(
1045
1015
  resp = resp.to_dict()
1046
1016
  if (
1047
1017
  not format_
1048
- or format_ == mlrun.common.schemas.PipelinesFormat.summary.value
1018
+ or format_ == mlrun.common.formatters.PipelineFormat.summary.value
1049
1019
  ):
1050
- resp = format_summary_from_kfp_run(resp)
1020
+ resp = mlrun.common.formatters.PipelineFormat.format_obj(resp, format_)
1051
1021
 
1052
1022
  show_kfp_run(resp)
1053
1023
  return resp
@@ -1061,7 +1031,7 @@ def list_pipelines(
1061
1031
  filter_="",
1062
1032
  namespace=None,
1063
1033
  project="*",
1064
- format_: mlrun.common.schemas.PipelinesFormat = mlrun.common.schemas.PipelinesFormat.metadata_only,
1034
+ format_: mlrun.common.formatters.PipelineFormat = mlrun.common.formatters.PipelineFormat.metadata_only,
1065
1035
  ) -> tuple[int, Optional[int], list[dict]]:
1066
1036
  """List pipelines
1067
1037
 
@@ -1081,7 +1051,7 @@ def list_pipelines(
1081
1051
  :param format_: Control what will be returned (full/metadata_only/name_only)
1082
1052
  """
1083
1053
  if full:
1084
- format_ = mlrun.common.schemas.PipelinesFormat.full
1054
+ format_ = mlrun.common.formatters.PipelineFormat.full
1085
1055
  run_db = mlrun.db.get_run_db()
1086
1056
  pipelines = run_db.list_pipelines(
1087
1057
  project, namespace, sort_by, page_token, filter_, format_, page_size
@@ -1150,7 +1120,7 @@ def wait_for_runs_completion(
1150
1120
  running = []
1151
1121
  for run in runs:
1152
1122
  state = run.state()
1153
- if state in mlrun.runtimes.constants.RunStates.terminal_states():
1123
+ if state in mlrun.common.runtimes.constants.RunStates.terminal_states():
1154
1124
  completed.append(run)
1155
1125
  else:
1156
1126
  running.append(run)
@@ -26,23 +26,26 @@ __all__ = [
26
26
  "Spark3Runtime",
27
27
  "DatabricksRuntime",
28
28
  "KubeResource",
29
+ "ApplicationRuntime",
30
+ "MpiRuntimeV1",
29
31
  ]
30
32
 
31
33
  from mlrun.runtimes.utils import resolve_spark_operator_version
32
34
 
35
+ from ..common.runtimes.constants import MPIJobCRDVersions
33
36
  from .base import BaseRuntime, RunError, RuntimeClassMode # noqa
34
- from .constants import MPIJobCRDVersions
35
37
  from .daskjob import DaskCluster # noqa
36
38
  from .databricks_job.databricks_runtime import DatabricksRuntime
37
39
  from .kubejob import KubejobRuntime, KubeResource # noqa
38
40
  from .local import HandlerRuntime, LocalRuntime # noqa
39
- from .mpijob import MpiRuntimeContainer, MpiRuntimeV1, MpiRuntimeV1Alpha1 # noqa
41
+ from .mpijob import MpiRuntimeV1 # noqa
40
42
  from .nuclio import (
41
43
  RemoteRuntime,
42
44
  ServingRuntime,
43
45
  new_v2_model_server,
44
46
  nuclio_init_hook,
45
47
  )
48
+ from .nuclio.api_gateway import APIGateway
46
49
  from .nuclio.application import ApplicationRuntime
47
50
  from .nuclio.serving import serving_subkind
48
51
  from .remotesparkjob import RemoteSparkRuntime
@@ -264,7 +267,7 @@ class RuntimeKinds:
264
267
 
265
268
  def get_runtime_class(kind: str):
266
269
  if kind == RuntimeKinds.mpijob:
267
- return MpiRuntimeContainer.selector()
270
+ return MpiRuntimeV1
268
271
 
269
272
  if kind == RuntimeKinds.spark:
270
273
  return Spark3Runtime
mlrun/runtimes/base.py CHANGED
@@ -21,9 +21,11 @@ from os import environ
21
21
  from typing import Callable, Optional, Union
22
22
 
23
23
  import requests.exceptions
24
+ from mlrun_pipelines.common.ops import mlrun_op
24
25
  from nuclio.build import mlrun_footer
25
26
 
26
27
  import mlrun.common.constants
28
+ import mlrun.common.constants as mlrun_constants
27
29
  import mlrun.common.schemas
28
30
  import mlrun.common.schemas.model_monitoring.constants as mm_constants
29
31
  import mlrun.db
@@ -37,7 +39,6 @@ from mlrun.utils.helpers import generate_object_uri, verify_field_regex
37
39
  from ..config import config
38
40
  from ..datastore import store_manager
39
41
  from ..errors import err_to_str
40
- from ..kfpops import mlrun_op
41
42
  from ..lists import RunList
42
43
  from ..model import BaseMetadata, HyperParamOptions, ImageBuilder, ModelObj, RunObject
43
44
  from ..utils import (
@@ -67,6 +68,7 @@ spec_fields = [
67
68
  "disable_auto_mount",
68
69
  "allow_empty_resources",
69
70
  "clone_target_dir",
71
+ "reset_on_run",
70
72
  ]
71
73
 
72
74
 
@@ -335,6 +337,7 @@ class BaseRuntime(ModelObj):
335
337
  notifications: Optional[list[mlrun.model.Notification]] = None,
336
338
  returns: Optional[list[Union[str, dict[str, str]]]] = None,
337
339
  state_thresholds: Optional[dict[str, int]] = None,
340
+ reset_on_run: Optional[bool] = None,
338
341
  **launcher_kwargs,
339
342
  ) -> RunObject:
340
343
  """
@@ -389,6 +392,9 @@ class BaseRuntime(ModelObj):
389
392
  standards and is at least 1 minute (-1 for infinite).
390
393
  If the phase is active for longer than the threshold, the run will be aborted.
391
394
  See mlconf.function.spec.state_thresholds for the state options and default values.
395
+ :param reset_on_run: When True, function python modules would reload prior to code execution.
396
+ This ensures latest code changes are executed. This argument must be used in
397
+ conjunction with the local=True argument.
392
398
  :return: Run context object (RunObject) with run metadata, results and status
393
399
  """
394
400
  launcher = mlrun.launcher.factory.LauncherFactory().create_launcher(
@@ -417,6 +423,7 @@ class BaseRuntime(ModelObj):
417
423
  notifications=notifications,
418
424
  returns=returns,
419
425
  state_thresholds=state_thresholds,
426
+ reset_on_run=reset_on_run,
420
427
  )
421
428
 
422
429
  def _get_db_run(self, task: RunObject = None):
@@ -469,11 +476,11 @@ class BaseRuntime(ModelObj):
469
476
  def _store_function(self, runspec, meta, db):
470
477
  meta.labels["kind"] = self.kind
471
478
  mlrun.runtimes.utils.enrich_run_labels(
472
- meta.labels, [mlrun.runtimes.constants.RunLabels.owner]
479
+ meta.labels, [mlrun.common.runtimes.constants.RunLabels.owner]
473
480
  )
474
481
  if runspec.spec.output_path:
475
482
  runspec.spec.output_path = runspec.spec.output_path.replace(
476
- "{{run.user}}", meta.labels["owner"]
483
+ "{{run.user}}", meta.labels[mlrun_constants.MLRunInternalLabels.owner]
477
484
  )
478
485
 
479
486
  if db and self.kind != "handler":
@@ -580,9 +587,9 @@ class BaseRuntime(ModelObj):
580
587
 
581
588
  elif (
582
589
  not was_none
583
- and last_state != mlrun.runtimes.constants.RunStates.completed
590
+ and last_state != mlrun.common.runtimes.constants.RunStates.completed
584
591
  and last_state
585
- not in mlrun.runtimes.constants.RunStates.error_and_abortion_states()
592
+ not in mlrun.common.runtimes.constants.RunStates.error_and_abortion_states()
586
593
  ):
587
594
  try:
588
595
  runtime_cls = mlrun.runtimes.get_runtime_class(kind)
@@ -707,11 +714,11 @@ class BaseRuntime(ModelObj):
707
714
  "key": "the_key".
708
715
  :param auto_build: when set to True and the function require build it will be built on the first
709
716
  function run, use only if you dont plan on changing the build config between runs
710
- :return: KubeFlow containerOp
717
+ :return: mlrun_pipelines.models.PipelineNodeWrapper
711
718
  """
712
719
 
713
720
  # if the function contain KFP PipelineParams (futures) pass the full spec to the
714
- # ContainerOp this way KFP will substitute the params with previous step outputs
721
+ # PipelineNodeWrapper this way KFP will substitute the params with previous step outputs
715
722
  if use_db and not self._has_pipeline_param():
716
723
  # if the same function is built as part of the pipeline we do not use the versioned function
717
724
  # rather the latest function w the same tag so we can pick up the updated image/status
mlrun/runtimes/daskjob.py CHANGED
@@ -494,6 +494,7 @@ class DaskCluster(KubejobRuntime):
494
494
  notifications: Optional[list[mlrun.model.Notification]] = None,
495
495
  returns: Optional[list[Union[str, dict[str, str]]]] = None,
496
496
  state_thresholds: Optional[dict[str, int]] = None,
497
+ reset_on_run: Optional[bool] = None,
497
498
  **launcher_kwargs,
498
499
  ) -> RunObject:
499
500
  if state_thresholds:
@@ -232,6 +232,7 @@ def run_mlrun_databricks_job(context,task_parameters: dict, **kwargs):
232
232
  notifications: Optional[list[mlrun.model.Notification]] = None,
233
233
  returns: Optional[list[Union[str, dict[str, str]]]] = None,
234
234
  state_thresholds: Optional[dict[str, int]] = None,
235
+ reset_on_run: Optional[bool] = None,
235
236
  **launcher_kwargs,
236
237
  ) -> RunObject:
237
238
  if local:
@@ -99,7 +99,7 @@ def save_credentials(
99
99
  credentials["DATABRICKS_CLUSTER_ID"] = cluster_id
100
100
 
101
101
  with open(credentials_path, "w") as yaml_file:
102
- yaml.dump(credentials, yaml_file, default_flow_style=False)
102
+ yaml.safe_dump(credentials, yaml_file, default_flow_style=False)
103
103
 
104
104
 
105
105
  def run_mlrun_databricks_job(
mlrun/runtimes/funcdoc.py CHANGED
@@ -16,8 +16,6 @@ import ast
16
16
  import inspect
17
17
  import re
18
18
 
19
- from deprecated import deprecated
20
-
21
19
  from mlrun.model import FunctionEntrypoint
22
20
 
23
21
 
@@ -73,32 +71,6 @@ def func_dict(
73
71
  }
74
72
 
75
73
 
76
- # TODO: remove in 1.7.0
77
- @deprecated(
78
- version="1.5.0",
79
- reason="'func_info' is deprecated and will be removed in 1.7.0, use 'ast_func_info' instead",
80
- category=FutureWarning,
81
- )
82
- def func_info(fn) -> dict:
83
- sig = inspect.signature(fn)
84
- doc = inspect.getdoc(fn) or ""
85
-
86
- out = func_dict(
87
- name=fn.__name__,
88
- doc=doc,
89
- params=[inspect_param(p) for p in sig.parameters.values()],
90
- returns=param_dict(
91
- type=type_name(sig.return_annotation, empty_is_none=True), default=None
92
- ),
93
- lineno=func_lineno(fn),
94
- )
95
-
96
- if not fn.__doc__ or not fn.__doc__.strip():
97
- return out
98
-
99
- return merge_doc(out, doc)
100
-
101
-
102
74
  def func_lineno(fn):
103
75
  try:
104
76
  return inspect.getsourcelines(fn)[1]
mlrun/runtimes/kubejob.py CHANGED
@@ -14,11 +14,12 @@
14
14
 
15
15
  import warnings
16
16
 
17
+ from mlrun_pipelines.common.ops import build_op
18
+
17
19
  import mlrun.common.schemas
18
20
  import mlrun.db
19
21
  import mlrun.errors
20
22
 
21
- from ..kfpops import build_op
22
23
  from ..model import RunObject
23
24
  from .pod import KubeResource
24
25
 
mlrun/runtimes/local.py CHANGED
@@ -33,6 +33,7 @@ from sys import executable
33
33
  from nuclio import Event
34
34
 
35
35
  import mlrun
36
+ import mlrun.common.constants as mlrun_constants
36
37
  from mlrun.lists import RunList
37
38
 
38
39
  from ..errors import err_to_str
@@ -257,7 +258,8 @@ class LocalRuntime(BaseRuntime, ParallelRunner):
257
258
  set_paths(os.path.realpath("."))
258
259
 
259
260
  if (
260
- runobj.metadata.labels.get("kind") == RemoteSparkRuntime.kind
261
+ runobj.metadata.labels.get(mlrun_constants.MLRunInternalLabels.kind)
262
+ == RemoteSparkRuntime.kind
261
263
  and environ["MLRUN_SPARK_CLIENT_IGZ_SPARK"] == "true"
262
264
  ):
263
265
  from mlrun.runtimes.remotesparkjob import igz_spark_pre_hook
@@ -382,13 +384,20 @@ def load_module(file_name, handler, context):
382
384
  if spec is None:
383
385
  raise RunError(f"Cannot import from {file_name!r}")
384
386
  module = imputil.module_from_spec(spec)
387
+ sys.modules[mod_name] = module
385
388
  spec.loader.exec_module(module)
386
389
 
387
390
  class_args = {}
388
391
  if context:
389
392
  class_args = copy(context._parameters.get("_init_args", {}))
390
393
 
391
- return get_handler_extended(handler, context, class_args, namespaces=module)
394
+ return get_handler_extended(
395
+ handler,
396
+ context,
397
+ class_args,
398
+ namespaces=module,
399
+ reload_modules=context._reset_on_run,
400
+ )
392
401
 
393
402
 
394
403
  def run_exec(cmd, args, env=None, cwd=None):
@@ -493,7 +502,7 @@ def exec_from_params(handler, runobj: RunObject, context: MLClientCtx, cwd=None)
493
502
  logger.warning("Run was aborted", err=err_to_str(exc))
494
503
  # Run was aborted, the state run state is updated by the abort job, no need to commit again
495
504
  context.set_state(
496
- mlrun.runtimes.constants.RunStates.aborted, commit=False
505
+ mlrun.common.runtimes.constants.RunStates.aborted, commit=False
497
506
  )
498
507
  commit = False
499
508
  except Exception as exc:
@@ -21,28 +21,8 @@ from mlrun.config import config
21
21
  from .. import MPIJobCRDVersions
22
22
  from .abstract import AbstractMPIJobRuntime
23
23
  from .v1 import MpiRuntimeV1
24
- from .v1alpha1 import MpiRuntimeV1Alpha1
25
24
 
26
25
 
27
26
  def _resolve_mpijob_crd_version():
28
27
  # config is expected to get enriched from the API through the client-spec
29
28
  return config.mpijob_crd_version or MPIJobCRDVersions.default()
30
-
31
-
32
- class MpiRuntimeContainer(containers.DeclarativeContainer):
33
- resolver = providers.Callable(
34
- _resolve_mpijob_crd_version,
35
- )
36
-
37
- selector = providers.Selector(
38
- resolver,
39
- v1=providers.Object(MpiRuntimeV1),
40
- v1alpha1=providers.Object(MpiRuntimeV1Alpha1),
41
- )
42
-
43
- # An empty selector to be overriden by the API
44
- handler_selector = providers.Selector(
45
- resolver,
46
- v1=providers.Object(None),
47
- v1alpha1=providers.Object(None),
48
- )
@@ -11,7 +11,7 @@
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
- from mlrun.runtimes.constants import MPIJobCRDVersions, MPIJobV1CleanPodPolicies
14
+ from mlrun.common.runtimes.constants import MPIJobCRDVersions, MPIJobV1CleanPodPolicies
15
15
  from mlrun.runtimes.mpijob.abstract import AbstractMPIJobRuntime, MPIResourceSpec
16
16
 
17
17