mlrun 1.6.0rc35__py3-none-any.whl → 1.7.0rc2__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 (199) hide show
  1. mlrun/__main__.py +3 -3
  2. mlrun/api/schemas/__init__.py +1 -1
  3. mlrun/artifacts/base.py +11 -6
  4. mlrun/artifacts/dataset.py +2 -2
  5. mlrun/artifacts/model.py +30 -24
  6. mlrun/artifacts/plots.py +2 -2
  7. mlrun/common/db/sql_session.py +5 -3
  8. mlrun/common/helpers.py +1 -2
  9. mlrun/common/schemas/artifact.py +3 -3
  10. mlrun/common/schemas/auth.py +3 -3
  11. mlrun/common/schemas/background_task.py +1 -1
  12. mlrun/common/schemas/client_spec.py +1 -1
  13. mlrun/common/schemas/feature_store.py +16 -16
  14. mlrun/common/schemas/frontend_spec.py +7 -7
  15. mlrun/common/schemas/function.py +1 -1
  16. mlrun/common/schemas/hub.py +4 -9
  17. mlrun/common/schemas/memory_reports.py +2 -2
  18. mlrun/common/schemas/model_monitoring/grafana.py +4 -4
  19. mlrun/common/schemas/model_monitoring/model_endpoints.py +14 -15
  20. mlrun/common/schemas/notification.py +4 -4
  21. mlrun/common/schemas/object.py +2 -2
  22. mlrun/common/schemas/pipeline.py +1 -1
  23. mlrun/common/schemas/project.py +3 -3
  24. mlrun/common/schemas/runtime_resource.py +8 -12
  25. mlrun/common/schemas/schedule.py +3 -3
  26. mlrun/common/schemas/tag.py +1 -2
  27. mlrun/common/schemas/workflow.py +2 -2
  28. mlrun/config.py +8 -4
  29. mlrun/data_types/to_pandas.py +1 -3
  30. mlrun/datastore/base.py +0 -28
  31. mlrun/datastore/datastore_profile.py +9 -9
  32. mlrun/datastore/filestore.py +0 -1
  33. mlrun/datastore/google_cloud_storage.py +1 -1
  34. mlrun/datastore/sources.py +7 -11
  35. mlrun/datastore/spark_utils.py +1 -2
  36. mlrun/datastore/targets.py +31 -31
  37. mlrun/datastore/utils.py +4 -6
  38. mlrun/datastore/v3io.py +70 -46
  39. mlrun/db/base.py +22 -23
  40. mlrun/db/httpdb.py +34 -34
  41. mlrun/db/nopdb.py +19 -19
  42. mlrun/errors.py +1 -1
  43. mlrun/execution.py +4 -4
  44. mlrun/feature_store/api.py +20 -21
  45. mlrun/feature_store/common.py +1 -1
  46. mlrun/feature_store/feature_set.py +28 -32
  47. mlrun/feature_store/feature_vector.py +24 -27
  48. mlrun/feature_store/retrieval/base.py +7 -7
  49. mlrun/feature_store/retrieval/conversion.py +2 -4
  50. mlrun/feature_store/steps.py +7 -15
  51. mlrun/features.py +5 -7
  52. mlrun/frameworks/_common/artifacts_library.py +9 -9
  53. mlrun/frameworks/_common/mlrun_interface.py +5 -5
  54. mlrun/frameworks/_common/model_handler.py +48 -48
  55. mlrun/frameworks/_common/plan.py +2 -3
  56. mlrun/frameworks/_common/producer.py +3 -4
  57. mlrun/frameworks/_common/utils.py +5 -5
  58. mlrun/frameworks/_dl_common/loggers/logger.py +6 -7
  59. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +9 -9
  60. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +16 -35
  61. mlrun/frameworks/_ml_common/artifacts_library.py +1 -2
  62. mlrun/frameworks/_ml_common/loggers/logger.py +3 -4
  63. mlrun/frameworks/_ml_common/loggers/mlrun_logger.py +4 -5
  64. mlrun/frameworks/_ml_common/model_handler.py +24 -24
  65. mlrun/frameworks/_ml_common/pkl_model_server.py +2 -2
  66. mlrun/frameworks/_ml_common/plan.py +1 -1
  67. mlrun/frameworks/_ml_common/plans/calibration_curve_plan.py +2 -3
  68. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +2 -3
  69. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  70. mlrun/frameworks/_ml_common/plans/feature_importance_plan.py +3 -3
  71. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  72. mlrun/frameworks/_ml_common/utils.py +4 -4
  73. mlrun/frameworks/auto_mlrun/auto_mlrun.py +7 -7
  74. mlrun/frameworks/huggingface/model_server.py +4 -4
  75. mlrun/frameworks/lgbm/__init__.py +32 -32
  76. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -5
  77. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -5
  78. mlrun/frameworks/lgbm/mlrun_interfaces/booster_mlrun_interface.py +1 -3
  79. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +6 -6
  80. mlrun/frameworks/lgbm/model_handler.py +9 -9
  81. mlrun/frameworks/lgbm/model_server.py +6 -6
  82. mlrun/frameworks/lgbm/utils.py +5 -5
  83. mlrun/frameworks/onnx/dataset.py +8 -8
  84. mlrun/frameworks/onnx/mlrun_interface.py +3 -3
  85. mlrun/frameworks/onnx/model_handler.py +6 -6
  86. mlrun/frameworks/onnx/model_server.py +7 -7
  87. mlrun/frameworks/parallel_coordinates.py +2 -2
  88. mlrun/frameworks/pytorch/__init__.py +16 -16
  89. mlrun/frameworks/pytorch/callbacks/callback.py +4 -5
  90. mlrun/frameworks/pytorch/callbacks/logging_callback.py +17 -17
  91. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +11 -11
  92. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +23 -29
  93. mlrun/frameworks/pytorch/callbacks_handler.py +38 -38
  94. mlrun/frameworks/pytorch/mlrun_interface.py +20 -20
  95. mlrun/frameworks/pytorch/model_handler.py +17 -17
  96. mlrun/frameworks/pytorch/model_server.py +7 -7
  97. mlrun/frameworks/sklearn/__init__.py +12 -12
  98. mlrun/frameworks/sklearn/estimator.py +4 -4
  99. mlrun/frameworks/sklearn/metrics_library.py +14 -14
  100. mlrun/frameworks/sklearn/mlrun_interface.py +3 -6
  101. mlrun/frameworks/sklearn/model_handler.py +2 -2
  102. mlrun/frameworks/tf_keras/__init__.py +5 -5
  103. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +14 -14
  104. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +11 -11
  105. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +19 -23
  106. mlrun/frameworks/tf_keras/mlrun_interface.py +7 -9
  107. mlrun/frameworks/tf_keras/model_handler.py +14 -14
  108. mlrun/frameworks/tf_keras/model_server.py +6 -6
  109. mlrun/frameworks/xgboost/__init__.py +12 -12
  110. mlrun/frameworks/xgboost/model_handler.py +6 -6
  111. mlrun/k8s_utils.py +4 -5
  112. mlrun/kfpops.py +2 -2
  113. mlrun/launcher/base.py +10 -10
  114. mlrun/launcher/local.py +8 -8
  115. mlrun/launcher/remote.py +7 -7
  116. mlrun/lists.py +3 -4
  117. mlrun/model.py +205 -55
  118. mlrun/model_monitoring/api.py +21 -24
  119. mlrun/model_monitoring/application.py +4 -4
  120. mlrun/model_monitoring/batch.py +17 -17
  121. mlrun/model_monitoring/controller.py +2 -1
  122. mlrun/model_monitoring/features_drift_table.py +44 -31
  123. mlrun/model_monitoring/prometheus.py +1 -4
  124. mlrun/model_monitoring/stores/kv_model_endpoint_store.py +11 -13
  125. mlrun/model_monitoring/stores/model_endpoint_store.py +9 -11
  126. mlrun/model_monitoring/stores/models/__init__.py +2 -2
  127. mlrun/model_monitoring/stores/sql_model_endpoint_store.py +11 -13
  128. mlrun/model_monitoring/stream_processing.py +16 -34
  129. mlrun/model_monitoring/tracking_policy.py +2 -1
  130. mlrun/package/__init__.py +6 -6
  131. mlrun/package/context_handler.py +5 -5
  132. mlrun/package/packager.py +7 -7
  133. mlrun/package/packagers/default_packager.py +6 -6
  134. mlrun/package/packagers/numpy_packagers.py +15 -15
  135. mlrun/package/packagers/pandas_packagers.py +5 -5
  136. mlrun/package/packagers/python_standard_library_packagers.py +10 -10
  137. mlrun/package/packagers_manager.py +18 -23
  138. mlrun/package/utils/_formatter.py +4 -4
  139. mlrun/package/utils/_pickler.py +2 -2
  140. mlrun/package/utils/_supported_format.py +4 -4
  141. mlrun/package/utils/log_hint_utils.py +2 -2
  142. mlrun/package/utils/type_hint_utils.py +4 -9
  143. mlrun/platforms/other.py +1 -2
  144. mlrun/projects/operations.py +5 -5
  145. mlrun/projects/pipelines.py +9 -9
  146. mlrun/projects/project.py +58 -46
  147. mlrun/render.py +1 -1
  148. mlrun/run.py +9 -9
  149. mlrun/runtimes/__init__.py +7 -4
  150. mlrun/runtimes/base.py +20 -23
  151. mlrun/runtimes/constants.py +5 -5
  152. mlrun/runtimes/daskjob.py +8 -8
  153. mlrun/runtimes/databricks_job/databricks_cancel_task.py +1 -1
  154. mlrun/runtimes/databricks_job/databricks_runtime.py +7 -7
  155. mlrun/runtimes/function_reference.py +1 -1
  156. mlrun/runtimes/local.py +1 -1
  157. mlrun/runtimes/mpijob/abstract.py +1 -2
  158. mlrun/runtimes/nuclio/__init__.py +20 -0
  159. mlrun/runtimes/{function.py → nuclio/function.py} +15 -16
  160. mlrun/runtimes/{nuclio.py → nuclio/nuclio.py} +6 -6
  161. mlrun/runtimes/{serving.py → nuclio/serving.py} +13 -12
  162. mlrun/runtimes/pod.py +95 -48
  163. mlrun/runtimes/remotesparkjob.py +1 -1
  164. mlrun/runtimes/sparkjob/spark3job.py +50 -33
  165. mlrun/runtimes/utils.py +1 -2
  166. mlrun/secrets.py +3 -3
  167. mlrun/serving/remote.py +0 -4
  168. mlrun/serving/routers.py +6 -6
  169. mlrun/serving/server.py +4 -4
  170. mlrun/serving/states.py +29 -0
  171. mlrun/serving/utils.py +3 -3
  172. mlrun/serving/v1_serving.py +6 -7
  173. mlrun/serving/v2_serving.py +50 -8
  174. mlrun/track/tracker_manager.py +3 -3
  175. mlrun/track/trackers/mlflow_tracker.py +1 -2
  176. mlrun/utils/async_http.py +5 -7
  177. mlrun/utils/azure_vault.py +1 -1
  178. mlrun/utils/clones.py +1 -2
  179. mlrun/utils/condition_evaluator.py +3 -3
  180. mlrun/utils/db.py +3 -3
  181. mlrun/utils/helpers.py +37 -119
  182. mlrun/utils/http.py +1 -4
  183. mlrun/utils/logger.py +49 -14
  184. mlrun/utils/notifications/notification/__init__.py +3 -3
  185. mlrun/utils/notifications/notification/base.py +2 -2
  186. mlrun/utils/notifications/notification/ipython.py +1 -1
  187. mlrun/utils/notifications/notification_pusher.py +8 -14
  188. mlrun/utils/retryer.py +207 -0
  189. mlrun/utils/singleton.py +1 -1
  190. mlrun/utils/v3io_clients.py +2 -3
  191. mlrun/utils/version/version.json +2 -2
  192. mlrun/utils/version/version.py +2 -6
  193. {mlrun-1.6.0rc35.dist-info → mlrun-1.7.0rc2.dist-info}/METADATA +9 -9
  194. mlrun-1.7.0rc2.dist-info/RECORD +315 -0
  195. mlrun-1.6.0rc35.dist-info/RECORD +0 -313
  196. {mlrun-1.6.0rc35.dist-info → mlrun-1.7.0rc2.dist-info}/LICENSE +0 -0
  197. {mlrun-1.6.0rc35.dist-info → mlrun-1.7.0rc2.dist-info}/WHEEL +0 -0
  198. {mlrun-1.6.0rc35.dist-info → mlrun-1.7.0rc2.dist-info}/entry_points.txt +0 -0
  199. {mlrun-1.6.0rc35.dist-info → mlrun-1.7.0rc2.dist-info}/top_level.txt +0 -0
@@ -20,7 +20,7 @@ import sys
20
20
  import zipfile
21
21
  from abc import ABC, abstractmethod
22
22
  from types import MethodType
23
- from typing import Any, Dict, Generic, List, Type, Union
23
+ from typing import Any, Generic, Union
24
24
 
25
25
  import numpy as np
26
26
 
@@ -57,10 +57,10 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
57
57
  model_path: CommonTypes.PathType = None,
58
58
  model_name: str = None,
59
59
  modules_map: Union[
60
- Dict[str, Union[None, str, List[str]]], CommonTypes.PathType
60
+ dict[str, Union[None, str, list[str]]], CommonTypes.PathType
61
61
  ] = None,
62
62
  custom_objects_map: Union[
63
- Dict[str, Union[str, List[str]]], CommonTypes.PathType
63
+ dict[str, Union[str, list[str]]], CommonTypes.PathType
64
64
  ] = None,
65
65
  custom_objects_directory: CommonTypes.PathType = None,
66
66
  context: MLClientCtx = None,
@@ -224,7 +224,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
224
224
  return self._tag
225
225
 
226
226
  @property
227
- def inputs(self) -> Union[List[Feature], None]:
227
+ def inputs(self) -> Union[list[Feature], None]:
228
228
  """
229
229
  Get the input ports features list of this model's artifact. If the inputs are not set, None will be returned.
230
230
 
@@ -233,7 +233,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
233
233
  return self._inputs
234
234
 
235
235
  @property
236
- def outputs(self) -> Union[List[Feature], None]:
236
+ def outputs(self) -> Union[list[Feature], None]:
237
237
  """
238
238
  Get the output ports features list of this model's artifact. If the outputs are not set, None will be returned.
239
239
 
@@ -242,7 +242,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
242
242
  return self._outputs
243
243
 
244
244
  @property
245
- def labels(self) -> Dict[str, str]:
245
+ def labels(self) -> dict[str, str]:
246
246
  """
247
247
  Get the labels dictionary of this model's artifact. These will be the labels that will be logged with the model.
248
248
 
@@ -251,7 +251,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
251
251
  return self._labels
252
252
 
253
253
  @property
254
- def parameters(self) -> Dict[str, str]:
254
+ def parameters(self) -> dict[str, str]:
255
255
  """
256
256
  Get the parameters dictionary of this model's artifact. These will be the parameters that will be logged with
257
257
  the model.
@@ -262,7 +262,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
262
262
 
263
263
  def get_artifacts(
264
264
  self, committed_only: bool = False
265
- ) -> Dict[str, CommonTypes.ExtraDataType]:
265
+ ) -> dict[str, CommonTypes.ExtraDataType]:
266
266
  """
267
267
  Get the registered artifacts of this model's artifact. By default all the artifacts (logged and to be logged -
268
268
  committed only) will be returned. To get only the artifacts registered in the current run whom are committed and
@@ -306,7 +306,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
306
306
  def set_inputs(
307
307
  self,
308
308
  from_sample: CommonTypes.IOSampleType = None,
309
- features: List[Feature] = None,
309
+ features: list[Feature] = None,
310
310
  **kwargs,
311
311
  ):
312
312
  """
@@ -335,7 +335,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
335
335
  def set_outputs(
336
336
  self,
337
337
  from_sample: CommonTypes.IOSampleType = None,
338
- features: List[Feature] = None,
338
+ features: list[Feature] = None,
339
339
  **kwargs,
340
340
  ):
341
341
  """
@@ -363,8 +363,8 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
363
363
 
364
364
  def set_labels(
365
365
  self,
366
- to_add: Dict[str, Union[str, int, float]] = None,
367
- to_remove: List[str] = None,
366
+ to_add: dict[str, Union[str, int, float]] = None,
367
+ to_remove: list[str] = None,
368
368
  ):
369
369
  """
370
370
  Update the labels dictionary of this model artifact.
@@ -383,8 +383,8 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
383
383
 
384
384
  def set_parameters(
385
385
  self,
386
- to_add: Dict[str, Union[str, int, float]] = None,
387
- to_remove: List[str] = None,
386
+ to_add: dict[str, Union[str, int, float]] = None,
387
+ to_remove: list[str] = None,
388
388
  ):
389
389
  """
390
390
  Update the parameters dictionary of this model artifact.
@@ -403,8 +403,8 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
403
403
 
404
404
  def set_metrics(
405
405
  self,
406
- to_add: Dict[str, CommonTypes.ExtraDataType] = None,
407
- to_remove: List[str] = None,
406
+ to_add: dict[str, CommonTypes.ExtraDataType] = None,
407
+ to_remove: list[str] = None,
408
408
  ):
409
409
  """
410
410
  Update the metrics dictionary of this model artifact.
@@ -423,8 +423,8 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
423
423
 
424
424
  def set_extra_data(
425
425
  self,
426
- to_add: Dict[str, CommonTypes.ExtraDataType] = None,
427
- to_remove: List[str] = None,
426
+ to_add: dict[str, CommonTypes.ExtraDataType] = None,
427
+ to_remove: list[str] = None,
428
428
  ):
429
429
  """
430
430
  Update the extra data dictionary of this model artifact.
@@ -442,7 +442,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
442
442
  self._extra_data.pop(label)
443
443
 
444
444
  def register_artifacts(
445
- self, artifacts: Union[Artifact, List[Artifact], Dict[str, Artifact]]
445
+ self, artifacts: Union[Artifact, list[Artifact], dict[str, Artifact]]
446
446
  ):
447
447
  """
448
448
  Register the given artifacts, so they will be logged as extra data with the model of this handler. Notice: The
@@ -466,7 +466,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
466
466
  @abstractmethod
467
467
  def save(
468
468
  self, output_path: CommonTypes.PathType = None, **kwargs
469
- ) -> Union[Dict[str, Artifact], None]:
469
+ ) -> Union[dict[str, Artifact], None]:
470
470
  """
471
471
  Save the handled model at the given output path.
472
472
 
@@ -525,13 +525,13 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
525
525
  def log(
526
526
  self,
527
527
  tag: str = "",
528
- labels: Dict[str, Union[str, int, float]] = None,
529
- parameters: Dict[str, Union[str, int, float]] = None,
530
- inputs: List[Feature] = None,
531
- outputs: List[Feature] = None,
532
- metrics: Dict[str, Union[int, float]] = None,
533
- artifacts: Dict[str, Artifact] = None,
534
- extra_data: Dict[str, CommonTypes.ExtraDataType] = None,
528
+ labels: dict[str, Union[str, int, float]] = None,
529
+ parameters: dict[str, Union[str, int, float]] = None,
530
+ inputs: list[Feature] = None,
531
+ outputs: list[Feature] = None,
532
+ metrics: dict[str, Union[int, float]] = None,
533
+ artifacts: dict[str, Artifact] = None,
534
+ extra_data: dict[str, CommonTypes.ExtraDataType] = None,
535
535
  **kwargs,
536
536
  ):
537
537
  """
@@ -630,13 +630,13 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
630
630
 
631
631
  def update(
632
632
  self,
633
- labels: Dict[str, Union[str, int, float]] = None,
634
- parameters: Dict[str, Union[str, int, float]] = None,
635
- inputs: List[Feature] = None,
636
- outputs: List[Feature] = None,
637
- metrics: Dict[str, Union[int, float]] = None,
638
- artifacts: Dict[str, Artifact] = None,
639
- extra_data: Dict[str, CommonTypes.ExtraDataType] = None,
633
+ labels: dict[str, Union[str, int, float]] = None,
634
+ parameters: dict[str, Union[str, int, float]] = None,
635
+ inputs: list[Feature] = None,
636
+ outputs: list[Feature] = None,
637
+ metrics: dict[str, Union[int, float]] = None,
638
+ artifacts: dict[str, Artifact] = None,
639
+ extra_data: dict[str, CommonTypes.ExtraDataType] = None,
640
640
  **kwargs,
641
641
  ):
642
642
  """
@@ -857,7 +857,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
857
857
 
858
858
  # Read the modules map if given as a json:
859
859
  if isinstance(self._modules_map, str):
860
- with open(self._modules_map, "r") as map_json_file:
860
+ with open(self._modules_map) as map_json_file:
861
861
  self._modules_map = json.loads(map_json_file.read())
862
862
 
863
863
  # Start importing the modules according to the map:
@@ -887,7 +887,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
887
887
 
888
888
  # Read the custom objects map if given as a json:
889
889
  if isinstance(self._custom_objects_map, str):
890
- with open(self._custom_objects_map, "r") as map_json_file:
890
+ with open(self._custom_objects_map) as map_json_file:
891
891
  self._custom_objects_map = json.loads(map_json_file.read())
892
892
 
893
893
  # Unzip the custom objects files if the directory was given as a zip:
@@ -917,7 +917,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
917
917
  ),
918
918
  }
919
919
 
920
- def _log_modules(self) -> Dict[str, Artifact]:
920
+ def _log_modules(self) -> dict[str, Artifact]:
921
921
  """
922
922
  Log the modules, returning the modules map json file logged as an artifact.
923
923
 
@@ -946,7 +946,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
946
946
 
947
947
  return artifacts
948
948
 
949
- def _log_custom_objects(self) -> Dict[str, Artifact]:
949
+ def _log_custom_objects(self) -> dict[str, Artifact]:
950
950
  """
951
951
  Log the custom objects, returning their artifacts:
952
952
 
@@ -1002,8 +1002,8 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
1002
1002
 
1003
1003
  def _read_io_samples(
1004
1004
  self,
1005
- samples: Union[CommonTypes.IOSampleType, List[CommonTypes.IOSampleType]],
1006
- ) -> List[Feature]:
1005
+ samples: Union[CommonTypes.IOSampleType, list[CommonTypes.IOSampleType]],
1006
+ ) -> list[Feature]:
1007
1007
  """
1008
1008
  Read the given inputs / output sample to / from the model into a list of MLRun Features (ports) to log in
1009
1009
  the model's artifact.
@@ -1062,7 +1062,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
1062
1062
 
1063
1063
  @staticmethod
1064
1064
  def _validate_modules_parameter(
1065
- modules_map: Union[Dict[str, Union[None, str, List[str]]], str],
1065
+ modules_map: Union[dict[str, Union[None, str, list[str]]], str],
1066
1066
  ):
1067
1067
  """
1068
1068
  Validate the given modules parameter.
@@ -1090,7 +1090,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
1090
1090
 
1091
1091
  @staticmethod
1092
1092
  def _validate_custom_objects_parameters(
1093
- custom_objects_map: Union[Dict[str, Union[str, List[str]]], str],
1093
+ custom_objects_map: Union[dict[str, Union[str, list[str]]], str],
1094
1094
  custom_objects_directory: str,
1095
1095
  ):
1096
1096
  """
@@ -1154,8 +1154,8 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
1154
1154
 
1155
1155
  @staticmethod
1156
1156
  def _import_module(
1157
- module_path: str, objects_names: Union[List[str], None]
1158
- ) -> Dict[str, Any]:
1157
+ module_path: str, objects_names: Union[list[str], None]
1158
+ ) -> dict[str, Any]:
1159
1159
  """
1160
1160
  Import the given objects by their names from the given module path by the following rules:
1161
1161
 
@@ -1199,8 +1199,8 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
1199
1199
 
1200
1200
  @staticmethod
1201
1201
  def _import_custom_object(
1202
- py_file_path: str, objects_names: List[str]
1203
- ) -> Dict[str, Any]:
1202
+ py_file_path: str, objects_names: list[str]
1203
+ ) -> dict[str, Any]:
1204
1204
  """
1205
1205
  Import the given objects by their names from the given python file as: from 'py_file_path' import 'object_name'.
1206
1206
  If an object specified is already imported, a reference would simply be returned.
@@ -1232,7 +1232,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
1232
1232
  return objects_imports
1233
1233
 
1234
1234
 
1235
- def with_mlrun_interface(interface: Type[MLRunInterface]):
1235
+ def with_mlrun_interface(interface: type[MLRunInterface]):
1236
1236
  """
1237
1237
  Decorator configure for decorating a ModelHandler method (expecting 'self' to be the first argument) to add the
1238
1238
  given MLRun interface into the model before executing the method and remove it afterwards.
@@ -1261,7 +1261,7 @@ def with_mlrun_interface(interface: Type[MLRunInterface]):
1261
1261
  return decorator
1262
1262
 
1263
1263
 
1264
- def without_mlrun_interface(interface: Type[MLRunInterface]):
1264
+ def without_mlrun_interface(interface: type[MLRunInterface]):
1265
1265
  """
1266
1266
  Decorator configure for decorating a ModelHandler method (expecting 'self' to be the first argument) to remove the
1267
1267
  given MLRun interface from the model before executing the method and restore it afterwards.
@@ -13,7 +13,6 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  from abc import ABC, abstractmethod
16
- from typing import Dict
17
16
 
18
17
  import mlrun
19
18
  from mlrun.artifacts import Artifact
@@ -33,7 +32,7 @@ class Plan(ABC):
33
32
  self._artifacts = {} # type: Dict[str, Artifact]
34
33
 
35
34
  @property
36
- def artifacts(self) -> Dict[str, Artifact]:
35
+ def artifacts(self) -> dict[str, Artifact]:
37
36
  """
38
37
  Get the plan's produced artifacts.
39
38
 
@@ -59,7 +58,7 @@ class Plan(ABC):
59
58
  pass
60
59
 
61
60
  @abstractmethod
62
- def produce(self, *args, **kwargs) -> Dict[str, Artifact]:
61
+ def produce(self, *args, **kwargs) -> dict[str, Artifact]:
63
62
  """
64
63
  Produce the artifact according to this plan.
65
64
 
@@ -12,7 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #
15
- from typing import Dict, List
16
15
 
17
16
  import mlrun
18
17
  from mlrun.artifacts import Artifact
@@ -29,7 +28,7 @@ class Producer:
29
28
  def __init__(
30
29
  self,
31
30
  context: mlrun.MLClientCtx = None,
32
- plans: List[Plan] = None,
31
+ plans: list[Plan] = None,
33
32
  ):
34
33
  """
35
34
  Initialize a producer with the given plans. The producer will log the produced artifacts using the given
@@ -68,7 +67,7 @@ class Producer:
68
67
  return self._context
69
68
 
70
69
  @property
71
- def artifacts(self) -> Dict[str, Artifact]:
70
+ def artifacts(self) -> dict[str, Artifact]:
72
71
  """
73
72
  Get the logged artifacts.
74
73
 
@@ -92,7 +91,7 @@ class Producer:
92
91
  """
93
92
  self._context = context
94
93
 
95
- def set_plans(self, plans: List[Plan]):
94
+ def set_plans(self, plans: list[Plan]):
96
95
  """
97
96
  Update the plans of this logger to the given list of plans here.
98
97
 
@@ -16,7 +16,7 @@ import re
16
16
  from abc import ABC
17
17
  from enum import Enum
18
18
  from pathlib import Path
19
- from typing import Any, Dict, List, Tuple, TypeVar, Union
19
+ from typing import Any, TypeVar, Union
20
20
 
21
21
  import numpy as np
22
22
  import pandas as pd
@@ -42,10 +42,10 @@ class CommonTypes(ABC):
42
42
  MLRunInterfaceableType = TypeVar("MLRunInterfaceableType")
43
43
 
44
44
  # Type for a MLRun Interface restoration tuple as returned from 'remove_interface':
45
- MLRunInterfaceRestorationType = Tuple[
46
- Dict[str, Any], # Interface properties.
47
- Dict[str, Any], # Replaced properties.
48
- List[str], # Replaced methods and functions.
45
+ MLRunInterfaceRestorationType = tuple[
46
+ dict[str, Any], # Interface properties.
47
+ dict[str, Any], # Replaced properties.
48
+ list[str], # Replaced methods and functions.
49
49
  ]
50
50
 
51
51
  # Common dataset type to all frameworks:
@@ -12,7 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #
15
- from typing import Dict, List
16
15
 
17
16
  import mlrun
18
17
 
@@ -79,7 +78,7 @@ class Logger:
79
78
  return self._mode
80
79
 
81
80
  @property
82
- def training_results(self) -> Dict[str, List[List[float]]]:
81
+ def training_results(self) -> dict[str, list[list[float]]]:
83
82
  """
84
83
  Get the training results logged. The results will be stored in a dictionary where each key is the metric name
85
84
  and the value is a list of lists of values. The first list is by epoch and the second list is by iteration
@@ -90,7 +89,7 @@ class Logger:
90
89
  return self._training_results
91
90
 
92
91
  @property
93
- def validation_results(self) -> Dict[str, List[List[float]]]:
92
+ def validation_results(self) -> dict[str, list[list[float]]]:
94
93
  """
95
94
  Get the validation results logged. The results will be stored in a dictionary where each key is the metric name
96
95
  and the value is a list of lists of values. The first list is by epoch and the second list is by iteration
@@ -101,7 +100,7 @@ class Logger:
101
100
  return self._validation_results
102
101
 
103
102
  @property
104
- def training_summaries(self) -> Dict[str, List[float]]:
103
+ def training_summaries(self) -> dict[str, list[float]]:
105
104
  """
106
105
  Get the training summaries of the metrics results. The summaries will be stored in a dictionary where each key
107
106
  is the metric names and the value is a list of all the summary values per epoch.
@@ -111,7 +110,7 @@ class Logger:
111
110
  return self._training_summaries
112
111
 
113
112
  @property
114
- def validation_summaries(self) -> Dict[str, List[float]]:
113
+ def validation_summaries(self) -> dict[str, list[float]]:
115
114
  """
116
115
  Get the validation summaries of the metrics results. The summaries will be stored in a dictionary where each key
117
116
  is the metric names and the value is a list of all the summary values per epoch.
@@ -121,7 +120,7 @@ class Logger:
121
120
  return self._validation_summaries
122
121
 
123
122
  @property
124
- def static_hyperparameters(self) -> Dict[str, DLTypes.TrackableType]:
123
+ def static_hyperparameters(self) -> dict[str, DLTypes.TrackableType]:
125
124
  """
126
125
  Get the static hyperparameters logged. The hyperparameters will be stored in a dictionary where each key is the
127
126
  hyperparameter name and the value is his logged value.
@@ -131,7 +130,7 @@ class Logger:
131
130
  return self._static_hyperparameters
132
131
 
133
132
  @property
134
- def dynamic_hyperparameters(self) -> Dict[str, List[DLTypes.TrackableType]]:
133
+ def dynamic_hyperparameters(self) -> dict[str, list[DLTypes.TrackableType]]:
135
134
  """
136
135
  Get the dynamic hyperparameters logged. The hyperparameters will be stored in a dictionary where each key is the
137
136
  hyperparameter name and the value is a list of his logged values per epoch.
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  import itertools
16
- from typing import Dict, List, Union
16
+ from typing import Union
17
17
 
18
18
  import numpy as np
19
19
  import plotly.graph_objects as go
@@ -63,7 +63,7 @@ class MLRunLogger(Logger):
63
63
  :param context: MLRun context to log to. The context parameters can be logged as static
64
64
  hyperparameters.
65
65
  """
66
- super(MLRunLogger, self).__init__(context=context)
66
+ super().__init__(context=context)
67
67
 
68
68
  # Prepare the artifacts collection:
69
69
  self._artifacts = {} # type: Dict[str, Artifact]
@@ -144,9 +144,9 @@ class MLRunLogger(Logger):
144
144
  self,
145
145
  model_handler: DLModelHandler,
146
146
  tag: str = "",
147
- labels: Dict[str, DLTypes.TrackableType] = None,
148
- parameters: Dict[str, DLTypes.TrackableType] = None,
149
- extra_data: Dict[str, Union[DLTypes.TrackableType, Artifact]] = None,
147
+ labels: dict[str, DLTypes.TrackableType] = None,
148
+ parameters: dict[str, DLTypes.TrackableType] = None,
149
+ extra_data: dict[str, Union[DLTypes.TrackableType, Artifact]] = None,
150
150
  ):
151
151
  """
152
152
  Log the run, summarizing the validation metrics and dynamic hyperparameters across all epochs. If 'update' is
@@ -227,7 +227,7 @@ class MLRunLogger(Logger):
227
227
  # Commit to update the changes, so they will be available in the MLRun UI:
228
228
  self._context.commit(completed=False)
229
229
 
230
- def _generate_metrics_summary(self) -> Dict[str, float]:
230
+ def _generate_metrics_summary(self) -> dict[str, float]:
231
231
  """
232
232
  Generate a metrics summary to log along the model.
233
233
 
@@ -254,7 +254,7 @@ class MLRunLogger(Logger):
254
254
 
255
255
  @staticmethod
256
256
  def _generate_metric_results_artifact(
257
- loop: str, name: str, epochs_results: List[List[float]]
257
+ loop: str, name: str, epochs_results: list[list[float]]
258
258
  ) -> PlotlyArtifact:
259
259
  """
260
260
  Generate a plotly artifact for the results of the metric provided.
@@ -300,7 +300,7 @@ class MLRunLogger(Logger):
300
300
 
301
301
  @staticmethod
302
302
  def _generate_summary_results_artifact(
303
- name: str, training_results: List[float], validation_results: List[float]
303
+ name: str, training_results: list[float], validation_results: list[float]
304
304
  ) -> PlotlyArtifact:
305
305
  """
306
306
  Generate a plotly artifact for the results summary across all the epochs of training.
@@ -351,7 +351,7 @@ class MLRunLogger(Logger):
351
351
 
352
352
  @staticmethod
353
353
  def _generate_dynamic_hyperparameter_values_artifact(
354
- name: str, values: List[float]
354
+ name: str, values: list[float]
355
355
  ) -> PlotlyArtifact:
356
356
  """
357
357
  Generate a plotly artifact for the values of the hyperparameter provided.
@@ -15,7 +15,7 @@
15
15
  import os
16
16
  from abc import abstractmethod
17
17
  from datetime import datetime
18
- from typing import Any, Callable, Dict, Generic, List, Union
18
+ from typing import Any, Callable, Generic, Union
19
19
 
20
20
  import yaml
21
21
 
@@ -60,7 +60,7 @@ class TensorboardLogger(Logger, Generic[DLTypes.WeightType]):
60
60
 
61
61
  def __init__(
62
62
  self,
63
- statistics_functions: List[
63
+ statistics_functions: list[
64
64
  Callable[[DLTypes.WeightType], Union[float, DLTypes.WeightType]]
65
65
  ],
66
66
  context: mlrun.MLClientCtx = None,
@@ -94,7 +94,7 @@ class TensorboardLogger(Logger, Generic[DLTypes.WeightType]):
94
94
  :raise MLRunInvalidArgumentError: If the `update_frequency` is illegal or if `tensorboard_directory` and
95
95
  `context` were not given.
96
96
  """
97
- super(TensorboardLogger, self).__init__(context=context)
97
+ super().__init__(context=context)
98
98
 
99
99
  # Validate the context and tensorboard directory combination:
100
100
  if tensorboard_directory is None and context is None:
@@ -136,7 +136,7 @@ class TensorboardLogger(Logger, Generic[DLTypes.WeightType]):
136
136
  self._weights_statistics[statistic_function.__name__] = {} # type: Dict[str, List[float]]
137
137
 
138
138
  @property
139
- def weights(self) -> Dict[str, DLTypes.WeightType]:
139
+ def weights(self) -> dict[str, DLTypes.WeightType]:
140
140
  """
141
141
  Get the logged weights dictionary. Each of the logged weight will be found by its name.
142
142
 
@@ -145,7 +145,7 @@ class TensorboardLogger(Logger, Generic[DLTypes.WeightType]):
145
145
  return self._weights
146
146
 
147
147
  @property
148
- def weight_statistics(self) -> Dict[str, Dict[str, List[float]]]:
148
+ def weight_statistics(self) -> dict[str, dict[str, list[float]]]:
149
149
  """
150
150
  Get the logged statistics for all the tracked weights. Each statistic has a dictionary of weights and their list
151
151
  of epochs values.
@@ -514,23 +514,15 @@ class TensorboardLogger(Logger, Generic[DLTypes.WeightType]):
514
514
  + list(self._dynamic_hyperparameters.keys()),
515
515
  ],
516
516
  ):
517
- text += "\n * **{}**: {}".format(
518
- property_name.capitalize(),
519
- self._markdown_print(value=property_value, tabs=2),
520
- )
517
+ text += f"\n * **{property_name.capitalize()}**: {self._markdown_print(value=property_value, tabs=2)}"
521
518
 
522
519
  # Add the context state:
523
520
  if self._context is not None:
524
- text += "\n####Context initial state: ({})".format(
525
- self._generate_context_link(context=self._context)
526
- )
521
+ text += f"\n####Context initial state: ({self._generate_context_link(context=self._context)})"
527
522
  for property_name, property_value in self._extract_properties_from_context(
528
523
  context=self._context
529
524
  ).items():
530
- text += "\n * **{}**: {}".format(
531
- property_name.capitalize(),
532
- self._markdown_print(value=property_value, tabs=2),
533
- )
525
+ text += f"\n * **{property_name.capitalize()}**: {self._markdown_print(value=property_value, tabs=2)}"
534
526
 
535
527
  return text
536
528
 
@@ -541,7 +533,7 @@ class TensorboardLogger(Logger, Generic[DLTypes.WeightType]):
541
533
 
542
534
  :return: The generated text.
543
535
  """
544
- text = "####Epoch {} summary:".format(self._epochs)
536
+ text = f"####Epoch {self._epochs} summary:"
545
537
  if self._context is not None:
546
538
  for property_name, property_value in self._extract_properties_from_context(
547
539
  context=self._context
@@ -561,10 +553,7 @@ class TensorboardLogger(Logger, Generic[DLTypes.WeightType]):
561
553
  )
562
554
  else:
563
555
  for property_name, property_value in self._extract_epoch_results().items():
564
- text += "\n * **{}**: {}".format(
565
- property_name.capitalize(),
566
- self._markdown_print(value=property_value, tabs=2),
567
- )
556
+ text += f"\n * **{property_name.capitalize()}**: {self._markdown_print(value=property_value, tabs=2)}"
568
557
  return text
569
558
 
570
559
  def _generate_run_end_text(self) -> str:
@@ -575,30 +564,22 @@ class TensorboardLogger(Logger, Generic[DLTypes.WeightType]):
575
564
  :return: The generated text.
576
565
  """
577
566
  # Write the run summary:
578
- text = "\n####Run final summary - epoch {}:".format(self._epochs)
567
+ text = f"\n####Run final summary - epoch {self._epochs}:"
579
568
  for property_name, property_value in self._extract_epoch_results().items():
580
- text += "\n * **{}**: {}".format(
581
- property_name.capitalize(),
582
- self._markdown_print(value=property_value, tabs=2),
583
- )
569
+ text += f"\n * **{property_name.capitalize()}**: {self._markdown_print(value=property_value, tabs=2)}"
584
570
 
585
571
  # Add the context final state:
586
572
  if self._context is not None:
587
- text += "\n####Context final state: ({})".format(
588
- self._generate_context_link(context=self._context)
589
- )
573
+ text += f"\n####Context final state: ({self._generate_context_link(context=self._context)})"
590
574
  for property_name, property_value in self._extract_properties_from_context(
591
575
  context=self._context
592
576
  ).items():
593
- text += "\n * **{}**: {}".format(
594
- property_name.capitalize(),
595
- self._markdown_print(value=property_value, tabs=2),
596
- )
577
+ text += f"\n * **{property_name.capitalize()}**: {self._markdown_print(value=property_value, tabs=2)}"
597
578
  return text
598
579
 
599
580
  def _extract_epoch_results(
600
581
  self, epoch: int = -1
601
- ) -> Dict[str, Dict[str, DLTypes.TrackableType]]:
582
+ ) -> dict[str, dict[str, DLTypes.TrackableType]]:
602
583
  """
603
584
  Extract the given epoch results from all the collected values and results.
604
585
 
@@ -643,7 +624,7 @@ class TensorboardLogger(Logger, Generic[DLTypes.WeightType]):
643
624
  )
644
625
 
645
626
  @staticmethod
646
- def _extract_properties_from_context(context: mlrun.MLClientCtx) -> Dict[str, Any]:
627
+ def _extract_properties_from_context(context: mlrun.MLClientCtx) -> dict[str, Any]:
647
628
  """
648
629
  Extract the properties of the run this context belongs to.
649
630
 
@@ -13,7 +13,6 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  from abc import ABC
16
- from typing import List
17
16
 
18
17
  from .._common.artifacts_library import ArtifactsLibrary, Plan
19
18
  from .plans import (
@@ -47,7 +46,7 @@ class MLArtifactsLibrary(ArtifactsLibrary, ABC):
47
46
  @classmethod
48
47
  def default(
49
48
  cls, model: MLTypes.ModelType, y: MLTypes.DatasetType = None, *args, **kwargs
50
- ) -> List[Plan]:
49
+ ) -> list[Plan]:
51
50
  """
52
51
  Get the default artifacts plans list of this framework's library.
53
52