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
@@ -17,7 +17,7 @@ import typing
17
17
  from copy import copy
18
18
  from datetime import datetime
19
19
  from enum import Enum
20
- from typing import Dict, List, Union
20
+ from typing import Union
21
21
 
22
22
  import numpy as np
23
23
  import pandas as pd
@@ -69,18 +69,16 @@ class FeatureVectorSpec(ModelObj):
69
69
  self._entity_fields: ObjectList = None
70
70
  self._entity_source: DataSource = None
71
71
  self._function: FunctionReference = None
72
- self._relations: typing.Dict[str, ObjectDict] = None
72
+ self._relations: dict[str, ObjectDict] = None
73
73
  self._join_graph: JoinGraph = None
74
74
 
75
75
  self.description = description
76
- self.features: List[str] = features or []
76
+ self.features: list[str] = features or []
77
77
  self.entity_source = entity_source
78
78
  self.entity_fields = entity_fields or []
79
79
  self.graph = graph
80
80
  self.join_graph = join_graph
81
- self.relations: typing.Dict[str, typing.Dict[str, Union[Entity, str]]] = (
82
- relations or {}
83
- )
81
+ self.relations: dict[str, dict[str, Union[Entity, str]]] = relations or {}
84
82
  self.timestamp_field = timestamp_field
85
83
  self.label_feature = label_feature
86
84
  self.with_indexes = with_indexes
@@ -97,12 +95,12 @@ class FeatureVectorSpec(ModelObj):
97
95
  self._entity_source = self._verify_dict(source, "entity_source", DataSource)
98
96
 
99
97
  @property
100
- def entity_fields(self) -> List[Feature]:
98
+ def entity_fields(self) -> list[Feature]:
101
99
  """the schema/metadata for the entity source fields"""
102
100
  return self._entity_fields
103
101
 
104
102
  @entity_fields.setter
105
- def entity_fields(self, entity_fields: List[Feature]):
103
+ def entity_fields(self, entity_fields: list[Feature]):
106
104
  self._entity_fields = ObjectList.from_list(Feature, entity_fields)
107
105
 
108
106
  @property
@@ -125,14 +123,12 @@ class FeatureVectorSpec(ModelObj):
125
123
  self._function = self._verify_dict(function, "function", FunctionReference)
126
124
 
127
125
  @property
128
- def relations(self) -> typing.Dict[str, ObjectDict]:
126
+ def relations(self) -> dict[str, ObjectDict]:
129
127
  """feature set relations dict"""
130
128
  return self._relations
131
129
 
132
130
  @relations.setter
133
- def relations(
134
- self, relations: typing.Dict[str, typing.Dict[str, Union[Entity, str]]]
135
- ):
131
+ def relations(self, relations: dict[str, dict[str, Union[Entity, str]]]):
136
132
  temp_relations = {}
137
133
  for fs_name, relation in relations.items():
138
134
  for col, ent in relation.items():
@@ -179,29 +175,29 @@ class FeatureVectorStatus(ModelObj):
179
175
  self.stats = stats or {}
180
176
  self.index_keys = index_keys
181
177
  self.preview = preview or []
182
- self.features: List[Feature] = features or []
178
+ self.features: list[Feature] = features or []
183
179
  self.run_uri = run_uri
184
180
  self.timestamp_key = timestamp_key
185
181
 
186
182
  @property
187
- def targets(self) -> List[DataTarget]:
183
+ def targets(self) -> list[DataTarget]:
188
184
  """list of material storage targets + their status/path"""
189
185
  return self._targets
190
186
 
191
187
  @targets.setter
192
- def targets(self, targets: List[DataTarget]):
188
+ def targets(self, targets: list[DataTarget]):
193
189
  self._targets = ObjectList.from_list(DataTarget, targets)
194
190
 
195
191
  def update_target(self, target: DataTarget):
196
192
  self._targets.update(target)
197
193
 
198
194
  @property
199
- def features(self) -> List[Feature]:
195
+ def features(self) -> list[Feature]:
200
196
  """list of features (result of joining features from the source feature sets)"""
201
197
  return self._features
202
198
 
203
199
  @features.setter
204
- def features(self, features: List[Feature]):
200
+ def features(self, features: list[Feature]):
205
201
  self._features = ObjectList.from_list(Feature, features)
206
202
 
207
203
 
@@ -378,7 +374,7 @@ class _JoinStep(ModelObj):
378
374
  name: str = None,
379
375
  left_step_name: str = None,
380
376
  right_step_name: str = None,
381
- left_feature_set_names: Union[str, List[str]] = None,
377
+ left_feature_set_names: Union[str, list[str]] = None,
382
378
  right_feature_set_name: str = None,
383
379
  join_type: str = "inner",
384
380
  asof_join: bool = False,
@@ -388,7 +384,8 @@ class _JoinStep(ModelObj):
388
384
  self.right_step_name = right_step_name
389
385
  self.left_feature_set_names = (
390
386
  left_feature_set_names
391
- if isinstance(left_feature_set_names, list)
387
+ if left_feature_set_names is None
388
+ or isinstance(left_feature_set_names, list)
392
389
  else [left_feature_set_names]
393
390
  )
394
391
  self.right_feature_set_name = right_feature_set_name
@@ -402,7 +399,7 @@ class _JoinStep(ModelObj):
402
399
  self,
403
400
  feature_set_objects: ObjectList,
404
401
  vector,
405
- entity_rows_keys: List[str] = None,
402
+ entity_rows_keys: list[str] = None,
406
403
  ):
407
404
  if feature_set_objects[self.right_feature_set_name].is_connectable_to_df(
408
405
  entity_rows_keys
@@ -482,7 +479,7 @@ class FeatureVector(ModelObj):
482
479
  description=None,
483
480
  with_indexes=None,
484
481
  join_graph: JoinGraph = None,
485
- relations: typing.Dict[str, typing.Dict[str, Union[Entity, str]]] = None,
482
+ relations: dict[str, dict[str, Union[Entity, str]]] = None,
486
483
  ):
487
484
  """Feature vector, specify selected features, their metadata and material views
488
485
 
@@ -732,7 +729,7 @@ class FeatureVector(ModelObj):
732
729
  entity_timestamp_column: str = None,
733
730
  target: DataTargetBase = None,
734
731
  run_config: RunConfig = None,
735
- drop_columns: List[str] = None,
732
+ drop_columns: list[str] = None,
736
733
  start_time: Union[str, datetime] = None,
737
734
  end_time: Union[str, datetime] = None,
738
735
  with_indexes: bool = False,
@@ -740,9 +737,9 @@ class FeatureVector(ModelObj):
740
737
  engine: str = None,
741
738
  engine_args: dict = None,
742
739
  query: str = None,
743
- order_by: Union[str, List[str]] = None,
740
+ order_by: Union[str, list[str]] = None,
744
741
  spark_service: str = None,
745
- timestamp_for_filtering: Union[str, Dict[str, str]] = None,
742
+ timestamp_for_filtering: Union[str, dict[str, str]] = None,
746
743
  ):
747
744
  """retrieve offline feature vector results
748
745
 
@@ -827,7 +824,7 @@ class FeatureVector(ModelObj):
827
824
  fixed_window_type: FixedWindowType = FixedWindowType.LastClosedWindow,
828
825
  impute_policy: dict = None,
829
826
  update_stats: bool = False,
830
- entity_keys: List[str] = None,
827
+ entity_keys: list[str] = None,
831
828
  ):
832
829
  """initialize and return online feature vector service api,
833
830
  returns :py:class:`~mlrun.feature_store.OnlineVectorService`
@@ -910,7 +907,7 @@ class OnlineVectorService:
910
907
  graph,
911
908
  index_columns,
912
909
  impute_policy: dict = None,
913
- requested_columns: List[str] = None,
910
+ requested_columns: list[str] = None,
914
911
  ):
915
912
  self.vector = vector
916
913
  self.impute_policy = impute_policy or {}
@@ -966,7 +963,7 @@ class OnlineVectorService:
966
963
  """vector merger function status (ready, running, error)"""
967
964
  return "ready"
968
965
 
969
- def get(self, entity_rows: List[Union[dict, list]], as_list=False):
966
+ def get(self, entity_rows: list[Union[dict, list]], as_list=False):
970
967
  """get feature vector given the provided entity inputs
971
968
 
972
969
  take a list of input vectors/rows and return a list of enriched feature vectors
@@ -540,8 +540,8 @@ class BaseMerger(abc.ABC):
540
540
  self,
541
541
  name: str,
542
542
  order: int,
543
- left_keys: typing.List[str] = None,
544
- right_keys: typing.List[str] = None,
543
+ left_keys: list[str] = None,
544
+ right_keys: list[str] = None,
545
545
  ):
546
546
  self.name = name
547
547
  self.left_keys = left_keys if left_keys is not None else []
@@ -750,8 +750,8 @@ class BaseMerger(abc.ABC):
750
750
  def _get_engine_df(
751
751
  self,
752
752
  feature_set: FeatureSet,
753
- feature_set_name: typing.List[str],
754
- column_names: typing.List[str] = None,
753
+ feature_set_name: list[str],
754
+ column_names: list[str] = None,
755
755
  start_time: typing.Union[str, datetime] = None,
756
756
  end_time: typing.Union[str, datetime] = None,
757
757
  time_column: typing.Optional[str] = None,
@@ -773,8 +773,8 @@ class BaseMerger(abc.ABC):
773
773
  def _rename_columns_and_select(
774
774
  self,
775
775
  df,
776
- rename_col_dict: typing.Dict[str, str],
777
- columns: typing.List[str] = None,
776
+ rename_col_dict: dict[str, str],
777
+ columns: list[str] = None,
778
778
  ):
779
779
  """
780
780
  rename the columns of the df according to rename_col_dict, and select only `columns` if it is not none
@@ -801,7 +801,7 @@ class BaseMerger(abc.ABC):
801
801
  """
802
802
  raise NotImplementedError
803
803
 
804
- def _order_by(self, order_by_active: typing.List[str]):
804
+ def _order_by(self, order_by_active: list[str]):
805
805
  """
806
806
  Order by `order_by_active` along all axis.
807
807
 
@@ -19,7 +19,7 @@ from collections import Counter
19
19
  # np.bool -> bool and np.object -> object fix backported from pyspark v3.3.3.
20
20
 
21
21
 
22
- class PandasConversionMixin(object):
22
+ class PandasConversionMixin:
23
23
  """
24
24
  Min-in for the conversion from Spark to pandas. Currently, only :class:`DataFrame`
25
25
  can use this class.
@@ -108,9 +108,7 @@ class PandasConversionMixin(object):
108
108
  )
109
109
 
110
110
  # Rename columns to avoid duplicated column names.
111
- tmp_column_names = [
112
- "col_{}".format(i) for i in range(len(self.columns))
113
- ]
111
+ tmp_column_names = [f"col_{i}" for i in range(len(self.columns))]
114
112
  self_destruct = self.sql_ctx._conf.arrowPySparkSelfDestructEnabled()
115
113
  batches = self.toDF(*tmp_column_names)._collect_as_arrow(
116
114
  split_batches=self_destruct
@@ -16,7 +16,7 @@ import math
16
16
  import re
17
17
  import uuid
18
18
  from collections import OrderedDict
19
- from typing import Any, Dict, List, Optional, Union
19
+ from typing import Any, Optional, Union
20
20
 
21
21
  import numpy as np
22
22
  import pandas as pd
@@ -92,8 +92,6 @@ class MLRunStep(MapClass):
92
92
 
93
93
 
94
94
  class FeaturesetValidator(StepToDict, MLRunStep):
95
- """Validate feature values according to the feature set validation policy"""
96
-
97
95
  def __init__(self, featureset=None, columns=None, name=None, **kwargs):
98
96
  """Validate feature values according to the feature set validation policy
99
97
 
@@ -152,11 +150,9 @@ class FeaturesetValidator(StepToDict, MLRunStep):
152
150
 
153
151
 
154
152
  class MapValues(StepToDict, MLRunStep):
155
- """Map column values to new values"""
156
-
157
153
  def __init__(
158
154
  self,
159
- mapping: Dict[str, Dict[Union[str, int, bool], Any]],
155
+ mapping: dict[str, dict[Union[str, int, bool], Any]],
160
156
  with_original_features: bool = False,
161
157
  suffix: str = "mapped",
162
158
  **kwargs,
@@ -377,7 +373,7 @@ class Imputer(StepToDict, MLRunStep):
377
373
  self,
378
374
  method: str = "avg",
379
375
  default_value=None,
380
- mapping: Dict[str, Any] = None,
376
+ mapping: dict[str, Any] = None,
381
377
  **kwargs,
382
378
  ):
383
379
  """Replace None values with default values
@@ -423,7 +419,7 @@ class Imputer(StepToDict, MLRunStep):
423
419
 
424
420
 
425
421
  class OneHotEncoder(StepToDict, MLRunStep):
426
- def __init__(self, mapping: Dict[str, List[Union[int, str]]], **kwargs):
422
+ def __init__(self, mapping: dict[str, list[Union[int, str]]], **kwargs):
427
423
  """Create new binary fields, one per category (one hot encoded)
428
424
 
429
425
  example::
@@ -510,15 +506,13 @@ class OneHotEncoder(StepToDict, MLRunStep):
510
506
 
511
507
 
512
508
  class DateExtractor(StepToDict, MLRunStep):
513
- """Date Extractor allows you to extract a date-time component"""
514
-
515
509
  def __init__(
516
510
  self,
517
- parts: Union[Dict[str, str], List[str]],
511
+ parts: Union[dict[str, str], list[str]],
518
512
  timestamp_col: str = None,
519
513
  **kwargs,
520
514
  ):
521
- """Date Extractor extract a date-time component into new columns
515
+ """Date Extractor extracts a date-time component into new columns
522
516
 
523
517
  The extracted date part will appear as `<timestamp_col>_<date_part>` feature.
524
518
 
@@ -629,8 +623,6 @@ class DateExtractor(StepToDict, MLRunStep):
629
623
 
630
624
 
631
625
  class SetEventMetadata(MapClass):
632
- """Set the event metadata (id and key) from the event body"""
633
-
634
626
  def __init__(
635
627
  self,
636
628
  id_path: Optional[str] = None,
@@ -695,7 +687,7 @@ class SetEventMetadata(MapClass):
695
687
 
696
688
 
697
689
  class DropFeatures(StepToDict, MLRunStep):
698
- def __init__(self, features: List[str], **kwargs):
690
+ def __init__(self, features: list[str], **kwargs):
699
691
  """Drop all the features from feature list
700
692
 
701
693
  :param features: string list of the features names to drop
mlrun/features.py CHANGED
@@ -14,7 +14,7 @@
14
14
  #
15
15
  import math
16
16
  import re
17
- from typing import Dict, List, Optional, Union
17
+ from typing import Optional, Union
18
18
 
19
19
  from .data_types import ValueType, python_type_to_value_type
20
20
  from .errors import MLRunRuntimeError, err_to_str
@@ -44,7 +44,7 @@ class Entity(ModelObj):
44
44
  name: str = None,
45
45
  value_type: Union[ValueType, str] = None,
46
46
  description: str = None,
47
- labels: Optional[Dict[str, str]] = None,
47
+ labels: Optional[dict[str, str]] = None,
48
48
  ):
49
49
  """data entity (index key)
50
50
 
@@ -65,8 +65,6 @@ class Entity(ModelObj):
65
65
 
66
66
 
67
67
  class Feature(ModelObj):
68
- """data feature"""
69
-
70
68
  _dict_fields = [
71
69
  "name",
72
70
  "description",
@@ -82,13 +80,13 @@ class Feature(ModelObj):
82
80
  def __init__(
83
81
  self,
84
82
  value_type: Union[ValueType, str] = None,
85
- dims: List[int] = None,
83
+ dims: list[int] = None,
86
84
  description: str = None,
87
85
  aggregate: bool = None,
88
86
  name: str = None,
89
87
  validator=None,
90
88
  default: str = None,
91
- labels: Dict[str, str] = None,
89
+ labels: dict[str, str] = None,
92
90
  ):
93
91
  """data feature
94
92
 
@@ -445,7 +443,7 @@ class RegexValidator(Validator):
445
443
 
446
444
  @classmethod
447
445
  def from_dict(cls, struct=None, fields=None, deprecated_fields: dict = None):
448
- new_obj = super(RegexValidator, cls).from_dict(
446
+ new_obj = super().from_dict(
449
447
  struct=struct, fields=fields, deprecated_fields=deprecated_fields
450
448
  )
451
449
  if hasattr(new_obj, "regex"):
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  from abc import ABC, abstractmethod
16
- from typing import Dict, List, Type, Union
16
+ from typing import Union
17
17
 
18
18
  import mlrun
19
19
 
@@ -39,12 +39,12 @@ class ArtifactsLibrary(ABC):
39
39
  @classmethod
40
40
  def get_plans(
41
41
  cls,
42
- artifacts: Union[List[Plan], Dict[str, dict], List[str]] = None,
42
+ artifacts: Union[list[Plan], dict[str, dict], list[str]] = None,
43
43
  context: mlrun.MLClientCtx = None,
44
44
  include_default: bool = True,
45
45
  # custom_plans: dict = None, :param custom_plans: Custom user plans objects to initialize from.
46
46
  **default_kwargs,
47
- ) -> List[Plan]:
47
+ ) -> list[Plan]:
48
48
  """
49
49
  Get plans for a run. The plans will be taken from the provided artifacts / configuration via code, from provided
50
50
  configuration via MLRun context and if the 'include_default' is True, from the framework artifact library's
@@ -97,7 +97,7 @@ class ArtifactsLibrary(ABC):
97
97
 
98
98
  @classmethod
99
99
  @abstractmethod
100
- def default(cls, **kwargs) -> List[Plan]:
100
+ def default(cls, **kwargs) -> list[Plan]:
101
101
  """
102
102
  Get the default artifacts plans list of this framework's library.
103
103
 
@@ -106,7 +106,7 @@ class ArtifactsLibrary(ABC):
106
106
  pass
107
107
 
108
108
  @classmethod
109
- def _get_library_plans(cls) -> Dict[str, Type[Plan]]:
109
+ def _get_library_plans(cls) -> dict[str, type[Plan]]:
110
110
  """
111
111
  Get all the supported plans in this library.
112
112
 
@@ -120,8 +120,8 @@ class ArtifactsLibrary(ABC):
120
120
 
121
121
  @staticmethod
122
122
  def _from_dict(
123
- requested_plans: Dict[str, dict], available_plans: Dict[str, Type[Plan]]
124
- ) -> List[Plan]:
123
+ requested_plans: dict[str, dict], available_plans: dict[str, type[Plan]]
124
+ ) -> list[Plan]:
125
125
  """
126
126
  Initialize a list of plans from a given configuration dictionary. The configuration is expected to be a
127
127
  dictionary of plans and their initialization parameters in the following format:
@@ -162,8 +162,8 @@ class ArtifactsLibrary(ABC):
162
162
 
163
163
  @staticmethod
164
164
  def _from_list(
165
- requested_plans: List[str], available_plans: Dict[str, Type[Plan]]
166
- ) -> List[Plan]:
165
+ requested_plans: list[str], available_plans: dict[str, type[Plan]]
166
+ ) -> list[Plan]:
167
167
  """
168
168
  Initialize a list of plans from a given configuration list. The configuration is expected to be a list of plans
169
169
  names to be initialized with their default configuration.
@@ -17,7 +17,7 @@ import functools
17
17
  import inspect
18
18
  from abc import ABC
19
19
  from types import FunctionType, MethodType
20
- from typing import Any, Dict, Generic, List, Tuple, Union
20
+ from typing import Any, Generic, Union
21
21
 
22
22
  from .utils import CommonTypes
23
23
 
@@ -173,7 +173,7 @@ class MLRunInterface(ABC, Generic[CommonTypes.MLRunInterfaceableType]):
173
173
  def _insert_properties(
174
174
  cls,
175
175
  obj: CommonTypes.MLRunInterfaceableType,
176
- properties: Dict[str, Any] = None,
176
+ properties: dict[str, Any] = None,
177
177
  ):
178
178
  """
179
179
  Insert the properties of the interface to the object. The properties default values are being copied (not deep
@@ -238,7 +238,7 @@ class MLRunInterface(ABC, Generic[CommonTypes.MLRunInterfaceableType]):
238
238
 
239
239
  @classmethod
240
240
  def _replace_properties(
241
- cls, obj: CommonTypes.MLRunInterfaceableType, properties: Dict[str, Any] = None
241
+ cls, obj: CommonTypes.MLRunInterfaceableType, properties: dict[str, Any] = None
242
242
  ):
243
243
  """
244
244
  Replace the properties of the given object according to the configuration in the MLRun interface.
@@ -282,7 +282,7 @@ class MLRunInterface(ABC, Generic[CommonTypes.MLRunInterfaceableType]):
282
282
 
283
283
  @classmethod
284
284
  def _replace_functions(
285
- cls, obj: CommonTypes.MLRunInterfaceableType, functions: List[str] = None
285
+ cls, obj: CommonTypes.MLRunInterfaceableType, functions: list[str] = None
286
286
  ):
287
287
  """
288
288
  Replace the functions / methods of the given object according to the configuration in the MLRun interface.
@@ -420,7 +420,7 @@ class MLRunInterface(ABC, Generic[CommonTypes.MLRunInterfaceableType]):
420
420
  passed_args: tuple = None,
421
421
  passed_kwargs: dict = None,
422
422
  default_value: Any = None,
423
- ) -> Tuple[Any, Union[str, int, None]]:
423
+ ) -> tuple[Any, Union[str, int, None]]:
424
424
  """
425
425
  Get a passed argument (from *args or **kwargs) to a function. If the argument was not found the default value
426
426
  will be returned. In addition, the keyword of the argument in `kwargs` or the index of the argument in `args`