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
@@ -15,7 +15,7 @@
15
15
  import os
16
16
  import pathlib
17
17
  import tempfile
18
- from typing import Union
18
+ from typing import Optional, Union
19
19
 
20
20
  from mlrun.artifacts import Artifact
21
21
  from mlrun.datastore import DataItem
@@ -140,7 +140,7 @@ class StrPackager(DefaultPackager):
140
140
  self,
141
141
  data_item: DataItem,
142
142
  is_directory: bool = False,
143
- archive_format: str = None,
143
+ archive_format: Optional[str] = None,
144
144
  ) -> str:
145
145
  """
146
146
  Unpack a data item representing a path string. If the path is of a file, the file is downloaded to a local
@@ -222,7 +222,7 @@ class _BuiltinCollectionPackager(DefaultPackager):
222
222
  return artifact, instructions
223
223
 
224
224
  def unpack_file(
225
- self, data_item: DataItem, file_format: str = None
225
+ self, data_item: DataItem, file_format: Optional[str] = None
226
226
  ) -> Union[dict, list]:
227
227
  """
228
228
  Unpack a builtin collection from file.
@@ -259,7 +259,9 @@ class DictPackager(_BuiltinCollectionPackager):
259
259
 
260
260
  PACKABLE_OBJECT_TYPE = dict
261
261
 
262
- def unpack_file(self, data_item: DataItem, file_format: str = None) -> dict:
262
+ def unpack_file(
263
+ self, data_item: DataItem, file_format: Optional[str] = None
264
+ ) -> dict:
263
265
  """
264
266
  Unpack a dictionary from file.
265
267
 
@@ -285,7 +287,9 @@ class ListPackager(_BuiltinCollectionPackager):
285
287
 
286
288
  PACKABLE_OBJECT_TYPE = list
287
289
 
288
- def unpack_file(self, data_item: DataItem, file_format: str = None) -> list:
290
+ def unpack_file(
291
+ self, data_item: DataItem, file_format: Optional[str] = None
292
+ ) -> list:
289
293
  """
290
294
  Unpack a list from file.
291
295
 
@@ -355,7 +359,9 @@ class TuplePackager(ListPackager):
355
359
  """
356
360
  return super().pack_file(obj=list(obj), key=key, file_format=file_format)
357
361
 
358
- def unpack_file(self, data_item: DataItem, file_format: str = None) -> tuple:
362
+ def unpack_file(
363
+ self, data_item: DataItem, file_format: Optional[str] = None
364
+ ) -> tuple:
359
365
  """
360
366
  Unpack a tuple from file.
361
367
 
@@ -400,7 +406,9 @@ class SetPackager(ListPackager):
400
406
  """
401
407
  return super().pack_file(obj=list(obj), key=key, file_format=file_format)
402
408
 
403
- def unpack_file(self, data_item: DataItem, file_format: str = None) -> set:
409
+ def unpack_file(
410
+ self, data_item: DataItem, file_format: Optional[str] = None
411
+ ) -> set:
404
412
  """
405
413
  Unpack a set from file.
406
414
 
@@ -434,7 +442,9 @@ class FrozensetPackager(SetPackager):
434
442
  """
435
443
  return super().pack_file(obj=set(obj), key=key, file_format=file_format)
436
444
 
437
- def unpack_file(self, data_item: DataItem, file_format: str = None) -> frozenset:
445
+ def unpack_file(
446
+ self, data_item: DataItem, file_format: Optional[str] = None
447
+ ) -> frozenset:
438
448
  """
439
449
  Unpack a frozenset from file.
440
450
 
@@ -481,7 +491,9 @@ class BytesPackager(ListPackager):
481
491
  """
482
492
  return super().pack_file(obj=list(obj), key=key, file_format=file_format)
483
493
 
484
- def unpack_file(self, data_item: DataItem, file_format: str = None) -> bytes:
494
+ def unpack_file(
495
+ self, data_item: DataItem, file_format: Optional[str] = None
496
+ ) -> bytes:
485
497
  """
486
498
  Unpack a bytes from file.
487
499
 
@@ -526,7 +538,9 @@ class BytearrayPackager(BytesPackager):
526
538
  """
527
539
  return super().pack_file(obj=bytes(obj), key=key, file_format=file_format)
528
540
 
529
- def unpack_file(self, data_item: DataItem, file_format: str = None) -> bytearray:
541
+ def unpack_file(
542
+ self, data_item: DataItem, file_format: Optional[str] = None
543
+ ) -> bytearray:
530
544
  """
531
545
  Unpack a bytearray from file.
532
546
 
@@ -585,7 +599,7 @@ class PathPackager(StrPackager):
585
599
  self,
586
600
  data_item: DataItem,
587
601
  is_directory: bool = False,
588
- archive_format: str = None,
602
+ archive_format: Optional[str] = None,
589
603
  ) -> pathlib.Path:
590
604
  """
591
605
  Unpack a data item representing a `Path`. If the path is of a file, the file is downloaded to a local
@@ -17,10 +17,11 @@ import inspect
17
17
  import os
18
18
  import shutil
19
19
  import traceback
20
- from typing import Any, Union
20
+ from typing import Any, Optional, Union
21
21
 
22
+ import mlrun.errors
22
23
  from mlrun.artifacts import Artifact
23
- from mlrun.datastore import DataItem, store_manager
24
+ from mlrun.datastore import DataItem, get_store_resource, store_manager
24
25
  from mlrun.errors import MLRunInvalidArgumentError
25
26
  from mlrun.utils import logger
26
27
 
@@ -41,7 +42,7 @@ class PackagersManager:
41
42
  It prepares the instructions / log hint configurations and then looks for the first packager that fits the task.
42
43
  """
43
44
 
44
- def __init__(self, default_packager: type[Packager] = None):
45
+ def __init__(self, default_packager: Optional[type[Packager]] = None):
45
46
  """
46
47
  Initialize a packagers manager.
47
48
 
@@ -302,18 +303,17 @@ class PackagersManager:
302
303
 
303
304
  def link_packages(
304
305
  self,
305
- additional_artifacts: list[Artifact],
306
+ additional_artifact_uris: dict,
306
307
  additional_results: dict,
307
308
  ):
308
309
  """
309
310
  Link packages to each other according to the provided extra data and metrics spec keys. A future link is
310
311
  marked with ellipses (...). If no link is found, None is used and a warning is printed.
311
312
 
312
- :param additional_artifacts: Additional artifacts to link (should come from an `mlrun.MLClientCtx`).
313
- :param additional_results: Additional results to link (should come from an `mlrun.MLClientCtx`).
313
+ :param additional_artifact_uris: Additional artifact URIs to link (should come from an `mlrun.MLClientCtx`).
314
+ :param additional_results: Additional results to link (should come from an `mlrun.MLClientCtx`).
314
315
  """
315
316
  # Join the manager's artifacts and results with the additional ones to look for a link in all of them:
316
- joined_artifacts = [*additional_artifacts, *self.artifacts]
317
317
  joined_results = {**additional_results, **self.results}
318
318
 
319
319
  # Go over the artifacts and link:
@@ -324,7 +324,10 @@ class PackagersManager:
324
324
  if artifact.spec.extra_data[key] is ...:
325
325
  # Look for an artifact or result with this key to link it:
326
326
  extra_data = self._look_for_extra_data(
327
- key=key, artifacts=joined_artifacts, results=joined_results
327
+ key=key,
328
+ artifacts=self.artifacts,
329
+ artifact_uris=additional_artifact_uris,
330
+ results=joined_results,
328
331
  )
329
332
  # Print a warning if a link is missing:
330
333
  if extra_data is None:
@@ -398,8 +401,8 @@ class PackagersManager:
398
401
  def _get_packager_for_packing(
399
402
  self,
400
403
  obj: Any,
401
- artifact_type: str = None,
402
- configurations: dict = None,
404
+ artifact_type: Optional[str] = None,
405
+ configurations: Optional[dict] = None,
403
406
  ) -> Union[Packager, None]:
404
407
  """
405
408
  Look for a packager that can pack the provided object as the provided artifact type.
@@ -426,7 +429,7 @@ class PackagersManager:
426
429
  self,
427
430
  data_item: Any,
428
431
  type_hint: type,
429
- artifact_type: str = None,
432
+ artifact_type: Optional[str] = None,
430
433
  ) -> Union[Packager, None]:
431
434
  """
432
435
  Look for a packager that can unpack the data item of the given type hint as the provided artifact type.
@@ -664,16 +667,9 @@ class PackagersManager:
664
667
  data_item=data_item,
665
668
  instructions={},
666
669
  )
667
- except Exception as exception:
670
+ except Exception:
668
671
  # Could not unpack as the reduced type hint, collect the exception and go to the next one:
669
- exception_string = "".join(
670
- traceback.format_exception(
671
- etype=type(exception),
672
- value=exception,
673
- tb=exception.__traceback__,
674
- )
675
- )
676
- found_packagers.append((packager, exception_string))
672
+ found_packagers.append((packager, traceback.format_exc()))
677
673
  # Reduce the type hint list and continue:
678
674
  possible_type_hints = TypeHintUtils.reduce_type_hint(
679
675
  type_hint=possible_type_hints
@@ -689,15 +685,8 @@ class PackagersManager:
689
685
  artifact_type=None,
690
686
  instructions={},
691
687
  )
692
- except Exception as exception:
693
- exception_string = "".join(
694
- traceback.format_exception(
695
- etype=type(exception),
696
- value=exception,
697
- tb=exception.__traceback__,
698
- )
699
- )
700
- found_packagers.append((self._default_packager, exception_string))
688
+ except Exception:
689
+ found_packagers.append((self._default_packager, traceback.format_exc()))
701
690
 
702
691
  # The method did not return until this point, raise an error:
703
692
  raise MLRunPackageUnpackingError(
@@ -715,17 +704,31 @@ class PackagersManager:
715
704
  def _look_for_extra_data(
716
705
  key: str,
717
706
  artifacts: list[Artifact],
707
+ artifact_uris: dict,
718
708
  results: dict,
719
709
  ) -> Union[Artifact, str, int, float, None]:
720
710
  """
721
711
  Look for an extra data item (artifact or result) by given key. If not found, None is returned.
722
712
 
723
- :param key: Key to look for.
724
- :param artifacts: Artifacts to look in.
725
- :param results: Results to look in.
713
+ :param key: Key to look for.
714
+ :param artifacts: Artifacts to look in.
715
+ :param artifact_uris: Artifacts URIs to look in.
716
+ :param results: Results to look in.
726
717
 
727
718
  :return: The artifact or result with the same key or None if not found.
728
719
  """
720
+ artifact_uris = artifact_uris or {}
721
+ for _key, uri in artifact_uris.items():
722
+ if key == _key:
723
+ try:
724
+ return get_store_resource(uri)
725
+ except mlrun.errors.MLRunNotFoundError as exc:
726
+ logger.warn(
727
+ f"Artifact {key=} not found when looking for extra data",
728
+ exc=mlrun.errors.err_to_str(exc),
729
+ )
730
+ return None
731
+
729
732
  # Look in the artifacts:
730
733
  for artifact in artifacts:
731
734
  if key == artifact.key:
@@ -11,9 +11,6 @@
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
14
 
18
15
  from ._archiver import ArchiveSupportedFormat
19
16
  from ._formatter import StructFileSupportedFormat
@@ -19,7 +19,7 @@ import sys
19
19
  import tempfile
20
20
  import warnings
21
21
  from types import ModuleType
22
- from typing import Any, Union
22
+ from typing import Any, Optional, Union
23
23
 
24
24
  from mlrun.errors import MLRunInvalidArgumentError
25
25
  from mlrun.utils import logger
@@ -34,7 +34,7 @@ class Pickler:
34
34
 
35
35
  @staticmethod
36
36
  def pickle(
37
- obj: Any, pickle_module_name: str, output_path: str = None
37
+ obj: Any, pickle_module_name: str, output_path: Optional[str] = None
38
38
  ) -> tuple[str, dict[str, Union[str, None]]]:
39
39
  """
40
40
  Pickle an object using the given module. The pickled object will be saved to file to the given output path.
@@ -91,10 +91,10 @@ class Pickler:
91
91
  def unpickle(
92
92
  pickle_path: str,
93
93
  pickle_module_name: str,
94
- object_module_name: str = None,
95
- python_version: str = None,
96
- pickle_module_version: str = None,
97
- object_module_version: str = None,
94
+ object_module_name: Optional[str] = None,
95
+ python_version: Optional[str] = None,
96
+ pickle_module_version: Optional[str] = None,
97
+ object_module_version: Optional[str] = None,
98
98
  ) -> Any:
99
99
  """
100
100
  Unpickle an object using the given instructions. Warnings may be raised in case any of the versions are
@@ -12,23 +12,11 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
16
15
  import json
16
+ import warnings
17
17
  from pprint import pprint
18
18
  from time import sleep
19
-
20
- from mlrun_pipelines.common.mounts import VolumeMount
21
- from mlrun_pipelines.mounts import (
22
- auto_mount,
23
- mount_configmap,
24
- mount_hostpath,
25
- mount_pvc,
26
- mount_s3,
27
- mount_secret,
28
- mount_v3io,
29
- set_env_variables,
30
- v3io_cred,
31
- )
19
+ from typing import Optional
32
20
 
33
21
  from .iguazio import (
34
22
  V3ioStreamClient,
@@ -37,10 +25,53 @@ from .iguazio import (
37
25
  )
38
26
 
39
27
 
28
+ class _DeprecationHelper:
29
+ """A helper class to deprecate old schemas"""
30
+
31
+ def __init__(self, new_target: str, version="1.8.0"):
32
+ self._new_target = new_target
33
+ self._version = version
34
+
35
+ def __call__(self, *args, **kwargs):
36
+ self._warn()
37
+ return self._lazy_load()(*args, **kwargs)
38
+
39
+ def __getattr__(self, attr):
40
+ self._warn()
41
+ return getattr(self._lazy_load(), attr)
42
+
43
+ def _lazy_load(self, *args, **kwargs):
44
+ import mlrun.runtimes.mounts as mlrun_mounts
45
+
46
+ return getattr(mlrun_mounts, self._new_target)
47
+
48
+ def _warn(self):
49
+ warnings.warn(
50
+ f"mlrun.platforms.{self._new_target} is deprecated since version {self._version}, "
51
+ f"and will be removed in 1.10. Use mlrun.runtimes.mounts.{self._new_target} instead.",
52
+ FutureWarning,
53
+ )
54
+
55
+
56
+ # TODO: Remove in 1.10
57
+ # For backwards compatibility
58
+ VolumeMount = _DeprecationHelper("VolumeMount")
59
+ auto_mount = _DeprecationHelper("auto_mount")
60
+ mount_configmap = _DeprecationHelper("mount_configmap")
61
+ mount_hostpath = _DeprecationHelper("mount_hostpath")
62
+ mount_pvc = _DeprecationHelper("mount_pvc")
63
+ mount_s3 = _DeprecationHelper("mount_s3")
64
+ mount_secret = _DeprecationHelper("mount_secret")
65
+ mount_v3io = _DeprecationHelper("mount_v3io")
66
+ set_env_variables = _DeprecationHelper("set_env_variables")
67
+ v3io_cred = _DeprecationHelper("v3io_cred")
68
+ # eof 'For backwards compatibility'
69
+
70
+
40
71
  def watch_stream(
41
72
  url,
42
- shard_ids: list = None,
43
- seek_to: str = None,
73
+ shard_ids: Optional[list] = None,
74
+ seek_to: Optional[str] = None,
44
75
  interval=None,
45
76
  is_json=False,
46
77
  **kwargs,
@@ -15,6 +15,7 @@
15
15
  import json
16
16
  import os
17
17
  import urllib
18
+ from typing import Optional
18
19
  from urllib.parse import urlparse
19
20
 
20
21
  import requests
@@ -250,7 +251,9 @@ class KafkaOutputStream:
250
251
 
251
252
 
252
253
  class V3ioStreamClient:
253
- def __init__(self, url: str, shard_id: int = 0, seek_to: str = None, **kwargs):
254
+ def __init__(
255
+ self, url: str, shard_id: int = 0, seek_to: Optional[str] = None, **kwargs
256
+ ):
254
257
  endpoint, stream_path = parse_path(url)
255
258
  seek_options = ["EARLIEST", "LATEST", "TIME", "SEQUENCE"]
256
259
  seek_to = seek_to or "LATEST"
@@ -12,16 +12,16 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #
15
+ import typing
15
16
  import warnings
16
17
  from typing import Optional, Union
17
18
 
18
- import mlrun_pipelines.common.models
19
- import mlrun_pipelines.models
20
-
21
19
  import mlrun
22
20
  import mlrun.common.constants as mlrun_constants
23
21
  import mlrun.common.schemas.function
24
22
  import mlrun.common.schemas.workflow
23
+ import mlrun_pipelines.common.models
24
+ import mlrun_pipelines.models
25
25
  from mlrun.utils import hub_prefix
26
26
 
27
27
  from .pipelines import enrich_function_object, pipeline_context
@@ -59,25 +59,25 @@ def _get_engine_and_function(function, project=None):
59
59
 
60
60
  def run_function(
61
61
  function: Union[str, mlrun.runtimes.BaseRuntime],
62
- handler: str = None,
62
+ handler: Optional[Union[str, typing.Callable]] = None,
63
63
  name: str = "",
64
- params: dict = None,
65
- hyperparams: dict = None,
64
+ params: Optional[dict] = None,
65
+ hyperparams: Optional[dict] = None,
66
66
  hyper_param_options: mlrun.model.HyperParamOptions = None,
67
- inputs: dict = None,
68
- outputs: list[str] = None,
67
+ inputs: Optional[dict] = None,
68
+ outputs: Optional[list[str]] = None,
69
69
  workdir: str = "",
70
- labels: dict = None,
70
+ labels: Optional[dict] = None,
71
71
  base_task: mlrun.model.RunTemplate = None,
72
72
  watch: bool = True,
73
- local: bool = None,
74
- verbose: bool = None,
75
- selector: str = None,
73
+ local: Optional[bool] = None,
74
+ verbose: Optional[bool] = None,
75
+ selector: Optional[str] = None,
76
76
  project_object=None,
77
- auto_build: bool = None,
77
+ auto_build: Optional[bool] = None,
78
78
  schedule: Union[str, mlrun.common.schemas.ScheduleCronTrigger] = None,
79
- artifact_path: str = None,
80
- notifications: list[mlrun.model.Notification] = None,
79
+ artifact_path: Optional[str] = None,
80
+ notifications: Optional[list[mlrun.model.Notification]] = None,
81
81
  returns: Optional[list[Union[str, dict[str, str]]]] = None,
82
82
  builder_env: Optional[list] = None,
83
83
  reset_on_run: Optional[bool] = None,
@@ -255,19 +255,19 @@ class BuildStatus:
255
255
 
256
256
  def build_function(
257
257
  function: Union[str, mlrun.runtimes.BaseRuntime],
258
- with_mlrun: bool = None,
258
+ with_mlrun: Optional[bool] = None,
259
259
  skip_deployed: bool = False,
260
260
  image=None,
261
261
  base_image=None,
262
- commands: list = None,
262
+ commands: Optional[list] = None,
263
263
  secret_name=None,
264
- requirements: Union[str, list[str]] = None,
265
- requirements_file: str = None,
264
+ requirements: Optional[Union[str, list[str]]] = None,
265
+ requirements_file: Optional[str] = None,
266
266
  mlrun_version_specifier=None,
267
- builder_env: dict = None,
267
+ builder_env: Optional[dict] = None,
268
268
  project_object=None,
269
269
  overwrite_build_params: bool = False,
270
- extra_args: str = None,
270
+ extra_args: Optional[str] = None,
271
271
  force_build: bool = False,
272
272
  ) -> Union[BuildStatus, mlrun_pipelines.models.PipelineNodeWrapper]:
273
273
  """deploy ML function, build container with its dependencies
@@ -294,9 +294,9 @@ def build_function(
294
294
  :param force_build: Force building the image, even when no changes were made
295
295
  """
296
296
  if not overwrite_build_params:
297
- # TODO: change overwrite_build_params default to True in 1.8.0
297
+ # TODO: change overwrite_build_params default to True in 1.10.0
298
298
  warnings.warn(
299
- "The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.8.0.",
299
+ "The `overwrite_build_params` parameter default will change from 'False' to 'True' in 1.10.0.",
300
300
  mlrun.utils.OverwriteBuildParamsWarning,
301
301
  )
302
302
 
@@ -325,7 +325,7 @@ def build_function(
325
325
  skip_deployed=skip_deployed,
326
326
  )
327
327
  else:
328
- # TODO: remove filter once overwrite_build_params default is changed to True in 1.8.0
328
+ # TODO: remove filter once overwrite_build_params default is changed to True in 1.10.0
329
329
  with warnings.catch_warnings():
330
330
  warnings.simplefilter(
331
331
  "ignore", category=mlrun.utils.OverwriteBuildParamsWarning
@@ -371,13 +371,13 @@ class DeployStatus:
371
371
 
372
372
  def deploy_function(
373
373
  function: Union[str, mlrun.runtimes.BaseRuntime],
374
- models: list = None,
375
- env: dict = None,
376
- tag: str = None,
377
- verbose: bool = None,
378
- builder_env: dict = None,
374
+ models: Optional[list] = None,
375
+ env: Optional[dict] = None,
376
+ tag: Optional[str] = None,
377
+ verbose: Optional[bool] = None,
378
+ builder_env: Optional[dict] = None,
379
379
  project_object=None,
380
- mock: bool = None,
380
+ mock: Optional[bool] = None,
381
381
  ) -> Union[DeployStatus, mlrun_pipelines.models.PipelineNodeWrapper]:
382
382
  """deploy real-time (nuclio based) functions
383
383