mlrun 1.6.4rc2__py3-none-any.whl → 1.7.0rc20__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 (291) hide show
  1. mlrun/__init__.py +11 -1
  2. mlrun/__main__.py +26 -112
  3. mlrun/alerts/__init__.py +15 -0
  4. mlrun/alerts/alert.py +144 -0
  5. mlrun/api/schemas/__init__.py +5 -4
  6. mlrun/artifacts/__init__.py +8 -3
  7. mlrun/artifacts/base.py +46 -257
  8. mlrun/artifacts/dataset.py +11 -192
  9. mlrun/artifacts/manager.py +47 -48
  10. mlrun/artifacts/model.py +31 -159
  11. mlrun/artifacts/plots.py +23 -380
  12. mlrun/common/constants.py +69 -0
  13. mlrun/common/db/sql_session.py +2 -3
  14. mlrun/common/formatters/__init__.py +19 -0
  15. mlrun/common/formatters/artifact.py +21 -0
  16. mlrun/common/formatters/base.py +78 -0
  17. mlrun/common/formatters/function.py +41 -0
  18. mlrun/common/formatters/pipeline.py +53 -0
  19. mlrun/common/formatters/project.py +51 -0
  20. mlrun/common/helpers.py +1 -2
  21. mlrun/common/model_monitoring/helpers.py +9 -5
  22. mlrun/{runtimes → common/runtimes}/constants.py +37 -9
  23. mlrun/common/schemas/__init__.py +24 -4
  24. mlrun/common/schemas/alert.py +203 -0
  25. mlrun/common/schemas/api_gateway.py +148 -0
  26. mlrun/common/schemas/artifact.py +18 -8
  27. mlrun/common/schemas/auth.py +11 -5
  28. mlrun/common/schemas/background_task.py +1 -1
  29. mlrun/common/schemas/client_spec.py +4 -1
  30. mlrun/common/schemas/feature_store.py +16 -16
  31. mlrun/common/schemas/frontend_spec.py +8 -7
  32. mlrun/common/schemas/function.py +5 -1
  33. mlrun/common/schemas/hub.py +11 -18
  34. mlrun/common/schemas/memory_reports.py +2 -2
  35. mlrun/common/schemas/model_monitoring/__init__.py +18 -3
  36. mlrun/common/schemas/model_monitoring/constants.py +83 -26
  37. mlrun/common/schemas/model_monitoring/grafana.py +13 -9
  38. mlrun/common/schemas/model_monitoring/model_endpoints.py +99 -16
  39. mlrun/common/schemas/notification.py +4 -4
  40. mlrun/common/schemas/object.py +2 -2
  41. mlrun/{runtimes/mpijob/v1alpha1.py → common/schemas/pagination.py} +10 -13
  42. mlrun/common/schemas/pipeline.py +1 -10
  43. mlrun/common/schemas/project.py +24 -23
  44. mlrun/common/schemas/runtime_resource.py +8 -12
  45. mlrun/common/schemas/schedule.py +3 -3
  46. mlrun/common/schemas/tag.py +1 -2
  47. mlrun/common/schemas/workflow.py +2 -2
  48. mlrun/common/types.py +7 -1
  49. mlrun/config.py +54 -17
  50. mlrun/data_types/to_pandas.py +10 -12
  51. mlrun/datastore/__init__.py +5 -8
  52. mlrun/datastore/alibaba_oss.py +130 -0
  53. mlrun/datastore/azure_blob.py +17 -5
  54. mlrun/datastore/base.py +62 -39
  55. mlrun/datastore/datastore.py +28 -9
  56. mlrun/datastore/datastore_profile.py +146 -20
  57. mlrun/datastore/filestore.py +0 -1
  58. mlrun/datastore/google_cloud_storage.py +6 -2
  59. mlrun/datastore/hdfs.py +56 -0
  60. mlrun/datastore/inmem.py +2 -2
  61. mlrun/datastore/redis.py +6 -2
  62. mlrun/datastore/s3.py +9 -0
  63. mlrun/datastore/snowflake_utils.py +43 -0
  64. mlrun/datastore/sources.py +201 -96
  65. mlrun/datastore/spark_utils.py +1 -2
  66. mlrun/datastore/store_resources.py +7 -7
  67. mlrun/datastore/targets.py +358 -104
  68. mlrun/datastore/utils.py +72 -58
  69. mlrun/datastore/v3io.py +5 -1
  70. mlrun/db/base.py +185 -35
  71. mlrun/db/factory.py +1 -1
  72. mlrun/db/httpdb.py +614 -179
  73. mlrun/db/nopdb.py +210 -26
  74. mlrun/errors.py +12 -1
  75. mlrun/execution.py +41 -24
  76. mlrun/feature_store/__init__.py +0 -2
  77. mlrun/feature_store/api.py +40 -72
  78. mlrun/feature_store/common.py +1 -1
  79. mlrun/feature_store/feature_set.py +76 -55
  80. mlrun/feature_store/feature_vector.py +28 -30
  81. mlrun/feature_store/ingestion.py +7 -6
  82. mlrun/feature_store/retrieval/base.py +16 -11
  83. mlrun/feature_store/retrieval/conversion.py +11 -13
  84. mlrun/feature_store/retrieval/dask_merger.py +2 -0
  85. mlrun/feature_store/retrieval/job.py +9 -3
  86. mlrun/feature_store/retrieval/local_merger.py +2 -0
  87. mlrun/feature_store/retrieval/spark_merger.py +34 -24
  88. mlrun/feature_store/steps.py +37 -34
  89. mlrun/features.py +9 -20
  90. mlrun/frameworks/_common/artifacts_library.py +9 -9
  91. mlrun/frameworks/_common/mlrun_interface.py +5 -5
  92. mlrun/frameworks/_common/model_handler.py +48 -48
  93. mlrun/frameworks/_common/plan.py +2 -3
  94. mlrun/frameworks/_common/producer.py +3 -4
  95. mlrun/frameworks/_common/utils.py +5 -5
  96. mlrun/frameworks/_dl_common/loggers/logger.py +6 -7
  97. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +9 -9
  98. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +23 -47
  99. mlrun/frameworks/_ml_common/artifacts_library.py +1 -2
  100. mlrun/frameworks/_ml_common/loggers/logger.py +3 -4
  101. mlrun/frameworks/_ml_common/loggers/mlrun_logger.py +4 -5
  102. mlrun/frameworks/_ml_common/model_handler.py +24 -24
  103. mlrun/frameworks/_ml_common/pkl_model_server.py +2 -2
  104. mlrun/frameworks/_ml_common/plan.py +1 -1
  105. mlrun/frameworks/_ml_common/plans/calibration_curve_plan.py +2 -3
  106. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +2 -3
  107. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  108. mlrun/frameworks/_ml_common/plans/feature_importance_plan.py +3 -3
  109. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  110. mlrun/frameworks/_ml_common/utils.py +4 -4
  111. mlrun/frameworks/auto_mlrun/auto_mlrun.py +9 -9
  112. mlrun/frameworks/huggingface/model_server.py +4 -4
  113. mlrun/frameworks/lgbm/__init__.py +33 -33
  114. mlrun/frameworks/lgbm/callbacks/callback.py +2 -4
  115. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -5
  116. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -5
  117. mlrun/frameworks/lgbm/mlrun_interfaces/booster_mlrun_interface.py +1 -3
  118. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +6 -6
  119. mlrun/frameworks/lgbm/model_handler.py +10 -10
  120. mlrun/frameworks/lgbm/model_server.py +6 -6
  121. mlrun/frameworks/lgbm/utils.py +5 -5
  122. mlrun/frameworks/onnx/dataset.py +8 -8
  123. mlrun/frameworks/onnx/mlrun_interface.py +3 -3
  124. mlrun/frameworks/onnx/model_handler.py +6 -6
  125. mlrun/frameworks/onnx/model_server.py +7 -7
  126. mlrun/frameworks/parallel_coordinates.py +4 -3
  127. mlrun/frameworks/pytorch/__init__.py +18 -18
  128. mlrun/frameworks/pytorch/callbacks/callback.py +4 -5
  129. mlrun/frameworks/pytorch/callbacks/logging_callback.py +17 -17
  130. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +11 -11
  131. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +23 -29
  132. mlrun/frameworks/pytorch/callbacks_handler.py +38 -38
  133. mlrun/frameworks/pytorch/mlrun_interface.py +20 -20
  134. mlrun/frameworks/pytorch/model_handler.py +17 -17
  135. mlrun/frameworks/pytorch/model_server.py +7 -7
  136. mlrun/frameworks/sklearn/__init__.py +13 -13
  137. mlrun/frameworks/sklearn/estimator.py +4 -4
  138. mlrun/frameworks/sklearn/metrics_library.py +14 -14
  139. mlrun/frameworks/sklearn/mlrun_interface.py +3 -6
  140. mlrun/frameworks/sklearn/model_handler.py +2 -2
  141. mlrun/frameworks/tf_keras/__init__.py +10 -7
  142. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +15 -15
  143. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +11 -11
  144. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +19 -23
  145. mlrun/frameworks/tf_keras/mlrun_interface.py +9 -11
  146. mlrun/frameworks/tf_keras/model_handler.py +14 -14
  147. mlrun/frameworks/tf_keras/model_server.py +6 -6
  148. mlrun/frameworks/xgboost/__init__.py +13 -13
  149. mlrun/frameworks/xgboost/model_handler.py +6 -6
  150. mlrun/k8s_utils.py +14 -16
  151. mlrun/launcher/__init__.py +1 -1
  152. mlrun/launcher/base.py +16 -15
  153. mlrun/launcher/client.py +8 -6
  154. mlrun/launcher/factory.py +1 -1
  155. mlrun/launcher/local.py +17 -11
  156. mlrun/launcher/remote.py +16 -10
  157. mlrun/lists.py +7 -6
  158. mlrun/model.py +238 -73
  159. mlrun/model_monitoring/__init__.py +1 -1
  160. mlrun/model_monitoring/api.py +138 -315
  161. mlrun/model_monitoring/application.py +5 -296
  162. mlrun/model_monitoring/applications/__init__.py +24 -0
  163. mlrun/model_monitoring/applications/_application_steps.py +157 -0
  164. mlrun/model_monitoring/applications/base.py +282 -0
  165. mlrun/model_monitoring/applications/context.py +214 -0
  166. mlrun/model_monitoring/applications/evidently_base.py +211 -0
  167. mlrun/model_monitoring/applications/histogram_data_drift.py +349 -0
  168. mlrun/model_monitoring/applications/results.py +99 -0
  169. mlrun/model_monitoring/controller.py +104 -84
  170. mlrun/model_monitoring/controller_handler.py +13 -5
  171. mlrun/model_monitoring/db/__init__.py +18 -0
  172. mlrun/model_monitoring/{stores → db/stores}/__init__.py +43 -36
  173. mlrun/model_monitoring/db/stores/base/__init__.py +15 -0
  174. mlrun/model_monitoring/{stores/model_endpoint_store.py → db/stores/base/store.py} +64 -40
  175. mlrun/model_monitoring/db/stores/sqldb/__init__.py +13 -0
  176. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +71 -0
  177. mlrun/model_monitoring/{stores → db/stores/sqldb}/models/base.py +109 -5
  178. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +88 -0
  179. mlrun/model_monitoring/{stores/models/mysql.py → db/stores/sqldb/models/sqlite.py} +19 -13
  180. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +684 -0
  181. mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +13 -0
  182. mlrun/model_monitoring/{stores/kv_model_endpoint_store.py → db/stores/v3io_kv/kv_store.py} +310 -165
  183. mlrun/model_monitoring/db/tsdb/__init__.py +100 -0
  184. mlrun/model_monitoring/db/tsdb/base.py +329 -0
  185. mlrun/model_monitoring/db/tsdb/helpers.py +30 -0
  186. mlrun/model_monitoring/db/tsdb/tdengine/__init__.py +15 -0
  187. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +240 -0
  188. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +45 -0
  189. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +397 -0
  190. mlrun/model_monitoring/db/tsdb/v3io/__init__.py +15 -0
  191. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +117 -0
  192. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +630 -0
  193. mlrun/model_monitoring/evidently_application.py +6 -118
  194. mlrun/model_monitoring/features_drift_table.py +134 -106
  195. mlrun/model_monitoring/helpers.py +127 -28
  196. mlrun/model_monitoring/metrics/__init__.py +13 -0
  197. mlrun/model_monitoring/metrics/histogram_distance.py +127 -0
  198. mlrun/model_monitoring/model_endpoint.py +3 -2
  199. mlrun/model_monitoring/prometheus.py +1 -4
  200. mlrun/model_monitoring/stream_processing.py +62 -231
  201. mlrun/model_monitoring/tracking_policy.py +9 -2
  202. mlrun/model_monitoring/writer.py +152 -124
  203. mlrun/package/__init__.py +6 -6
  204. mlrun/package/context_handler.py +5 -5
  205. mlrun/package/packager.py +7 -7
  206. mlrun/package/packagers/default_packager.py +6 -6
  207. mlrun/package/packagers/numpy_packagers.py +15 -15
  208. mlrun/package/packagers/pandas_packagers.py +5 -5
  209. mlrun/package/packagers/python_standard_library_packagers.py +10 -10
  210. mlrun/package/packagers_manager.py +19 -23
  211. mlrun/package/utils/_formatter.py +6 -6
  212. mlrun/package/utils/_pickler.py +2 -2
  213. mlrun/package/utils/_supported_format.py +4 -4
  214. mlrun/package/utils/log_hint_utils.py +2 -2
  215. mlrun/package/utils/type_hint_utils.py +4 -9
  216. mlrun/platforms/__init__.py +11 -10
  217. mlrun/platforms/iguazio.py +24 -203
  218. mlrun/projects/operations.py +35 -21
  219. mlrun/projects/pipelines.py +68 -99
  220. mlrun/projects/project.py +830 -266
  221. mlrun/render.py +3 -11
  222. mlrun/run.py +162 -166
  223. mlrun/runtimes/__init__.py +62 -7
  224. mlrun/runtimes/base.py +39 -32
  225. mlrun/runtimes/daskjob.py +8 -8
  226. mlrun/runtimes/databricks_job/databricks_cancel_task.py +1 -1
  227. mlrun/runtimes/databricks_job/databricks_runtime.py +7 -7
  228. mlrun/runtimes/databricks_job/databricks_wrapper.py +1 -1
  229. mlrun/runtimes/funcdoc.py +0 -28
  230. mlrun/runtimes/function_reference.py +1 -1
  231. mlrun/runtimes/kubejob.py +28 -122
  232. mlrun/runtimes/local.py +6 -3
  233. mlrun/runtimes/mpijob/__init__.py +0 -20
  234. mlrun/runtimes/mpijob/abstract.py +9 -10
  235. mlrun/runtimes/mpijob/v1.py +1 -1
  236. mlrun/{model_monitoring/stores/models/sqlite.py → runtimes/nuclio/__init__.py} +7 -9
  237. mlrun/runtimes/nuclio/api_gateway.py +709 -0
  238. mlrun/runtimes/nuclio/application/__init__.py +15 -0
  239. mlrun/runtimes/nuclio/application/application.py +523 -0
  240. mlrun/runtimes/nuclio/application/reverse_proxy.go +95 -0
  241. mlrun/runtimes/{function.py → nuclio/function.py} +112 -73
  242. mlrun/runtimes/{nuclio.py → nuclio/nuclio.py} +6 -6
  243. mlrun/runtimes/{serving.py → nuclio/serving.py} +45 -51
  244. mlrun/runtimes/pod.py +286 -88
  245. mlrun/runtimes/remotesparkjob.py +2 -2
  246. mlrun/runtimes/sparkjob/spark3job.py +51 -34
  247. mlrun/runtimes/utils.py +7 -75
  248. mlrun/secrets.py +9 -5
  249. mlrun/serving/remote.py +2 -7
  250. mlrun/serving/routers.py +13 -10
  251. mlrun/serving/server.py +22 -26
  252. mlrun/serving/states.py +99 -25
  253. mlrun/serving/utils.py +3 -3
  254. mlrun/serving/v1_serving.py +6 -7
  255. mlrun/serving/v2_serving.py +59 -20
  256. mlrun/track/tracker.py +2 -1
  257. mlrun/track/tracker_manager.py +3 -3
  258. mlrun/track/trackers/mlflow_tracker.py +1 -2
  259. mlrun/utils/async_http.py +5 -7
  260. mlrun/utils/azure_vault.py +1 -1
  261. mlrun/utils/clones.py +1 -2
  262. mlrun/utils/condition_evaluator.py +3 -3
  263. mlrun/utils/db.py +3 -3
  264. mlrun/utils/helpers.py +183 -197
  265. mlrun/utils/http.py +2 -5
  266. mlrun/utils/logger.py +76 -14
  267. mlrun/utils/notifications/notification/__init__.py +17 -12
  268. mlrun/utils/notifications/notification/base.py +14 -2
  269. mlrun/utils/notifications/notification/console.py +2 -0
  270. mlrun/utils/notifications/notification/git.py +3 -1
  271. mlrun/utils/notifications/notification/ipython.py +3 -1
  272. mlrun/utils/notifications/notification/slack.py +101 -21
  273. mlrun/utils/notifications/notification/webhook.py +11 -1
  274. mlrun/utils/notifications/notification_pusher.py +155 -30
  275. mlrun/utils/retryer.py +208 -0
  276. mlrun/utils/singleton.py +1 -1
  277. mlrun/utils/v3io_clients.py +2 -4
  278. mlrun/utils/version/version.json +2 -2
  279. mlrun/utils/version/version.py +2 -6
  280. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/METADATA +31 -19
  281. mlrun-1.7.0rc20.dist-info/RECORD +353 -0
  282. mlrun/kfpops.py +0 -868
  283. mlrun/model_monitoring/batch.py +0 -1095
  284. mlrun/model_monitoring/stores/models/__init__.py +0 -27
  285. mlrun/model_monitoring/stores/sql_model_endpoint_store.py +0 -384
  286. mlrun/platforms/other.py +0 -306
  287. mlrun-1.6.4rc2.dist-info/RECORD +0 -314
  288. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/LICENSE +0 -0
  289. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/WHEEL +0 -0
  290. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/entry_points.txt +0 -0
  291. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/top_level.txt +0 -0
@@ -30,17 +30,23 @@ __all__ = [
30
30
 
31
31
  from mlrun.runtimes.utils import resolve_spark_operator_version
32
32
 
33
+ from ..common.runtimes.constants import MPIJobCRDVersions
33
34
  from .base import BaseRuntime, RunError, RuntimeClassMode # noqa
34
- from .constants import MPIJobCRDVersions
35
35
  from .daskjob import DaskCluster # noqa
36
36
  from .databricks_job.databricks_runtime import DatabricksRuntime
37
- from .function import RemoteRuntime
38
37
  from .kubejob import KubejobRuntime, KubeResource # noqa
39
38
  from .local import HandlerRuntime, LocalRuntime # noqa
40
- from .mpijob import MpiRuntimeContainer, MpiRuntimeV1, MpiRuntimeV1Alpha1 # noqa
41
- from .nuclio import nuclio_init_hook
39
+ from .mpijob import MpiRuntimeV1 # noqa
40
+ from .nuclio import (
41
+ RemoteRuntime,
42
+ ServingRuntime,
43
+ new_v2_model_server,
44
+ nuclio_init_hook,
45
+ )
46
+ from .nuclio.api_gateway import APIGateway
47
+ from .nuclio.application import ApplicationRuntime
48
+ from .nuclio.serving import serving_subkind
42
49
  from .remotesparkjob import RemoteSparkRuntime
43
- from .serving import ServingRuntime, new_v2_model_server
44
50
  from .sparkjob import Spark3Runtime
45
51
 
46
52
  # for legacy imports (MLModelServer moved from here to /serving)
@@ -86,7 +92,7 @@ def new_model_server(
86
92
  )
87
93
 
88
94
 
89
- class RuntimeKinds(object):
95
+ class RuntimeKinds:
90
96
  remote = "remote"
91
97
  nuclio = "nuclio"
92
98
  dask = "dask"
@@ -98,6 +104,7 @@ class RuntimeKinds(object):
98
104
  local = "local"
99
105
  handler = "handler"
100
106
  databricks = "databricks"
107
+ application = "application"
101
108
 
102
109
  @staticmethod
103
110
  def all():
@@ -112,6 +119,7 @@ class RuntimeKinds(object):
112
119
  RuntimeKinds.mpijob,
113
120
  RuntimeKinds.local,
114
121
  RuntimeKinds.databricks,
122
+ RuntimeKinds.application,
115
123
  ]
116
124
 
117
125
  @staticmethod
@@ -144,6 +152,23 @@ class RuntimeKinds(object):
144
152
  RuntimeKinds.remote,
145
153
  RuntimeKinds.nuclio,
146
154
  RuntimeKinds.serving,
155
+ RuntimeKinds.application,
156
+ ]
157
+
158
+ @staticmethod
159
+ def pure_nuclio_deployed_runtimes():
160
+ return [
161
+ RuntimeKinds.remote,
162
+ RuntimeKinds.nuclio,
163
+ RuntimeKinds.serving,
164
+ ]
165
+
166
+ @staticmethod
167
+ def handlerless_runtimes():
168
+ return [
169
+ RuntimeKinds.serving,
170
+ # Application runtime handler is internal reverse proxy
171
+ RuntimeKinds.application,
147
172
  ]
148
173
 
149
174
  @staticmethod
@@ -208,10 +233,39 @@ class RuntimeKinds(object):
208
233
  # both spark and remote spark uses different mechanism for assigning images
209
234
  return kind not in [RuntimeKinds.spark, RuntimeKinds.remotespark]
210
235
 
236
+ @staticmethod
237
+ def resolve_nuclio_runtime(kind: str, sub_kind: str):
238
+ kind = kind.split(":")[0]
239
+ if kind not in RuntimeKinds.nuclio_runtimes():
240
+ raise ValueError(
241
+ f"Kind {kind} is not a nuclio runtime, available runtimes are {RuntimeKinds.nuclio_runtimes()}"
242
+ )
243
+
244
+ if sub_kind == serving_subkind:
245
+ return ServingRuntime()
246
+
247
+ if kind == RuntimeKinds.application:
248
+ return ApplicationRuntime()
249
+
250
+ runtime = RemoteRuntime()
251
+ runtime.spec.function_kind = sub_kind
252
+ return runtime
253
+
254
+ @staticmethod
255
+ def resolve_nuclio_sub_kind(kind):
256
+ is_nuclio = kind.startswith("nuclio")
257
+ sub_kind = kind[kind.find(":") + 1 :] if is_nuclio and ":" in kind else None
258
+ if kind == RuntimeKinds.serving:
259
+ is_nuclio = True
260
+ sub_kind = serving_subkind
261
+ elif kind == RuntimeKinds.application:
262
+ is_nuclio = True
263
+ return is_nuclio, sub_kind
264
+
211
265
 
212
266
  def get_runtime_class(kind: str):
213
267
  if kind == RuntimeKinds.mpijob:
214
- return MpiRuntimeContainer.selector()
268
+ return MpiRuntimeV1
215
269
 
216
270
  if kind == RuntimeKinds.spark:
217
271
  return Spark3Runtime
@@ -225,6 +279,7 @@ def get_runtime_class(kind: str):
225
279
  RuntimeKinds.local: LocalRuntime,
226
280
  RuntimeKinds.remotespark: RemoteSparkRuntime,
227
281
  RuntimeKinds.databricks: DatabricksRuntime,
282
+ RuntimeKinds.application: ApplicationRuntime,
228
283
  }
229
284
 
230
285
  return kind_runtime_map[kind]
mlrun/runtimes/base.py CHANGED
@@ -18,11 +18,14 @@ import typing
18
18
  import warnings
19
19
  from base64 import b64encode
20
20
  from os import environ
21
- from typing import Callable, Dict, List, Optional, Union
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
 
27
+ import mlrun.common.constants
28
+ import mlrun.common.constants as mlrun_constants
26
29
  import mlrun.common.schemas
27
30
  import mlrun.common.schemas.model_monitoring.constants as mm_constants
28
31
  import mlrun.db
@@ -36,7 +39,6 @@ from mlrun.utils.helpers import generate_object_uri, verify_field_regex
36
39
  from ..config import config
37
40
  from ..datastore import store_manager
38
41
  from ..errors import err_to_str
39
- from ..kfpops import mlrun_op
40
42
  from ..lists import RunList
41
43
  from ..model import BaseMetadata, HyperParamOptions, ImageBuilder, ModelObj, RunObject
42
44
  from ..utils import (
@@ -92,6 +94,7 @@ class FunctionStatus(ModelObj):
92
94
 
93
95
  class FunctionSpec(ModelObj):
94
96
  _dict_fields = spec_fields
97
+ _default_fields_to_strip = []
95
98
 
96
99
  def __init__(
97
100
  self,
@@ -123,7 +126,7 @@ class FunctionSpec(ModelObj):
123
126
  self.entry_points = entry_points or {}
124
127
  self.disable_auto_mount = disable_auto_mount
125
128
  self.allow_empty_resources = None
126
- # the build.source is cloned/extracted to the specified clone_target_dir
129
+ # The build.source is cloned/extracted to the specified clone_target_dir
127
130
  # if a relative path is specified, it will be enriched with a temp dir path
128
131
  self._clone_target_dir = clone_target_dir or None
129
132
 
@@ -169,6 +172,9 @@ class BaseRuntime(ModelObj):
169
172
  _is_nested = False
170
173
  _is_remote = False
171
174
  _dict_fields = ["kind", "metadata", "spec", "status", "verbose"]
175
+ _default_fields_to_strip = ModelObj._default_fields_to_strip + [
176
+ "status", # Function status describes the state rather than configuration
177
+ ]
172
178
 
173
179
  def __init__(self, metadata=None, spec=None):
174
180
  self._metadata = None
@@ -218,7 +224,7 @@ class BaseRuntime(ModelObj):
218
224
  self.metadata.labels[key] = str(value)
219
225
  return self
220
226
 
221
- def set_categories(self, categories: List[str]):
227
+ def set_categories(self, categories: list[str]):
222
228
  self.metadata.categories = mlrun.utils.helpers.as_list(categories)
223
229
 
224
230
  @property
@@ -292,7 +298,7 @@ class BaseRuntime(ModelObj):
292
298
  mlrun.model.Credentials.generate_access_key
293
299
  )
294
300
 
295
- def generate_runtime_k8s_env(self, runobj: RunObject = None) -> List[Dict]:
301
+ def generate_runtime_k8s_env(self, runobj: RunObject = None) -> list[dict]:
296
302
  """
297
303
  Prepares a runtime environment as it's expected by kubernetes.models.V1Container
298
304
 
@@ -313,23 +319,23 @@ class BaseRuntime(ModelObj):
313
319
  name: Optional[str] = "",
314
320
  project: Optional[str] = "",
315
321
  params: Optional[dict] = None,
316
- inputs: Optional[Dict[str, str]] = None,
322
+ inputs: Optional[dict[str, str]] = None,
317
323
  out_path: Optional[str] = "",
318
324
  workdir: Optional[str] = "",
319
325
  artifact_path: Optional[str] = "",
320
326
  watch: Optional[bool] = True,
321
327
  schedule: Optional[Union[str, mlrun.common.schemas.ScheduleCronTrigger]] = None,
322
- hyperparams: Optional[Dict[str, list]] = None,
328
+ hyperparams: Optional[dict[str, list]] = None,
323
329
  hyper_param_options: Optional[HyperParamOptions] = None,
324
330
  verbose: Optional[bool] = None,
325
331
  scrape_metrics: Optional[bool] = None,
326
332
  local: Optional[bool] = False,
327
333
  local_code_path: Optional[str] = None,
328
334
  auto_build: Optional[bool] = None,
329
- param_file_secrets: Optional[Dict[str, str]] = None,
330
- notifications: Optional[List[mlrun.model.Notification]] = None,
331
- returns: Optional[List[Union[str, Dict[str, str]]]] = None,
332
- state_thresholds: Optional[Dict[str, int]] = None,
335
+ param_file_secrets: Optional[dict[str, str]] = None,
336
+ notifications: Optional[list[mlrun.model.Notification]] = None,
337
+ returns: Optional[list[Union[str, dict[str, str]]]] = None,
338
+ state_thresholds: Optional[dict[str, int]] = None,
333
339
  **launcher_kwargs,
334
340
  ) -> RunObject:
335
341
  """
@@ -426,7 +432,7 @@ class BaseRuntime(ModelObj):
426
432
  if task:
427
433
  return task.to_dict()
428
434
 
429
- def _generate_runtime_env(self, runobj: RunObject = None) -> Dict:
435
+ def _generate_runtime_env(self, runobj: RunObject = None) -> dict:
430
436
  """
431
437
  Prepares all available environment variables for usage on a runtime
432
438
  Data will be extracted from several sources and most of them are not guaranteed to be available
@@ -464,11 +470,11 @@ class BaseRuntime(ModelObj):
464
470
  def _store_function(self, runspec, meta, db):
465
471
  meta.labels["kind"] = self.kind
466
472
  mlrun.runtimes.utils.enrich_run_labels(
467
- meta.labels, [mlrun.runtimes.constants.RunLabels.owner]
473
+ meta.labels, [mlrun.common.runtimes.constants.RunLabels.owner]
468
474
  )
469
475
  if runspec.spec.output_path:
470
476
  runspec.spec.output_path = runspec.spec.output_path.replace(
471
- "{{run.user}}", meta.labels["owner"]
477
+ "{{run.user}}", meta.labels[mlrun_constants.MLRunInternalLabels.owner]
472
478
  )
473
479
 
474
480
  if db and self.kind != "handler":
@@ -575,9 +581,9 @@ class BaseRuntime(ModelObj):
575
581
 
576
582
  elif (
577
583
  not was_none
578
- and last_state != mlrun.runtimes.constants.RunStates.completed
584
+ and last_state != mlrun.common.runtimes.constants.RunStates.completed
579
585
  and last_state
580
- not in mlrun.runtimes.constants.RunStates.error_and_abortion_states()
586
+ not in mlrun.common.runtimes.constants.RunStates.error_and_abortion_states()
581
587
  ):
582
588
  try:
583
589
  runtime_cls = mlrun.runtimes.get_runtime_class(kind)
@@ -630,7 +636,9 @@ class BaseRuntime(ModelObj):
630
636
  image = image or self.spec.image or ""
631
637
 
632
638
  image = enrich_image_url(image, client_version, client_python_version)
633
- if not image.startswith("."):
639
+ if not image.startswith(
640
+ mlrun.common.constants.IMAGE_NAME_ENRICH_REGISTRY_PREFIX
641
+ ):
634
642
  return image
635
643
  registry, repository = get_parsed_docker_registry()
636
644
  if registry:
@@ -661,7 +669,7 @@ class BaseRuntime(ModelObj):
661
669
  use_db=True,
662
670
  verbose=None,
663
671
  scrape_metrics=False,
664
- returns: Optional[List[Union[str, Dict[str, str]]]] = None,
672
+ returns: Optional[list[Union[str, dict[str, str]]]] = None,
665
673
  auto_build: bool = False,
666
674
  ):
667
675
  """Run a local or remote task.
@@ -700,11 +708,11 @@ class BaseRuntime(ModelObj):
700
708
  "key": "the_key".
701
709
  :param auto_build: when set to True and the function require build it will be built on the first
702
710
  function run, use only if you dont plan on changing the build config between runs
703
- :return: KubeFlow containerOp
711
+ :return: mlrun_pipelines.models.PipelineNodeWrapper
704
712
  """
705
713
 
706
714
  # if the function contain KFP PipelineParams (futures) pass the full spec to the
707
- # ContainerOp this way KFP will substitute the params with previous step outputs
715
+ # PipelineNodeWrapper this way KFP will substitute the params with previous step outputs
708
716
  if use_db and not self._has_pipeline_param():
709
717
  # if the same function is built as part of the pipeline we do not use the versioned function
710
718
  # rather the latest function w the same tag so we can pick up the updated image/status
@@ -767,7 +775,7 @@ class BaseRuntime(ModelObj):
767
775
  body = fp.read()
768
776
  if self.kind == mlrun.runtimes.RuntimeKinds.serving:
769
777
  body = body + mlrun_footer.format(
770
- mlrun.runtimes.serving.serving_subkind
778
+ mlrun.runtimes.nuclio.serving.serving_subkind
771
779
  )
772
780
 
773
781
  self.spec.build.functionSourceCode = b64encode(body.encode("utf-8")).decode(
@@ -779,10 +787,10 @@ class BaseRuntime(ModelObj):
779
787
 
780
788
  def with_requirements(
781
789
  self,
782
- requirements: Optional[List[str]] = None,
790
+ requirements: Optional[list[str]] = None,
783
791
  overwrite: bool = False,
784
792
  prepare_image_for_deploy: bool = True,
785
- requirements_file: str = "",
793
+ requirements_file: Optional[str] = "",
786
794
  ):
787
795
  """add package requirements from file or list to build spec.
788
796
 
@@ -801,7 +809,7 @@ class BaseRuntime(ModelObj):
801
809
 
802
810
  def with_commands(
803
811
  self,
804
- commands: List[str],
812
+ commands: list[str],
805
813
  overwrite: bool = False,
806
814
  prepare_image_for_deploy: bool = True,
807
815
  ):
@@ -836,6 +844,12 @@ class BaseRuntime(ModelObj):
836
844
  or (build.source and not build.load_source_on_run)
837
845
  )
838
846
 
847
+ def enrich_runtime_spec(
848
+ self,
849
+ project_node_selector: dict[str, str],
850
+ ):
851
+ pass
852
+
839
853
  def prepare_image_for_deploy(self):
840
854
  """
841
855
  if a function has a 'spec.image' it is considered to be deployed,
@@ -870,7 +884,7 @@ class BaseRuntime(ModelObj):
870
884
  data = dict_to_json(struct)
871
885
  stores = store_manager.set(secrets)
872
886
  target = target or "function.yaml"
873
- datastore, subpath = stores.get_or_create_store(target)
887
+ datastore, subpath, url = stores.get_or_create_store(target)
874
888
  datastore.put(subpath, data)
875
889
  logger.info(f"function spec saved to path: {target}")
876
890
  return self
@@ -883,13 +897,6 @@ class BaseRuntime(ModelObj):
883
897
  self, tag=tag, versioned=versioned, refresh=refresh
884
898
  )
885
899
 
886
- def to_dict(self, fields=None, exclude=None, strip=False):
887
- struct = super().to_dict(fields, exclude=exclude)
888
- if strip:
889
- if "status" in struct:
890
- del struct["status"]
891
- return struct
892
-
893
900
  def doc(self):
894
901
  print("function:", self.metadata.name)
895
902
  print(self.spec.description)
mlrun/runtimes/daskjob.py CHANGED
@@ -16,7 +16,7 @@ import inspect
16
16
  import socket
17
17
  import time
18
18
  from os import environ
19
- from typing import Callable, Dict, List, Optional, Union
19
+ from typing import Callable, Optional, Union
20
20
 
21
21
  import mlrun.common.schemas
22
22
  import mlrun.errors
@@ -461,7 +461,7 @@ class DaskCluster(KubejobRuntime):
461
461
 
462
462
  def set_state_thresholds(
463
463
  self,
464
- state_thresholds: Dict[str, str],
464
+ state_thresholds: dict[str, str],
465
465
  patch: bool = True,
466
466
  ):
467
467
  raise NotImplementedError(
@@ -477,23 +477,23 @@ class DaskCluster(KubejobRuntime):
477
477
  name: Optional[str] = "",
478
478
  project: Optional[str] = "",
479
479
  params: Optional[dict] = None,
480
- inputs: Optional[Dict[str, str]] = None,
480
+ inputs: Optional[dict[str, str]] = None,
481
481
  out_path: Optional[str] = "",
482
482
  workdir: Optional[str] = "",
483
483
  artifact_path: Optional[str] = "",
484
484
  watch: Optional[bool] = True,
485
485
  schedule: Optional[Union[str, mlrun.common.schemas.ScheduleCronTrigger]] = None,
486
- hyperparams: Optional[Dict[str, list]] = None,
486
+ hyperparams: Optional[dict[str, list]] = None,
487
487
  hyper_param_options: Optional[mlrun.model.HyperParamOptions] = None,
488
488
  verbose: Optional[bool] = None,
489
489
  scrape_metrics: Optional[bool] = None,
490
490
  local: Optional[bool] = False,
491
491
  local_code_path: Optional[str] = None,
492
492
  auto_build: Optional[bool] = None,
493
- param_file_secrets: Optional[Dict[str, str]] = None,
494
- notifications: Optional[List[mlrun.model.Notification]] = None,
495
- returns: Optional[List[Union[str, Dict[str, str]]]] = None,
496
- state_thresholds: Optional[Dict[str, int]] = None,
493
+ param_file_secrets: Optional[dict[str, str]] = None,
494
+ notifications: Optional[list[mlrun.model.Notification]] = None,
495
+ returns: Optional[list[Union[str, dict[str, str]]]] = None,
496
+ state_thresholds: Optional[dict[str, int]] = None,
497
497
  **launcher_kwargs,
498
498
  ) -> RunObject:
499
499
  if state_thresholds:
@@ -33,7 +33,7 @@ def main():
33
33
  "The Databricks credentials path does not exist."
34
34
  " Please manually cancel the job from the Databricks environment."
35
35
  )
36
- with open(credentials_path, "r") as yaml_file:
36
+ with open(credentials_path) as yaml_file:
37
37
  loaded_data = yaml.safe_load(yaml_file)
38
38
  # use for flat yaml only
39
39
  for key, value in loaded_data.items():
@@ -14,7 +14,7 @@
14
14
 
15
15
  from ast import FunctionDef, parse, unparse
16
16
  from base64 import b64decode, b64encode
17
- from typing import Callable, Dict, List, Optional, Union
17
+ from typing import Callable, Optional, Union
18
18
 
19
19
  import mlrun
20
20
  import mlrun.runtimes.kubejob as kubejob
@@ -215,23 +215,23 @@ def run_mlrun_databricks_job(context,task_parameters: dict, **kwargs):
215
215
  name: Optional[str] = "",
216
216
  project: Optional[str] = "",
217
217
  params: Optional[dict] = None,
218
- inputs: Optional[Dict[str, str]] = None,
218
+ inputs: Optional[dict[str, str]] = None,
219
219
  out_path: Optional[str] = "",
220
220
  workdir: Optional[str] = "",
221
221
  artifact_path: Optional[str] = "",
222
222
  watch: Optional[bool] = True,
223
223
  schedule: Optional[Union[str, mlrun.common.schemas.ScheduleCronTrigger]] = None,
224
- hyperparams: Optional[Dict[str, list]] = None,
224
+ hyperparams: Optional[dict[str, list]] = None,
225
225
  hyper_param_options: Optional[HyperParamOptions] = None,
226
226
  verbose: Optional[bool] = None,
227
227
  scrape_metrics: Optional[bool] = None,
228
228
  local: Optional[bool] = False,
229
229
  local_code_path: Optional[str] = None,
230
230
  auto_build: Optional[bool] = None,
231
- param_file_secrets: Optional[Dict[str, str]] = None,
232
- notifications: Optional[List[mlrun.model.Notification]] = None,
233
- returns: Optional[List[Union[str, Dict[str, str]]]] = None,
234
- state_thresholds: Optional[Dict[str, int]] = None,
231
+ param_file_secrets: Optional[dict[str, str]] = None,
232
+ notifications: Optional[list[mlrun.model.Notification]] = None,
233
+ returns: Optional[list[Union[str, dict[str, str]]]] = None,
234
+ state_thresholds: Optional[dict[str, int]] = None,
235
235
  **launcher_kwargs,
236
236
  ) -> RunObject:
237
237
  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]
@@ -111,7 +111,7 @@ class FunctionReference(ModelObj):
111
111
  code = self.code
112
112
  if kind == mlrun.runtimes.RuntimeKinds.serving:
113
113
  code = code + mlrun_footer.format(
114
- mlrun.runtimes.serving.serving_subkind
114
+ mlrun.runtimes.nuclio.serving.serving_subkind
115
115
  )
116
116
  func = mlrun.new_function(
117
117
  self.name, kind=kind, image=self.image or default_image