mlrun 1.7.2rc3__py3-none-any.whl → 1.8.0rc1__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 (222) hide show
  1. mlrun/__init__.py +14 -12
  2. mlrun/__main__.py +3 -3
  3. mlrun/alerts/alert.py +19 -12
  4. mlrun/artifacts/__init__.py +0 -2
  5. mlrun/artifacts/base.py +34 -11
  6. mlrun/artifacts/dataset.py +16 -16
  7. mlrun/artifacts/manager.py +13 -13
  8. mlrun/artifacts/model.py +66 -53
  9. mlrun/common/constants.py +6 -0
  10. mlrun/common/formatters/__init__.py +1 -0
  11. mlrun/common/formatters/feature_set.py +1 -0
  12. mlrun/common/formatters/function.py +1 -0
  13. mlrun/common/formatters/model_endpoint.py +30 -0
  14. mlrun/common/formatters/pipeline.py +1 -2
  15. mlrun/common/model_monitoring/__init__.py +0 -3
  16. mlrun/common/model_monitoring/helpers.py +1 -1
  17. mlrun/common/runtimes/constants.py +1 -2
  18. mlrun/common/schemas/__init__.py +4 -2
  19. mlrun/common/schemas/artifact.py +0 -6
  20. mlrun/common/schemas/common.py +50 -0
  21. mlrun/common/schemas/model_monitoring/__init__.py +8 -1
  22. mlrun/common/schemas/model_monitoring/constants.py +62 -12
  23. mlrun/common/schemas/model_monitoring/model_endpoint_v2.py +149 -0
  24. mlrun/common/schemas/model_monitoring/model_endpoints.py +21 -5
  25. mlrun/common/schemas/partition.py +122 -0
  26. mlrun/config.py +43 -15
  27. mlrun/data_types/__init__.py +0 -2
  28. mlrun/data_types/data_types.py +0 -1
  29. mlrun/data_types/infer.py +3 -1
  30. mlrun/data_types/spark.py +4 -4
  31. mlrun/data_types/to_pandas.py +2 -11
  32. mlrun/datastore/__init__.py +0 -2
  33. mlrun/datastore/alibaba_oss.py +4 -1
  34. mlrun/datastore/azure_blob.py +4 -1
  35. mlrun/datastore/base.py +12 -4
  36. mlrun/datastore/datastore.py +9 -3
  37. mlrun/datastore/datastore_profile.py +1 -1
  38. mlrun/datastore/dbfs_store.py +4 -1
  39. mlrun/datastore/filestore.py +4 -1
  40. mlrun/datastore/google_cloud_storage.py +4 -1
  41. mlrun/datastore/hdfs.py +4 -1
  42. mlrun/datastore/inmem.py +4 -1
  43. mlrun/datastore/redis.py +4 -1
  44. mlrun/datastore/s3.py +4 -1
  45. mlrun/datastore/sources.py +51 -49
  46. mlrun/datastore/store_resources.py +0 -2
  47. mlrun/datastore/targets.py +22 -23
  48. mlrun/datastore/utils.py +2 -2
  49. mlrun/datastore/v3io.py +4 -1
  50. mlrun/datastore/wasbfs/fs.py +13 -12
  51. mlrun/db/base.py +126 -62
  52. mlrun/db/factory.py +3 -0
  53. mlrun/db/httpdb.py +767 -231
  54. mlrun/db/nopdb.py +126 -57
  55. mlrun/errors.py +2 -2
  56. mlrun/execution.py +55 -29
  57. mlrun/feature_store/__init__.py +0 -2
  58. mlrun/feature_store/api.py +40 -40
  59. mlrun/feature_store/common.py +9 -9
  60. mlrun/feature_store/feature_set.py +20 -18
  61. mlrun/feature_store/feature_vector.py +27 -24
  62. mlrun/feature_store/retrieval/base.py +14 -9
  63. mlrun/feature_store/retrieval/job.py +2 -1
  64. mlrun/feature_store/steps.py +2 -2
  65. mlrun/features.py +30 -13
  66. mlrun/frameworks/__init__.py +1 -2
  67. mlrun/frameworks/_common/__init__.py +1 -2
  68. mlrun/frameworks/_common/artifacts_library.py +2 -2
  69. mlrun/frameworks/_common/mlrun_interface.py +10 -6
  70. mlrun/frameworks/_common/model_handler.py +29 -27
  71. mlrun/frameworks/_common/producer.py +3 -1
  72. mlrun/frameworks/_dl_common/__init__.py +1 -2
  73. mlrun/frameworks/_dl_common/loggers/__init__.py +1 -2
  74. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +4 -4
  75. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +3 -3
  76. mlrun/frameworks/_ml_common/__init__.py +1 -2
  77. mlrun/frameworks/_ml_common/loggers/__init__.py +1 -2
  78. mlrun/frameworks/_ml_common/model_handler.py +21 -21
  79. mlrun/frameworks/_ml_common/plans/__init__.py +1 -2
  80. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +3 -1
  81. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  82. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  83. mlrun/frameworks/auto_mlrun/__init__.py +1 -2
  84. mlrun/frameworks/auto_mlrun/auto_mlrun.py +22 -15
  85. mlrun/frameworks/huggingface/__init__.py +1 -2
  86. mlrun/frameworks/huggingface/model_server.py +9 -9
  87. mlrun/frameworks/lgbm/__init__.py +47 -44
  88. mlrun/frameworks/lgbm/callbacks/__init__.py +1 -2
  89. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -2
  90. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -2
  91. mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -2
  92. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +5 -5
  93. mlrun/frameworks/lgbm/model_handler.py +15 -11
  94. mlrun/frameworks/lgbm/model_server.py +11 -7
  95. mlrun/frameworks/lgbm/utils.py +2 -2
  96. mlrun/frameworks/onnx/__init__.py +1 -2
  97. mlrun/frameworks/onnx/dataset.py +3 -3
  98. mlrun/frameworks/onnx/mlrun_interface.py +2 -2
  99. mlrun/frameworks/onnx/model_handler.py +7 -5
  100. mlrun/frameworks/onnx/model_server.py +8 -6
  101. mlrun/frameworks/parallel_coordinates.py +11 -11
  102. mlrun/frameworks/pytorch/__init__.py +22 -23
  103. mlrun/frameworks/pytorch/callbacks/__init__.py +1 -2
  104. mlrun/frameworks/pytorch/callbacks/callback.py +2 -1
  105. mlrun/frameworks/pytorch/callbacks/logging_callback.py +15 -8
  106. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +19 -12
  107. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +22 -15
  108. mlrun/frameworks/pytorch/callbacks_handler.py +36 -30
  109. mlrun/frameworks/pytorch/mlrun_interface.py +17 -17
  110. mlrun/frameworks/pytorch/model_handler.py +21 -17
  111. mlrun/frameworks/pytorch/model_server.py +13 -9
  112. mlrun/frameworks/sklearn/__init__.py +19 -18
  113. mlrun/frameworks/sklearn/estimator.py +2 -2
  114. mlrun/frameworks/sklearn/metric.py +3 -3
  115. mlrun/frameworks/sklearn/metrics_library.py +8 -6
  116. mlrun/frameworks/sklearn/mlrun_interface.py +3 -2
  117. mlrun/frameworks/sklearn/model_handler.py +4 -3
  118. mlrun/frameworks/tf_keras/__init__.py +11 -12
  119. mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -2
  120. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +17 -14
  121. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +15 -12
  122. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +21 -18
  123. mlrun/frameworks/tf_keras/model_handler.py +17 -13
  124. mlrun/frameworks/tf_keras/model_server.py +12 -8
  125. mlrun/frameworks/xgboost/__init__.py +19 -18
  126. mlrun/frameworks/xgboost/model_handler.py +13 -9
  127. mlrun/launcher/base.py +3 -4
  128. mlrun/launcher/local.py +1 -1
  129. mlrun/launcher/remote.py +1 -1
  130. mlrun/lists.py +4 -3
  131. mlrun/model.py +108 -44
  132. mlrun/model_monitoring/__init__.py +1 -2
  133. mlrun/model_monitoring/api.py +6 -6
  134. mlrun/model_monitoring/applications/_application_steps.py +13 -15
  135. mlrun/model_monitoring/applications/histogram_data_drift.py +41 -15
  136. mlrun/model_monitoring/applications/results.py +55 -3
  137. mlrun/model_monitoring/controller.py +185 -223
  138. mlrun/model_monitoring/db/_schedules.py +156 -0
  139. mlrun/model_monitoring/db/_stats.py +189 -0
  140. mlrun/model_monitoring/db/stores/__init__.py +1 -1
  141. mlrun/model_monitoring/db/stores/base/store.py +6 -65
  142. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -25
  143. mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -97
  144. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +2 -58
  145. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -15
  146. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +6 -257
  147. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +9 -271
  148. mlrun/model_monitoring/db/tsdb/base.py +74 -22
  149. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +66 -35
  150. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
  151. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +284 -51
  152. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
  153. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +35 -17
  154. mlrun/model_monitoring/helpers.py +97 -1
  155. mlrun/model_monitoring/model_endpoint.py +4 -2
  156. mlrun/model_monitoring/stream_processing.py +2 -2
  157. mlrun/model_monitoring/tracking_policy.py +10 -3
  158. mlrun/model_monitoring/writer.py +47 -26
  159. mlrun/package/__init__.py +3 -6
  160. mlrun/package/context_handler.py +1 -1
  161. mlrun/package/packager.py +12 -9
  162. mlrun/package/packagers/__init__.py +0 -2
  163. mlrun/package/packagers/default_packager.py +14 -11
  164. mlrun/package/packagers/numpy_packagers.py +16 -7
  165. mlrun/package/packagers/pandas_packagers.py +18 -18
  166. mlrun/package/packagers/python_standard_library_packagers.py +25 -11
  167. mlrun/package/packagers_manager.py +31 -14
  168. mlrun/package/utils/__init__.py +0 -3
  169. mlrun/package/utils/_pickler.py +6 -6
  170. mlrun/platforms/__init__.py +3 -3
  171. mlrun/platforms/iguazio.py +4 -1
  172. mlrun/projects/__init__.py +1 -6
  173. mlrun/projects/operations.py +27 -27
  174. mlrun/projects/pipelines.py +85 -215
  175. mlrun/projects/project.py +444 -158
  176. mlrun/run.py +9 -9
  177. mlrun/runtimes/__init__.py +1 -3
  178. mlrun/runtimes/base.py +13 -10
  179. mlrun/runtimes/daskjob.py +9 -9
  180. mlrun/runtimes/generators.py +2 -1
  181. mlrun/runtimes/kubejob.py +4 -5
  182. mlrun/runtimes/mpijob/__init__.py +0 -2
  183. mlrun/runtimes/mpijob/abstract.py +7 -6
  184. mlrun/runtimes/nuclio/api_gateway.py +7 -7
  185. mlrun/runtimes/nuclio/application/application.py +11 -11
  186. mlrun/runtimes/nuclio/function.py +14 -13
  187. mlrun/runtimes/nuclio/serving.py +9 -9
  188. mlrun/runtimes/pod.py +74 -29
  189. mlrun/runtimes/remotesparkjob.py +3 -2
  190. mlrun/runtimes/sparkjob/__init__.py +0 -2
  191. mlrun/runtimes/sparkjob/spark3job.py +21 -11
  192. mlrun/runtimes/utils.py +6 -5
  193. mlrun/serving/merger.py +6 -4
  194. mlrun/serving/remote.py +18 -17
  195. mlrun/serving/routers.py +27 -27
  196. mlrun/serving/server.py +1 -1
  197. mlrun/serving/states.py +76 -71
  198. mlrun/serving/utils.py +13 -2
  199. mlrun/serving/v1_serving.py +3 -2
  200. mlrun/serving/v2_serving.py +4 -4
  201. mlrun/track/__init__.py +1 -1
  202. mlrun/track/tracker.py +2 -2
  203. mlrun/track/trackers/mlflow_tracker.py +6 -5
  204. mlrun/utils/async_http.py +1 -1
  205. mlrun/utils/helpers.py +72 -28
  206. mlrun/utils/logger.py +104 -2
  207. mlrun/utils/notifications/notification/base.py +23 -4
  208. mlrun/utils/notifications/notification/console.py +1 -1
  209. mlrun/utils/notifications/notification/git.py +6 -6
  210. mlrun/utils/notifications/notification/ipython.py +5 -4
  211. mlrun/utils/notifications/notification/slack.py +1 -1
  212. mlrun/utils/notifications/notification/webhook.py +13 -17
  213. mlrun/utils/notifications/notification_pusher.py +23 -19
  214. mlrun/utils/regex.py +1 -1
  215. mlrun/utils/version/version.json +2 -2
  216. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc1.dist-info}/METADATA +186 -186
  217. mlrun-1.8.0rc1.dist-info/RECORD +356 -0
  218. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc1.dist-info}/WHEEL +1 -1
  219. mlrun-1.7.2rc3.dist-info/RECORD +0 -351
  220. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc1.dist-info}/LICENSE +0 -0
  221. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc1.dist-info}/entry_points.txt +0 -0
  222. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc1.dist-info}/top_level.txt +0 -0
@@ -17,7 +17,7 @@ import os
17
17
  import pathlib
18
18
  import tempfile
19
19
  from abc import ABC, abstractmethod
20
- from typing import Any, Union
20
+ from typing import Any, Optional, Union
21
21
 
22
22
  import pandas as pd
23
23
 
@@ -56,7 +56,7 @@ class _Formatter(ABC):
56
56
  @classmethod
57
57
  @abstractmethod
58
58
  def read(
59
- cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
59
+ cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
60
60
  ) -> pd.DataFrame:
61
61
  """
62
62
  Read the dataframe from the given file path.
@@ -173,7 +173,7 @@ class _ParquetFormatter(_Formatter):
173
173
 
174
174
  @classmethod
175
175
  def read(
176
- cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
176
+ cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
177
177
  ) -> pd.DataFrame:
178
178
  """
179
179
  Read the dataframe from the given parquet file path.
@@ -221,7 +221,7 @@ class _CSVFormatter(_Formatter):
221
221
 
222
222
  @classmethod
223
223
  def read(
224
- cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
224
+ cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
225
225
  ) -> pd.DataFrame:
226
226
  """
227
227
  Read the dataframe from the given csv file path.
@@ -275,7 +275,7 @@ class _H5Formatter(_Formatter):
275
275
 
276
276
  @classmethod
277
277
  def read(
278
- cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
278
+ cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
279
279
  ) -> pd.DataFrame:
280
280
  """
281
281
  Read the dataframe from the given h5 file path.
@@ -332,7 +332,7 @@ class _XMLFormatter(_Formatter):
332
332
 
333
333
  @classmethod
334
334
  def read(
335
- cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
335
+ cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
336
336
  ) -> pd.DataFrame:
337
337
  """
338
338
  Read the dataframe from the given xml file path.
@@ -391,7 +391,7 @@ class _XLSXFormatter(_Formatter):
391
391
 
392
392
  @classmethod
393
393
  def read(
394
- cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
394
+ cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
395
395
  ) -> pd.DataFrame:
396
396
  """
397
397
  Read the dataframe from the given xlsx file path.
@@ -449,7 +449,7 @@ class _HTMLFormatter(_Formatter):
449
449
 
450
450
  @classmethod
451
451
  def read(
452
- cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
452
+ cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
453
453
  ) -> pd.DataFrame:
454
454
  """
455
455
  Read dataframes from the given html file path.
@@ -510,7 +510,7 @@ class _JSONFormatter(_Formatter):
510
510
 
511
511
  @classmethod
512
512
  def read(
513
- cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
513
+ cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
514
514
  ) -> pd.DataFrame:
515
515
  """
516
516
  Read dataframes from the given json file path.
@@ -565,7 +565,7 @@ class _FeatherFormatter(_Formatter):
565
565
 
566
566
  @classmethod
567
567
  def read(
568
- cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
568
+ cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
569
569
  ) -> pd.DataFrame:
570
570
  """
571
571
  Read dataframes from the given feather file path.
@@ -620,7 +620,7 @@ class _ORCFormatter(_Formatter):
620
620
 
621
621
  @classmethod
622
622
  def read(
623
- cls, file_path: str, unflatten_kwargs: dict = None, **read_kwargs
623
+ cls, file_path: str, unflatten_kwargs: Optional[dict] = None, **read_kwargs
624
624
  ) -> pd.DataFrame:
625
625
  """
626
626
  Read dataframes from the given orc file path.
@@ -730,7 +730,7 @@ class PandasDataFramePackager(DefaultPackager):
730
730
  self,
731
731
  obj: pd.DataFrame,
732
732
  key: str,
733
- file_format: str = None,
733
+ file_format: Optional[str] = None,
734
734
  flatten: bool = True,
735
735
  **to_kwargs,
736
736
  ) -> tuple[Artifact, dict]:
@@ -785,8 +785,8 @@ class PandasDataFramePackager(DefaultPackager):
785
785
  def unpack_file(
786
786
  self,
787
787
  data_item: DataItem,
788
- file_format: str = None,
789
- read_kwargs: dict = None,
788
+ file_format: Optional[str] = None,
789
+ read_kwargs: Optional[dict] = None,
790
790
  ) -> pd.DataFrame:
791
791
  """
792
792
  Unpack a pandas dataframe from file.
@@ -883,7 +883,7 @@ class PandasSeriesPackager(PandasDataFramePackager):
883
883
  self,
884
884
  obj: pd.Series,
885
885
  key: str,
886
- file_format: str = None,
886
+ file_format: Optional[str] = None,
887
887
  flatten: bool = True,
888
888
  **to_kwargs,
889
889
  ) -> tuple[Artifact, dict]:
@@ -919,9 +919,9 @@ class PandasSeriesPackager(PandasDataFramePackager):
919
919
  def unpack_file(
920
920
  self,
921
921
  data_item: DataItem,
922
- file_format: str = None,
923
- read_kwargs: dict = None,
924
- column_name: Union[str, int] = None,
922
+ file_format: Optional[str] = None,
923
+ read_kwargs: Optional[dict] = None,
924
+ column_name: Optional[Union[str, int]] = None,
925
925
  ) -> pd.Series:
926
926
  """
927
927
  Unpack a pandas series from file.
@@ -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.
@@ -715,17 +718,31 @@ class PackagersManager:
715
718
  def _look_for_extra_data(
716
719
  key: str,
717
720
  artifacts: list[Artifact],
721
+ artifact_uris: dict,
718
722
  results: dict,
719
723
  ) -> Union[Artifact, str, int, float, None]:
720
724
  """
721
725
  Look for an extra data item (artifact or result) by given key. If not found, None is returned.
722
726
 
723
- :param key: Key to look for.
724
- :param artifacts: Artifacts to look in.
725
- :param results: Results to look in.
727
+ :param key: Key to look for.
728
+ :param artifacts: Artifacts to look in.
729
+ :param artifact_uris: Artifacts URIs to look in.
730
+ :param results: Results to look in.
726
731
 
727
732
  :return: The artifact or result with the same key or None if not found.
728
733
  """
734
+ artifact_uris = artifact_uris or {}
735
+ for _key, uri in artifact_uris.items():
736
+ if key == _key:
737
+ try:
738
+ return get_store_resource(uri)
739
+ except mlrun.errors.MLRunNotFoundError as exc:
740
+ logger.warn(
741
+ f"Artifact {key=} not found when looking for extra data",
742
+ exc=mlrun.errors.err_to_str(exc),
743
+ )
744
+ return None
745
+
729
746
  # Look in the artifacts:
730
747
  for artifact in artifacts:
731
748
  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,10 +12,10 @@
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
17
16
  from pprint import pprint
18
17
  from time import sleep
18
+ from typing import Optional
19
19
 
20
20
  from mlrun_pipelines.common.mounts import VolumeMount
21
21
  from mlrun_pipelines.mounts import (
@@ -39,8 +39,8 @@ from .iguazio import (
39
39
 
40
40
  def watch_stream(
41
41
  url,
42
- shard_ids: list = None,
43
- seek_to: str = None,
42
+ shard_ids: Optional[list] = None,
43
+ seek_to: Optional[str] = None,
44
44
  interval=None,
45
45
  is_json=False,
46
46
  **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"
@@ -27,12 +27,7 @@ __all__ = [
27
27
  ]
28
28
 
29
29
  from .operations import build_function, deploy_function, run_function # noqa
30
- from .pipelines import (
31
- import_remote_project,
32
- load_and_run_workflow,
33
- load_and_run,
34
- pipeline_context,
35
- ) # noqa
30
+ from .pipelines import load_and_run, pipeline_context # noqa
36
31
  from .project import (
37
32
  MlrunProject,
38
33
  ProjectMetadata,
@@ -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
@@ -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