mlrun 1.7.2rc4__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.

Files changed (275) hide show
  1. mlrun/__init__.py +26 -22
  2. mlrun/__main__.py +15 -16
  3. mlrun/alerts/alert.py +150 -15
  4. mlrun/api/schemas/__init__.py +1 -9
  5. mlrun/artifacts/__init__.py +2 -3
  6. mlrun/artifacts/base.py +62 -19
  7. mlrun/artifacts/dataset.py +17 -17
  8. mlrun/artifacts/document.py +454 -0
  9. mlrun/artifacts/manager.py +28 -18
  10. mlrun/artifacts/model.py +91 -59
  11. mlrun/artifacts/plots.py +2 -2
  12. mlrun/common/constants.py +8 -0
  13. mlrun/common/formatters/__init__.py +1 -0
  14. mlrun/common/formatters/artifact.py +1 -1
  15. mlrun/common/formatters/feature_set.py +2 -0
  16. mlrun/common/formatters/function.py +1 -0
  17. mlrun/{model_monitoring/db/stores/v3io_kv/__init__.py → common/formatters/model_endpoint.py} +17 -0
  18. mlrun/common/formatters/pipeline.py +1 -2
  19. mlrun/common/formatters/project.py +9 -0
  20. mlrun/common/model_monitoring/__init__.py +0 -5
  21. mlrun/common/model_monitoring/helpers.py +12 -62
  22. mlrun/common/runtimes/constants.py +25 -4
  23. mlrun/common/schemas/__init__.py +9 -5
  24. mlrun/common/schemas/alert.py +114 -19
  25. mlrun/common/schemas/api_gateway.py +3 -3
  26. mlrun/common/schemas/artifact.py +22 -9
  27. mlrun/common/schemas/auth.py +8 -4
  28. mlrun/common/schemas/background_task.py +7 -7
  29. mlrun/common/schemas/client_spec.py +4 -4
  30. mlrun/common/schemas/clusterization_spec.py +2 -2
  31. mlrun/common/schemas/common.py +53 -3
  32. mlrun/common/schemas/constants.py +15 -0
  33. mlrun/common/schemas/datastore_profile.py +1 -1
  34. mlrun/common/schemas/feature_store.py +9 -9
  35. mlrun/common/schemas/frontend_spec.py +4 -4
  36. mlrun/common/schemas/function.py +10 -10
  37. mlrun/common/schemas/hub.py +1 -1
  38. mlrun/common/schemas/k8s.py +3 -3
  39. mlrun/common/schemas/memory_reports.py +3 -3
  40. mlrun/common/schemas/model_monitoring/__init__.py +4 -8
  41. mlrun/common/schemas/model_monitoring/constants.py +127 -46
  42. mlrun/common/schemas/model_monitoring/grafana.py +18 -12
  43. mlrun/common/schemas/model_monitoring/model_endpoints.py +154 -160
  44. mlrun/common/schemas/notification.py +24 -3
  45. mlrun/common/schemas/object.py +1 -1
  46. mlrun/common/schemas/pagination.py +4 -4
  47. mlrun/common/schemas/partition.py +142 -0
  48. mlrun/common/schemas/pipeline.py +3 -3
  49. mlrun/common/schemas/project.py +26 -18
  50. mlrun/common/schemas/runs.py +3 -3
  51. mlrun/common/schemas/runtime_resource.py +5 -5
  52. mlrun/common/schemas/schedule.py +1 -1
  53. mlrun/common/schemas/secret.py +1 -1
  54. mlrun/{model_monitoring/db/stores/sqldb/__init__.py → common/schemas/serving.py} +10 -1
  55. mlrun/common/schemas/tag.py +3 -3
  56. mlrun/common/schemas/workflow.py +6 -5
  57. mlrun/common/types.py +1 -0
  58. mlrun/config.py +157 -89
  59. mlrun/data_types/__init__.py +5 -3
  60. mlrun/data_types/infer.py +13 -3
  61. mlrun/data_types/spark.py +2 -1
  62. mlrun/datastore/__init__.py +59 -18
  63. mlrun/datastore/alibaba_oss.py +4 -1
  64. mlrun/datastore/azure_blob.py +4 -1
  65. mlrun/datastore/base.py +19 -24
  66. mlrun/datastore/datastore.py +10 -4
  67. mlrun/datastore/datastore_profile.py +178 -45
  68. mlrun/datastore/dbfs_store.py +4 -1
  69. mlrun/datastore/filestore.py +4 -1
  70. mlrun/datastore/google_cloud_storage.py +4 -1
  71. mlrun/datastore/hdfs.py +4 -1
  72. mlrun/datastore/inmem.py +4 -1
  73. mlrun/datastore/redis.py +4 -1
  74. mlrun/datastore/s3.py +14 -3
  75. mlrun/datastore/sources.py +89 -92
  76. mlrun/datastore/store_resources.py +7 -4
  77. mlrun/datastore/storeytargets.py +51 -16
  78. mlrun/datastore/targets.py +38 -31
  79. mlrun/datastore/utils.py +87 -4
  80. mlrun/datastore/v3io.py +4 -1
  81. mlrun/datastore/vectorstore.py +291 -0
  82. mlrun/datastore/wasbfs/fs.py +13 -12
  83. mlrun/db/base.py +286 -100
  84. mlrun/db/httpdb.py +1562 -490
  85. mlrun/db/nopdb.py +250 -83
  86. mlrun/errors.py +6 -2
  87. mlrun/execution.py +194 -50
  88. mlrun/feature_store/__init__.py +2 -10
  89. mlrun/feature_store/api.py +20 -458
  90. mlrun/feature_store/common.py +9 -9
  91. mlrun/feature_store/feature_set.py +20 -18
  92. mlrun/feature_store/feature_vector.py +105 -479
  93. mlrun/feature_store/feature_vector_utils.py +466 -0
  94. mlrun/feature_store/retrieval/base.py +15 -11
  95. mlrun/feature_store/retrieval/job.py +2 -1
  96. mlrun/feature_store/retrieval/storey_merger.py +1 -1
  97. mlrun/feature_store/steps.py +3 -3
  98. mlrun/features.py +30 -13
  99. mlrun/frameworks/__init__.py +1 -2
  100. mlrun/frameworks/_common/__init__.py +1 -2
  101. mlrun/frameworks/_common/artifacts_library.py +2 -2
  102. mlrun/frameworks/_common/mlrun_interface.py +10 -6
  103. mlrun/frameworks/_common/model_handler.py +31 -31
  104. mlrun/frameworks/_common/producer.py +3 -1
  105. mlrun/frameworks/_dl_common/__init__.py +1 -2
  106. mlrun/frameworks/_dl_common/loggers/__init__.py +1 -2
  107. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +4 -4
  108. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +3 -3
  109. mlrun/frameworks/_ml_common/__init__.py +1 -2
  110. mlrun/frameworks/_ml_common/loggers/__init__.py +1 -2
  111. mlrun/frameworks/_ml_common/model_handler.py +21 -21
  112. mlrun/frameworks/_ml_common/plans/__init__.py +1 -2
  113. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +3 -1
  114. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  115. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  116. mlrun/frameworks/auto_mlrun/__init__.py +1 -2
  117. mlrun/frameworks/auto_mlrun/auto_mlrun.py +22 -15
  118. mlrun/frameworks/huggingface/__init__.py +1 -2
  119. mlrun/frameworks/huggingface/model_server.py +9 -9
  120. mlrun/frameworks/lgbm/__init__.py +47 -44
  121. mlrun/frameworks/lgbm/callbacks/__init__.py +1 -2
  122. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -2
  123. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -2
  124. mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -2
  125. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +5 -5
  126. mlrun/frameworks/lgbm/model_handler.py +15 -11
  127. mlrun/frameworks/lgbm/model_server.py +11 -7
  128. mlrun/frameworks/lgbm/utils.py +2 -2
  129. mlrun/frameworks/onnx/__init__.py +1 -2
  130. mlrun/frameworks/onnx/dataset.py +3 -3
  131. mlrun/frameworks/onnx/mlrun_interface.py +2 -2
  132. mlrun/frameworks/onnx/model_handler.py +7 -5
  133. mlrun/frameworks/onnx/model_server.py +8 -6
  134. mlrun/frameworks/parallel_coordinates.py +11 -11
  135. mlrun/frameworks/pytorch/__init__.py +22 -23
  136. mlrun/frameworks/pytorch/callbacks/__init__.py +1 -2
  137. mlrun/frameworks/pytorch/callbacks/callback.py +2 -1
  138. mlrun/frameworks/pytorch/callbacks/logging_callback.py +15 -8
  139. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +19 -12
  140. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +22 -15
  141. mlrun/frameworks/pytorch/callbacks_handler.py +36 -30
  142. mlrun/frameworks/pytorch/mlrun_interface.py +17 -17
  143. mlrun/frameworks/pytorch/model_handler.py +21 -17
  144. mlrun/frameworks/pytorch/model_server.py +13 -9
  145. mlrun/frameworks/sklearn/__init__.py +19 -18
  146. mlrun/frameworks/sklearn/estimator.py +2 -2
  147. mlrun/frameworks/sklearn/metric.py +3 -3
  148. mlrun/frameworks/sklearn/metrics_library.py +8 -6
  149. mlrun/frameworks/sklearn/mlrun_interface.py +3 -2
  150. mlrun/frameworks/sklearn/model_handler.py +4 -3
  151. mlrun/frameworks/tf_keras/__init__.py +11 -12
  152. mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -2
  153. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +17 -14
  154. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +15 -12
  155. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +21 -18
  156. mlrun/frameworks/tf_keras/model_handler.py +17 -13
  157. mlrun/frameworks/tf_keras/model_server.py +12 -8
  158. mlrun/frameworks/xgboost/__init__.py +19 -18
  159. mlrun/frameworks/xgboost/model_handler.py +13 -9
  160. mlrun/k8s_utils.py +2 -5
  161. mlrun/launcher/base.py +3 -4
  162. mlrun/launcher/client.py +2 -2
  163. mlrun/launcher/local.py +6 -2
  164. mlrun/launcher/remote.py +1 -1
  165. mlrun/lists.py +8 -4
  166. mlrun/model.py +132 -46
  167. mlrun/model_monitoring/__init__.py +3 -5
  168. mlrun/model_monitoring/api.py +113 -98
  169. mlrun/model_monitoring/applications/__init__.py +0 -5
  170. mlrun/model_monitoring/applications/_application_steps.py +81 -50
  171. mlrun/model_monitoring/applications/base.py +467 -14
  172. mlrun/model_monitoring/applications/context.py +212 -134
  173. mlrun/model_monitoring/{db/stores/base → applications/evidently}/__init__.py +6 -2
  174. mlrun/model_monitoring/applications/evidently/base.py +146 -0
  175. mlrun/model_monitoring/applications/histogram_data_drift.py +89 -56
  176. mlrun/model_monitoring/applications/results.py +67 -15
  177. mlrun/model_monitoring/controller.py +701 -315
  178. mlrun/model_monitoring/db/__init__.py +0 -2
  179. mlrun/model_monitoring/db/_schedules.py +242 -0
  180. mlrun/model_monitoring/db/_stats.py +189 -0
  181. mlrun/model_monitoring/db/tsdb/__init__.py +33 -22
  182. mlrun/model_monitoring/db/tsdb/base.py +243 -49
  183. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +76 -36
  184. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
  185. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connection.py +213 -0
  186. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +534 -88
  187. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
  188. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +436 -106
  189. mlrun/model_monitoring/helpers.py +356 -114
  190. mlrun/model_monitoring/stream_processing.py +190 -345
  191. mlrun/model_monitoring/tracking_policy.py +11 -4
  192. mlrun/model_monitoring/writer.py +49 -90
  193. mlrun/package/__init__.py +3 -6
  194. mlrun/package/context_handler.py +2 -2
  195. mlrun/package/packager.py +12 -9
  196. mlrun/package/packagers/__init__.py +0 -2
  197. mlrun/package/packagers/default_packager.py +14 -11
  198. mlrun/package/packagers/numpy_packagers.py +16 -7
  199. mlrun/package/packagers/pandas_packagers.py +18 -18
  200. mlrun/package/packagers/python_standard_library_packagers.py +25 -11
  201. mlrun/package/packagers_manager.py +35 -32
  202. mlrun/package/utils/__init__.py +0 -3
  203. mlrun/package/utils/_pickler.py +6 -6
  204. mlrun/platforms/__init__.py +47 -16
  205. mlrun/platforms/iguazio.py +4 -1
  206. mlrun/projects/operations.py +30 -30
  207. mlrun/projects/pipelines.py +116 -47
  208. mlrun/projects/project.py +1292 -329
  209. mlrun/render.py +5 -9
  210. mlrun/run.py +57 -14
  211. mlrun/runtimes/__init__.py +1 -3
  212. mlrun/runtimes/base.py +30 -22
  213. mlrun/runtimes/daskjob.py +9 -9
  214. mlrun/runtimes/databricks_job/databricks_runtime.py +6 -5
  215. mlrun/runtimes/function_reference.py +5 -2
  216. mlrun/runtimes/generators.py +3 -2
  217. mlrun/runtimes/kubejob.py +6 -7
  218. mlrun/runtimes/mounts.py +574 -0
  219. mlrun/runtimes/mpijob/__init__.py +0 -2
  220. mlrun/runtimes/mpijob/abstract.py +7 -6
  221. mlrun/runtimes/nuclio/api_gateway.py +7 -7
  222. mlrun/runtimes/nuclio/application/application.py +11 -13
  223. mlrun/runtimes/nuclio/application/reverse_proxy.go +66 -64
  224. mlrun/runtimes/nuclio/function.py +127 -70
  225. mlrun/runtimes/nuclio/serving.py +105 -37
  226. mlrun/runtimes/pod.py +159 -54
  227. mlrun/runtimes/remotesparkjob.py +3 -2
  228. mlrun/runtimes/sparkjob/__init__.py +0 -2
  229. mlrun/runtimes/sparkjob/spark3job.py +22 -12
  230. mlrun/runtimes/utils.py +7 -6
  231. mlrun/secrets.py +2 -2
  232. mlrun/serving/__init__.py +8 -0
  233. mlrun/serving/merger.py +7 -5
  234. mlrun/serving/remote.py +35 -22
  235. mlrun/serving/routers.py +186 -240
  236. mlrun/serving/server.py +41 -10
  237. mlrun/serving/states.py +432 -118
  238. mlrun/serving/utils.py +13 -2
  239. mlrun/serving/v1_serving.py +3 -2
  240. mlrun/serving/v2_serving.py +161 -203
  241. mlrun/track/__init__.py +1 -1
  242. mlrun/track/tracker.py +2 -2
  243. mlrun/track/trackers/mlflow_tracker.py +6 -5
  244. mlrun/utils/async_http.py +35 -22
  245. mlrun/utils/clones.py +7 -4
  246. mlrun/utils/helpers.py +511 -58
  247. mlrun/utils/logger.py +119 -13
  248. mlrun/utils/notifications/notification/__init__.py +22 -19
  249. mlrun/utils/notifications/notification/base.py +39 -15
  250. mlrun/utils/notifications/notification/console.py +6 -6
  251. mlrun/utils/notifications/notification/git.py +11 -11
  252. mlrun/utils/notifications/notification/ipython.py +10 -9
  253. mlrun/utils/notifications/notification/mail.py +176 -0
  254. mlrun/utils/notifications/notification/slack.py +16 -8
  255. mlrun/utils/notifications/notification/webhook.py +24 -8
  256. mlrun/utils/notifications/notification_pusher.py +191 -200
  257. mlrun/utils/regex.py +12 -2
  258. mlrun/utils/version/version.json +2 -2
  259. {mlrun-1.7.2rc4.dist-info → mlrun-1.8.0.dist-info}/METADATA +69 -54
  260. mlrun-1.8.0.dist-info/RECORD +351 -0
  261. {mlrun-1.7.2rc4.dist-info → mlrun-1.8.0.dist-info}/WHEEL +1 -1
  262. mlrun/model_monitoring/applications/evidently_base.py +0 -137
  263. mlrun/model_monitoring/db/stores/__init__.py +0 -136
  264. mlrun/model_monitoring/db/stores/base/store.py +0 -213
  265. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -71
  266. mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -190
  267. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +0 -103
  268. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -40
  269. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +0 -659
  270. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +0 -726
  271. mlrun/model_monitoring/model_endpoint.py +0 -118
  272. mlrun-1.7.2rc4.dist-info/RECORD +0 -351
  273. {mlrun-1.7.2rc4.dist-info → mlrun-1.8.0.dist-info}/entry_points.txt +0 -0
  274. {mlrun-1.7.2rc4.dist-info → mlrun-1.8.0.dist-info/licenses}/LICENSE +0 -0
  275. {mlrun-1.7.2rc4.dist-info → mlrun-1.8.0.dist-info}/top_level.txt +0 -0
mlrun/artifacts/model.py CHANGED
@@ -30,6 +30,7 @@ from ..utils import StorePrefix, is_relative_path
30
30
  from .base import Artifact, ArtifactSpec, upload_extra_data
31
31
 
32
32
  model_spec_filename = "model_spec.yaml"
33
+ MODEL_OPTIONAL_SUFFIXES = [".tar.gz", ".pkl", ".bin", ".pickle"]
33
34
 
34
35
 
35
36
  class ModelArtifactSpec(ArtifactSpec):
@@ -151,7 +152,7 @@ class ModelArtifact(Artifact):
151
152
  ):
152
153
  if key or body or format or target_path:
153
154
  warnings.warn(
154
- "Artifact constructor parameters are deprecated and will be removed in 1.9.0. "
155
+ "Artifact constructor parameters are deprecated in 1.7.0 and will be removed in 1.10.0. "
155
156
  "Use the metadata and spec parameters instead.",
156
157
  DeprecationWarning,
157
158
  )
@@ -278,7 +279,11 @@ class ModelArtifact(Artifact):
278
279
  )
279
280
  if label_columns:
280
281
  inferer.infer_schema(
281
- df[label_columns], self.spec.outputs, {}, options=InferOptions.Features
282
+ df[label_columns],
283
+ self.spec.outputs,
284
+ {},
285
+ options=InferOptions.Features,
286
+ push_at_start=True,
282
287
  )
283
288
  if with_stats:
284
289
  self.spec.feature_stats = inferer.get_stats(
@@ -303,7 +308,7 @@ class ModelArtifact(Artifact):
303
308
  self.metadata.labels = self.metadata.labels or {}
304
309
  self.metadata.labels["framework"] = self.spec.framework
305
310
 
306
- def upload(self, artifact_path: str = None):
311
+ def upload(self, artifact_path: Optional[str] = None):
307
312
  """
308
313
  internal, upload to target store
309
314
  :param artifact_path: required only for when generating target_path from artifact hash
@@ -324,9 +329,7 @@ class ModelArtifact(Artifact):
324
329
  artifact=self, extra_data=self.spec.extra_data, artifact_path=artifact_path
325
330
  )
326
331
 
327
- # the model spec yaml should not include the tag, as the same model can be used with different tags,
328
- # and the tag is not part of the model spec but the metadata of the model artifact
329
- spec_body = _remove_tag_from_spec_yaml(self)
332
+ spec_body = _sanitize_and_serialize_model_spec_yaml(self)
330
333
  spec_target_path = None
331
334
 
332
335
  if mlrun.mlconf.artifacts.generate_target_path_from_artifact_hash:
@@ -355,7 +358,7 @@ class ModelArtifact(Artifact):
355
358
  def _upload_body_or_file(
356
359
  self,
357
360
  artifact_path: str,
358
- target_model_path: str = None,
361
+ target_model_path: Optional[str] = None,
359
362
  ):
360
363
  body = self.spec.get_body()
361
364
  if body:
@@ -403,12 +406,6 @@ class ModelArtifact(Artifact):
403
406
  return mlrun.get_dataitem(target_model_path).get()
404
407
 
405
408
 
406
- def _get_src_path(model_spec: ModelArtifact, filename):
407
- if model_spec.src_path:
408
- return path.join(model_spec.src_path, filename)
409
- return filename
410
-
411
-
412
409
  def get_model(model_dir, suffix=""):
413
410
  """return model file, model spec object, and list of extra data items
414
411
 
@@ -434,10 +431,20 @@ def get_model(model_dir, suffix=""):
434
431
  model_file = ""
435
432
  model_spec = None
436
433
  extra_dataitems = {}
437
- suffix = suffix or ".pkl"
434
+ default_suffix = ".pkl"
435
+
438
436
  if hasattr(model_dir, "artifact_url"):
439
437
  model_dir = model_dir.artifact_url
440
438
 
439
+ alternative_suffix = next(
440
+ (
441
+ optional_suffix
442
+ for optional_suffix in MODEL_OPTIONAL_SUFFIXES
443
+ if model_dir.lower().endswith(optional_suffix)
444
+ ),
445
+ None,
446
+ )
447
+
441
448
  if mlrun.datastore.is_store_uri(model_dir):
442
449
  model_spec, target = mlrun.datastore.store_manager.get_store_artifact(model_dir)
443
450
  if not model_spec or model_spec.kind != "model":
@@ -448,15 +455,19 @@ def get_model(model_dir, suffix=""):
448
455
  target, model_spec.model_target_file or model_spec.model_file
449
456
  )
450
457
  extra_dataitems = _get_extra(target, model_spec.extra_data)
451
-
458
+ suffix = suffix or default_suffix
452
459
  elif model_dir.lower().endswith(".yaml"):
453
460
  model_spec = _load_model_spec(model_dir)
454
461
  model_file = _get_file_path(model_dir, model_spec.model_file)
455
462
  extra_dataitems = _get_extra(model_dir, model_spec.extra_data)
456
-
457
- elif model_dir.endswith(suffix):
463
+ suffix = suffix or default_suffix
464
+ elif suffix and model_dir.endswith(suffix):
465
+ model_file = model_dir
466
+ elif not suffix and alternative_suffix:
467
+ suffix = alternative_suffix
458
468
  model_file = model_dir
459
469
  else:
470
+ suffix = suffix or default_suffix
460
471
  dirobj = mlrun.datastore.store_manager.object(url=model_dir)
461
472
  model_dir_list = dirobj.listdir()
462
473
  if model_spec_filename in model_dir_list:
@@ -483,49 +494,20 @@ def get_model(model_dir, suffix=""):
483
494
  return temp_path, model_spec, extra_dataitems
484
495
 
485
496
 
486
- def _load_model_spec(spec_path):
487
- data = mlrun.datastore.store_manager.object(url=spec_path).get()
488
- spec = yaml.load(data, Loader=yaml.FullLoader)
489
- return ModelArtifact.from_dict(spec)
490
-
491
-
492
- def _get_file_path(base_path: str, name: str, isdir=False):
493
- if not is_relative_path(name):
494
- return name
495
- if not isdir:
496
- base_path = path.dirname(base_path)
497
- return path.join(base_path, name).replace("\\", "/")
498
-
499
-
500
- def _get_extra(target, extra_data, is_dir=False):
501
- extra_dataitems = {}
502
- for k, v in extra_data.items():
503
- extra_dataitems[k] = mlrun.datastore.store_manager.object(
504
- url=_get_file_path(target, v, isdir=is_dir), key=k
505
- )
506
- return extra_dataitems
507
-
508
-
509
- def _remove_tag_from_spec_yaml(model_spec):
510
- spec_dict = model_spec.to_dict()
511
- spec_dict["metadata"].pop("tag", None)
512
- return yaml.safe_dump(spec_dict)
513
-
514
-
515
497
  def update_model(
516
498
  model_artifact,
517
- parameters: dict = None,
518
- metrics: dict = None,
519
- extra_data: dict = None,
520
- inputs: list[Feature] = None,
521
- outputs: list[Feature] = None,
522
- feature_vector: str = None,
523
- feature_weights: list = None,
499
+ parameters: Optional[dict] = None,
500
+ metrics: Optional[dict] = None,
501
+ extra_data: Optional[dict] = None,
502
+ inputs: Optional[list[Feature]] = None,
503
+ outputs: Optional[list[Feature]] = None,
504
+ feature_vector: Optional[str] = None,
505
+ feature_weights: Optional[list] = None,
524
506
  key_prefix: str = "",
525
- labels: dict = None,
507
+ labels: Optional[dict] = None,
526
508
  write_spec_copy=True,
527
509
  store_object: bool = True,
528
- ):
510
+ ) -> ModelArtifact:
529
511
  """Update model object attributes
530
512
 
531
513
  this method will edit or add attributes to a model object
@@ -593,10 +575,7 @@ def update_model(
593
575
 
594
576
  if write_spec_copy:
595
577
  spec_path = path.join(model_spec.target_path, model_spec_filename)
596
-
597
- # the model spec yaml should not include the tag, as the same model can be used with different tags,
598
- # and the tag is not part of the model spec but the metadata of the model artifact
599
- model_spec_yaml = _remove_tag_from_spec_yaml(model_spec)
578
+ model_spec_yaml = _sanitize_and_serialize_model_spec_yaml(model_spec)
600
579
  mlrun.datastore.store_manager.object(url=spec_path).put(model_spec_yaml)
601
580
 
602
581
  model_spec.db_key = model_spec.db_key or model_spec.key
@@ -609,3 +588,56 @@ def update_model(
609
588
  project=model_spec.project,
610
589
  )
611
590
  return model_spec
591
+
592
+
593
+ def _get_src_path(model_spec: ModelArtifact, filename: str) -> str:
594
+ return path.join(model_spec.src_path, filename) if model_spec.src_path else filename
595
+
596
+
597
+ def _load_model_spec(spec_path) -> ModelArtifact:
598
+ data = mlrun.datastore.store_manager.object(url=spec_path).get()
599
+ spec = yaml.load(data, Loader=yaml.FullLoader)
600
+ return ModelArtifact.from_dict(spec)
601
+
602
+
603
+ def _get_file_path(base_path: str, name: str, isdir: bool = False) -> str:
604
+ if not is_relative_path(name):
605
+ return name
606
+ if not isdir:
607
+ base_path = path.dirname(base_path)
608
+ return path.join(base_path, name).replace("\\", "/")
609
+
610
+
611
+ def _get_extra(target: str, extra_data: dict, is_dir: bool = False) -> dict:
612
+ extra_dataitems = {}
613
+ for k, v in extra_data.items():
614
+ extra_dataitems[k] = mlrun.datastore.store_manager.object(
615
+ url=_get_file_path(target, v, isdir=is_dir), key=k
616
+ )
617
+ return extra_dataitems
618
+
619
+
620
+ def _sanitize_and_serialize_model_spec_yaml(model: ModelArtifact) -> str:
621
+ model_dict = _sanitize_model_spec(model)
622
+ return _serialize_model_spec_yaml(model_dict)
623
+
624
+
625
+ def _sanitize_model_spec(model: ModelArtifact) -> dict:
626
+ model_dict = model.to_dict()
627
+
628
+ # The model spec yaml should not include the tag, as the same model can be used with different tags,
629
+ # and the tag is not part of the model spec but the metadata of the model artifact
630
+ model_dict["metadata"].pop("tag", None)
631
+
632
+ # Remove future packaging links
633
+ if model_dict["spec"].get("extra_data"):
634
+ model_dict["spec"]["extra_data"] = {
635
+ key: item
636
+ for key, item in model_dict["spec"]["extra_data"].items()
637
+ if item is not ...
638
+ }
639
+ return model_dict
640
+
641
+
642
+ def _serialize_model_spec_yaml(model_dict: dict) -> str:
643
+ return yaml.safe_dump(model_dict)
mlrun/artifacts/plots.py CHANGED
@@ -37,7 +37,7 @@ class PlotArtifact(Artifact):
37
37
  ):
38
38
  if key or body or is_inline or target_path:
39
39
  warnings.warn(
40
- "Artifact constructor parameters are deprecated and will be removed in 1.9.0. "
40
+ "Artifact constructor parameters are deprecated in 1.7.0 and will be removed in 1.10.0. "
41
41
  "Use the metadata and spec parameters instead.",
42
42
  DeprecationWarning,
43
43
  )
@@ -96,7 +96,7 @@ class PlotlyArtifact(Artifact):
96
96
  """
97
97
  if key or target_path:
98
98
  warnings.warn(
99
- "Artifact constructor parameters are deprecated and will be removed in 1.9.0. "
99
+ "Artifact constructor parameters are deprecated in 1.7.0 and will be removed in 1.10.0. "
100
100
  "Use the metadata and spec parameters instead.",
101
101
  DeprecationWarning,
102
102
  )
mlrun/common/constants.py CHANGED
@@ -11,6 +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
+ import mlrun.common.types
14
15
 
15
16
  IMAGE_NAME_ENRICH_REGISTRY_PREFIX = "." # prefix for image name to enrich with registry
16
17
  MLRUN_SERVING_CONF = "serving-conf"
@@ -24,6 +25,7 @@ MYSQL_MEDIUMBLOB_SIZE_BYTES = 16 * 1024 * 1024
24
25
  MLRUN_LABEL_PREFIX = "mlrun/"
25
26
  DASK_LABEL_PREFIX = "dask.org/"
26
27
  NUCLIO_LABEL_PREFIX = "nuclio.io/"
28
+ RESERVED_TAG_NAME_LATEST = "latest"
27
29
 
28
30
 
29
31
  class MLRunInternalLabels:
@@ -68,6 +70,7 @@ class MLRunInternalLabels:
68
70
  producer_type = f"{MLRUN_LABEL_PREFIX}producer-type"
69
71
  app_name = f"{MLRUN_LABEL_PREFIX}app-name"
70
72
  endpoint_id = f"{MLRUN_LABEL_PREFIX}endpoint-id"
73
+ endpoint_name = f"{MLRUN_LABEL_PREFIX}endpoint-name"
71
74
  host = "host"
72
75
  job_type = "job-type"
73
76
  kind = "kind"
@@ -86,3 +89,8 @@ class MLRunInternalLabels:
86
89
  for key, value in cls.__dict__.items()
87
90
  if not key.startswith("__") and isinstance(value, str)
88
91
  ]
92
+
93
+
94
+ class DeployStatusTextKind(mlrun.common.types.StrEnum):
95
+ logs = "logs"
96
+ events = "events"
@@ -19,3 +19,4 @@ from .pipeline import PipelineFormat # noqa
19
19
  from .project import ProjectFormat # noqa
20
20
  from .run import RunFormat # noqa
21
21
  from .feature_set import FeatureSetFormat # noqa
22
+ from .model_endpoint import ModelEndpointFormat # noqa
@@ -32,7 +32,7 @@ class ArtifactFormat(ObjectFormat, mlrun.common.types.StrEnum):
32
32
  [
33
33
  "kind",
34
34
  "metadata",
35
- "status",
35
+ "status.state",
36
36
  "project",
37
37
  "spec.producer",
38
38
  "spec.db_key",
@@ -21,6 +21,7 @@ from .base import ObjectFormat
21
21
 
22
22
 
23
23
  class FeatureSetFormat(ObjectFormat, mlrun.common.types.StrEnum):
24
+ full = "full"
24
25
  minimal = "minimal"
25
26
 
26
27
  @staticmethod
@@ -32,6 +33,7 @@ class FeatureSetFormat(ObjectFormat, mlrun.common.types.StrEnum):
32
33
  "metadata.name",
33
34
  "metadata.project",
34
35
  "metadata.tag",
36
+ "metadata.updated",
35
37
  "metadata.uid",
36
38
  "metadata.labels",
37
39
  "spec.entities",
@@ -21,6 +21,7 @@ from .base import ObjectFormat
21
21
 
22
22
 
23
23
  class FunctionFormat(ObjectFormat, mlrun.common.types.StrEnum):
24
+ full = "full"
24
25
  minimal = "minimal"
25
26
 
26
27
  @staticmethod
@@ -11,3 +11,20 @@
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
+ #
15
+
16
+ import typing
17
+
18
+ import mlrun.common.types
19
+
20
+ from .base import ObjectFormat
21
+
22
+
23
+ class ModelEndpointFormat(ObjectFormat, mlrun.common.types.StrEnum):
24
+ full = "full"
25
+
26
+ @staticmethod
27
+ def format_method(_format: str) -> typing.Optional[typing.Callable]:
28
+ return {
29
+ ModelEndpointFormat.full: None,
30
+ }[_format]
@@ -15,11 +15,10 @@
15
15
 
16
16
  import typing
17
17
 
18
+ import mlrun.common.types
18
19
  import mlrun_pipelines.common.ops
19
20
  import mlrun_pipelines.models
20
21
 
21
- import mlrun.common.types
22
-
23
22
  from .base import ObjectFormat
24
23
 
25
24
 
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
 
16
+ import datetime
16
17
  import typing
17
18
 
18
19
  import mlrun.common.schemas
@@ -30,11 +31,18 @@ class ProjectFormat(ObjectFormat, mlrun.common.types.StrEnum):
30
31
  # internal - allowed only in follower mode, only for the leader for upgrade purposes
31
32
  leader = "leader"
32
33
 
34
+ name_and_creation_time = "name_and_creation_time"
35
+
33
36
  @staticmethod
34
37
  def format_method(_format: str) -> typing.Optional[typing.Callable]:
35
38
  def _name_only(project: mlrun.common.schemas.Project) -> str:
36
39
  return project.metadata.name
37
40
 
41
+ def _name_and_creation_time(
42
+ project: mlrun.common.schemas.Project,
43
+ ) -> tuple[str, datetime.datetime]:
44
+ return project.metadata.name, project.metadata.created
45
+
38
46
  def _minimal(
39
47
  project: mlrun.common.schemas.Project,
40
48
  ) -> mlrun.common.schemas.Project:
@@ -48,4 +56,5 @@ class ProjectFormat(ObjectFormat, mlrun.common.types.StrEnum):
48
56
  ProjectFormat.name_only: _name_only,
49
57
  ProjectFormat.minimal: _minimal,
50
58
  ProjectFormat.leader: None,
59
+ ProjectFormat.name_and_creation_time: _name_and_creation_time,
51
60
  }[_format]
@@ -11,8 +11,3 @@
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
- #
15
-
16
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
17
-
18
- from .helpers import create_model_endpoint_uid
@@ -17,11 +17,6 @@ import typing
17
17
 
18
18
  import mlrun.common
19
19
  import mlrun.common.schemas.model_monitoring.constants as mm_constants
20
- from mlrun.common.schemas.model_monitoring import (
21
- EndpointUID,
22
- FunctionURI,
23
- VersionedModel,
24
- )
25
20
 
26
21
  FeatureStats = typing.NewType("FeatureStats", dict[str, dict[str, typing.Any]])
27
22
  Histogram = typing.NewType("Histogram", list[list])
@@ -31,29 +26,6 @@ BinEdges = typing.NewType("BinEdges", list[float])
31
26
  _MAX_FLOAT = sys.float_info.max
32
27
 
33
28
 
34
- def create_model_endpoint_uid(function_uri: str, versioned_model: str):
35
- function_uri = FunctionURI.from_string(function_uri)
36
- versioned_model = VersionedModel.from_string(versioned_model)
37
-
38
- if (
39
- not function_uri.project
40
- or not function_uri.function
41
- or not versioned_model.model
42
- ):
43
- raise ValueError("Both function_uri and versioned_model have to be initialized")
44
-
45
- uid = EndpointUID(
46
- function_uri.project,
47
- function_uri.function,
48
- function_uri.tag,
49
- function_uri.hash_key,
50
- versioned_model.model,
51
- versioned_model.version,
52
- )
53
-
54
- return uid
55
-
56
-
57
29
  def parse_model_endpoint_project_prefix(path: str, project_name: str):
58
30
  return path.split(project_name, 1)[0] + project_name
59
31
 
@@ -64,40 +36,18 @@ def parse_model_endpoint_store_prefix(store_prefix: str):
64
36
  return endpoint, container, path
65
37
 
66
38
 
67
- def parse_monitoring_stream_path(
68
- stream_uri: str, project: str, function_name: str = None
69
- ):
70
- if stream_uri.startswith("kafka://"):
71
- if "?topic" in stream_uri:
72
- raise mlrun.errors.MLRunInvalidArgumentError(
73
- "Custom kafka topic is not allowed"
74
- )
75
- # Add topic to stream kafka uri
76
- if (
77
- function_name is None
78
- or function_name == mm_constants.MonitoringFunctionNames.STREAM
79
- ):
80
- stream_uri += f"?topic=monitoring_stream_{project}"
81
- else:
82
- stream_uri += f"?topic=monitoring_stream_{project}_{function_name}"
83
-
84
- elif stream_uri.startswith("v3io://") and mlrun.mlconf.is_ce_mode():
85
- # V3IO is not supported in CE mode, generating a default http stream path
86
- if function_name is None:
87
- stream_uri = (
88
- mlrun.mlconf.model_endpoint_monitoring.default_http_sink.format(
89
- project=project, namespace=mlrun.mlconf.namespace
90
- )
91
- )
92
- else:
93
- stream_uri = (
94
- mlrun.mlconf.model_endpoint_monitoring.default_http_sink_app.format(
95
- project=project,
96
- application_name=function_name,
97
- namespace=mlrun.mlconf.namespace,
98
- )
99
- )
100
- return stream_uri
39
+ def get_kafka_topic(project: str, function_name: typing.Optional[str] = None) -> str:
40
+ if (
41
+ function_name is None
42
+ or function_name == mm_constants.MonitoringFunctionNames.STREAM
43
+ ):
44
+ function_specifier = ""
45
+ else:
46
+ function_specifier = f"_{function_name}"
47
+
48
+ return (
49
+ f"monitoring_stream_{mlrun.mlconf.system_id}_{project}{function_specifier}_v1"
50
+ )
101
51
 
102
52
 
103
53
  def _get_counts(hist: Histogram) -> BinCounts:
@@ -15,9 +15,8 @@
15
15
  import enum
16
16
  import typing
17
17
 
18
- import mlrun_pipelines.common.models
19
-
20
18
  import mlrun.common.constants as mlrun_constants
19
+ import mlrun_pipelines.common.models
21
20
 
22
21
 
23
22
  class PodPhases:
@@ -195,6 +194,10 @@ class RunStates:
195
194
  # TODO: add aborting state once we have it
196
195
  ]
197
196
 
197
+ @staticmethod
198
+ def notification_states():
199
+ return RunStates.terminal_states() + [RunStates.running]
200
+
198
201
  @staticmethod
199
202
  def run_state_to_pipeline_run_status(run_state: str):
200
203
  if not run_state:
@@ -215,8 +218,26 @@ class RunStates:
215
218
  RunStates.skipped: mlrun_pipelines.common.models.RunStatuses.skipped,
216
219
  }[run_state]
217
220
 
218
-
219
- # TODO: remove this class in 1.9.0 - use only MlrunInternalLabels
221
+ @staticmethod
222
+ def pipeline_run_status_to_run_state(pipeline_run_status):
223
+ if pipeline_run_status not in mlrun_pipelines.common.models.RunStatuses.all():
224
+ raise ValueError(f"Invalid pipeline run status: {pipeline_run_status}")
225
+ return {
226
+ mlrun_pipelines.common.models.RunStatuses.succeeded: RunStates.completed,
227
+ mlrun_pipelines.common.models.RunStatuses.failed: RunStates.error,
228
+ mlrun_pipelines.common.models.RunStatuses.running: RunStates.running,
229
+ mlrun_pipelines.common.models.RunStatuses.pending: RunStates.pending,
230
+ mlrun_pipelines.common.models.RunStatuses.canceled: RunStates.aborted,
231
+ mlrun_pipelines.common.models.RunStatuses.canceling: RunStates.aborting,
232
+ mlrun_pipelines.common.models.RunStatuses.skipped: RunStates.skipped,
233
+ mlrun_pipelines.common.models.RunStatuses.runtime_state_unspecified: RunStates.unknown,
234
+ mlrun_pipelines.common.models.RunStatuses.error: RunStates.error,
235
+ mlrun_pipelines.common.models.RunStatuses.paused: RunStates.unknown,
236
+ mlrun_pipelines.common.models.RunStatuses.unknown: RunStates.unknown,
237
+ }[pipeline_run_status]
238
+
239
+
240
+ # TODO: remove this class in 1.10.0 - use only MlrunInternalLabels
220
241
  class RunLabels(enum.Enum):
221
242
  owner = mlrun_constants.MLRunInternalLabels.owner
222
243
  v3io_user = mlrun_constants.MLRunInternalLabels.v3io_user
@@ -11,10 +11,10 @@
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
- #
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
16
14
 
17
15
  from .alert import (
16
+ AlertActivation,
17
+ AlertActivations,
18
18
  AlertActiveState,
19
19
  AlertConfig,
20
20
  AlertNotification,
@@ -63,6 +63,7 @@ from .clusterization_spec import (
63
63
  from .common import ImageBuilder
64
64
  from .constants import (
65
65
  APIStates,
66
+ ArtifactPartitionByField,
66
67
  ClusterizationRole,
67
68
  DeletionStrategy,
68
69
  FeatureStorePartitionByField,
@@ -138,19 +139,19 @@ from .model_monitoring import (
138
139
  Features,
139
140
  FeatureSetFeatures,
140
141
  FeatureValues,
142
+ FileTargetKind,
141
143
  GrafanaColumn,
142
- GrafanaDataPoint,
143
144
  GrafanaNumberColumn,
144
145
  GrafanaStringColumn,
145
146
  GrafanaTable,
146
- GrafanaTimeSeriesTarget,
147
147
  ModelEndpoint,
148
+ ModelEndpointCreationStrategy,
148
149
  ModelEndpointList,
149
150
  ModelEndpointMetadata,
151
+ ModelEndpointSchema,
150
152
  ModelEndpointSpec,
151
153
  ModelEndpointStatus,
152
154
  ModelMonitoringMode,
153
- ModelMonitoringStoreKinds,
154
155
  MonitoringFunctionNames,
155
156
  TSDBTarget,
156
157
  V3IOTSDBTables,
@@ -159,11 +160,14 @@ from .notification import (
159
160
  Notification,
160
161
  NotificationKind,
161
162
  NotificationSeverity,
163
+ NotificationState,
162
164
  NotificationStatus,
165
+ NotificationSummary,
163
166
  SetNotificationRequest,
164
167
  )
165
168
  from .object import ObjectKind, ObjectMetadata, ObjectSpec, ObjectStatus
166
169
  from .pagination import PaginationInfo
170
+ from .partition import PartitionInterval
167
171
  from .pipeline import PipelinesOutput, PipelinesPagination
168
172
  from .project import (
169
173
  IguazioProject,