mlrun 1.7.2__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 -14
  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.2.dist-info → mlrun-1.8.0rc1.dist-info}/METADATA +187 -199
  217. mlrun-1.8.0rc1.dist-info/RECORD +356 -0
  218. {mlrun-1.7.2.dist-info → mlrun-1.8.0rc1.dist-info}/WHEEL +1 -1
  219. mlrun-1.7.2.dist-info/RECORD +0 -351
  220. {mlrun-1.7.2.dist-info → mlrun-1.8.0rc1.dist-info}/LICENSE +0 -0
  221. {mlrun-1.7.2.dist-info → mlrun-1.8.0rc1.dist-info}/entry_points.txt +0 -0
  222. {mlrun-1.7.2.dist-info → mlrun-1.8.0rc1.dist-info}/top_level.txt +0 -0
@@ -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, Generic, Union
20
+ from typing import Any, Generic, Optional, 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: Optional[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,9 @@ 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,
242
+ obj: CommonTypes.MLRunInterfaceableType,
243
+ properties: Optional[dict[str, Any]] = None,
242
244
  ):
243
245
  """
244
246
  Replace the properties of the given object according to the configuration in the MLRun interface.
@@ -282,7 +284,9 @@ class MLRunInterface(ABC, Generic[CommonTypes.MLRunInterfaceableType]):
282
284
 
283
285
  @classmethod
284
286
  def _replace_functions(
285
- cls, obj: CommonTypes.MLRunInterfaceableType, functions: list[str] = None
287
+ cls,
288
+ obj: CommonTypes.MLRunInterfaceableType,
289
+ functions: Optional[list[str]] = None,
286
290
  ):
287
291
  """
288
292
  Replace the functions / methods of the given object according to the configuration in the MLRun interface.
@@ -417,8 +421,8 @@ class MLRunInterface(ABC, Generic[CommonTypes.MLRunInterfaceableType]):
417
421
  def _get_function_argument(
418
422
  func: FunctionType,
419
423
  argument_name: str,
420
- passed_args: tuple = None,
421
- passed_kwargs: dict = None,
424
+ passed_args: Optional[tuple] = None,
425
+ passed_kwargs: Optional[dict] = None,
422
426
  default_value: Any = None,
423
427
  ) -> tuple[Any, Union[str, int, None]]:
424
428
  """
@@ -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, Generic, Union
23
+ from typing import Any, Generic, Optional, Union
24
24
 
25
25
  import numpy as np
26
26
 
@@ -55,7 +55,7 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
55
55
  self,
56
56
  model: CommonTypes.ModelType = None,
57
57
  model_path: CommonTypes.PathType = None,
58
- model_name: str = None,
58
+ model_name: Optional[str] = None,
59
59
  modules_map: Union[
60
60
  dict[str, Union[None, str, list[str]]], CommonTypes.PathType
61
61
  ] = None,
@@ -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: Optional[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: Optional[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: Optional[dict[str, Union[str, int, float]]] = None,
367
+ to_remove: Optional[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: Optional[dict[str, Union[str, int, float]]] = None,
387
+ to_remove: Optional[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: Optional[dict[str, CommonTypes.ExtraDataType]] = None,
407
+ to_remove: Optional[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: Optional[dict[str, CommonTypes.ExtraDataType]] = None,
427
+ to_remove: Optional[list[str]] = None,
428
428
  ):
429
429
  """
430
430
  Update the extra data dictionary of this model artifact.
@@ -509,7 +509,9 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
509
509
  self._import_custom_objects()
510
510
 
511
511
  @abstractmethod
512
- def to_onnx(self, model_name: str = None, optimize: bool = True, **kwargs):
512
+ def to_onnx(
513
+ self, model_name: Optional[str] = None, optimize: bool = True, **kwargs
514
+ ):
513
515
  """
514
516
  Convert the model in this handler to an ONNX model.
515
517
 
@@ -525,13 +527,13 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
525
527
  def log(
526
528
  self,
527
529
  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,
530
+ labels: Optional[dict[str, Union[str, int, float]]] = None,
531
+ parameters: Optional[dict[str, Union[str, int, float]]] = None,
532
+ inputs: Optional[list[Feature]] = None,
533
+ outputs: Optional[list[Feature]] = None,
534
+ metrics: Optional[dict[str, Union[int, float]]] = None,
535
+ artifacts: Optional[dict[str, Artifact]] = None,
536
+ extra_data: Optional[dict[str, CommonTypes.ExtraDataType]] = None,
535
537
  **kwargs,
536
538
  ):
537
539
  """
@@ -630,13 +632,13 @@ class ModelHandler(ABC, Generic[CommonTypes.ModelType, CommonTypes.IOSampleType]
630
632
 
631
633
  def update(
632
634
  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,
635
+ labels: Optional[dict[str, Union[str, int, float]]] = None,
636
+ parameters: Optional[dict[str, Union[str, int, float]]] = None,
637
+ inputs: Optional[list[Feature]] = None,
638
+ outputs: Optional[list[Feature]] = None,
639
+ metrics: Optional[dict[str, Union[int, float]]] = None,
640
+ artifacts: Optional[dict[str, Artifact]] = None,
641
+ extra_data: Optional[dict[str, CommonTypes.ExtraDataType]] = None,
640
642
  **kwargs,
641
643
  ):
642
644
  """
@@ -13,6 +13,8 @@
13
13
  # limitations under the License.
14
14
  #
15
15
 
16
+ from typing import Optional
17
+
16
18
  import mlrun
17
19
  from mlrun.artifacts import Artifact
18
20
 
@@ -28,7 +30,7 @@ class Producer:
28
30
  def __init__(
29
31
  self,
30
32
  context: mlrun.MLClientCtx = None,
31
- plans: list[Plan] = None,
33
+ plans: Optional[list[Plan]] = None,
32
34
  ):
33
35
  """
34
36
  Initialize a producer with the given plans. The producer will log the produced artifacts using the given
@@ -11,7 +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
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
14
+
16
15
  from .model_handler import DLModelHandler
17
16
  from .utils import DLTypes, DLUtils
@@ -11,8 +11,7 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- #
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
14
+
16
15
  from .logger import Logger
17
16
  from .mlrun_logger import MLRunLogger
18
17
  from .tensorboard_logger import TensorboardLogger
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  import itertools
16
- from typing import Union
16
+ from typing import Optional, Union
17
17
 
18
18
  import numpy as np
19
19
  import plotly.graph_objects as go
@@ -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: Optional[dict[str, DLTypes.TrackableType]] = None,
148
+ parameters: Optional[dict[str, DLTypes.TrackableType]] = None,
149
+ extra_data: Optional[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
@@ -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, Generic, Union
18
+ from typing import Any, Callable, Generic, Optional, Union
19
19
 
20
20
  import yaml
21
21
 
@@ -64,8 +64,8 @@ class TensorboardLogger(Logger, Generic[DLTypes.WeightType]):
64
64
  Callable[[DLTypes.WeightType], Union[float, DLTypes.WeightType]]
65
65
  ],
66
66
  context: mlrun.MLClientCtx = None,
67
- tensorboard_directory: str = None,
68
- run_name: str = None,
67
+ tensorboard_directory: Optional[str] = None,
68
+ run_name: Optional[str] = None,
69
69
  update_frequency: Union[int, str] = "epoch",
70
70
  ):
71
71
  """
@@ -11,8 +11,7 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- #
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
14
+
16
15
  from .artifacts_library import MLArtifactsLibrary
17
16
  from .model_handler import MLModelHandler
18
17
  from .pkl_model_server import PickleModelServer
@@ -11,7 +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
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
14
+
16
15
  from .logger import Logger
17
16
  from .mlrun_logger import MLRunLogger
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  from abc import ABC
16
- from typing import Union
16
+ from typing import Optional, Union
17
17
 
18
18
  import mlrun
19
19
  from mlrun.artifacts import Artifact
@@ -33,7 +33,7 @@ class MLModelHandler(ModelHandler, ABC):
33
33
  self,
34
34
  model: MLTypes.ModelType = None,
35
35
  model_path: MLTypes.PathType = None,
36
- model_name: str = None,
36
+ model_name: Optional[str] = None,
37
37
  modules_map: Union[
38
38
  dict[str, Union[None, str, list[str]]], MLTypes.PathType
39
39
  ] = None,
@@ -224,18 +224,18 @@ class MLModelHandler(ModelHandler, ABC):
224
224
  def log(
225
225
  self,
226
226
  tag: str = "",
227
- labels: dict[str, Union[str, int, float]] = None,
228
- parameters: dict[str, Union[str, int, float]] = None,
229
- inputs: list[Feature] = None,
230
- outputs: list[Feature] = None,
231
- metrics: dict[str, Union[int, float]] = None,
232
- artifacts: dict[str, Artifact] = None,
233
- extra_data: dict[str, MLTypes.ExtraDataType] = None,
234
- algorithm: str = None,
227
+ labels: Optional[dict[str, Union[str, int, float]]] = None,
228
+ parameters: Optional[dict[str, Union[str, int, float]]] = None,
229
+ inputs: Optional[list[Feature]] = None,
230
+ outputs: Optional[list[Feature]] = None,
231
+ metrics: Optional[dict[str, Union[int, float]]] = None,
232
+ artifacts: Optional[dict[str, Artifact]] = None,
233
+ extra_data: Optional[dict[str, MLTypes.ExtraDataType]] = None,
234
+ algorithm: Optional[str] = None,
235
235
  sample_set: MLTypes.DatasetType = None,
236
236
  target_columns: MLTypes.TargetColumnsNamesType = None,
237
- feature_vector: str = None,
238
- feature_weights: list[float] = None,
237
+ feature_vector: Optional[str] = None,
238
+ feature_weights: Optional[list[float]] = None,
239
239
  ):
240
240
  """
241
241
  Log the model held by this handler into the MLRun context provided.
@@ -299,15 +299,15 @@ class MLModelHandler(ModelHandler, ABC):
299
299
 
300
300
  def update(
301
301
  self,
302
- labels: dict[str, Union[str, int, float]] = None,
303
- parameters: dict[str, Union[str, int, float]] = None,
304
- inputs: list[Feature] = None,
305
- outputs: list[Feature] = None,
306
- metrics: dict[str, Union[int, float]] = None,
307
- artifacts: dict[str, Artifact] = None,
308
- extra_data: dict[str, MLTypes.ExtraDataType] = None,
309
- feature_vector: str = None,
310
- feature_weights: list[float] = None,
302
+ labels: Optional[dict[str, Union[str, int, float]]] = None,
303
+ parameters: Optional[dict[str, Union[str, int, float]]] = None,
304
+ inputs: Optional[list[Feature]] = None,
305
+ outputs: Optional[list[Feature]] = None,
306
+ metrics: Optional[dict[str, Union[int, float]]] = None,
307
+ artifacts: Optional[dict[str, Artifact]] = None,
308
+ extra_data: Optional[dict[str, MLTypes.ExtraDataType]] = None,
309
+ feature_vector: Optional[str] = None,
310
+ feature_weights: Optional[list[float]] = None,
311
311
  ):
312
312
  """
313
313
  Update the model held by this handler into the MLRun context provided, updating the model's artifact properties
@@ -11,8 +11,7 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- #
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
14
+
16
15
  from .calibration_curve_plan import CalibrationCurvePlan
17
16
  from .confusion_matrix_plan import ConfusionMatrixPlan
18
17
  from .dataset_plan import DatasetPlan
@@ -13,6 +13,8 @@
13
13
  # limitations under the License.
14
14
  #
15
15
 
16
+ from typing import Optional
17
+
16
18
  import numpy as np
17
19
  import pandas as pd
18
20
  from plotly.figure_factory import create_annotated_heatmap
@@ -35,7 +37,7 @@ class ConfusionMatrixPlan(MLPlotPlan):
35
37
  self,
36
38
  labels: np.ndarray = None,
37
39
  sample_weight: np.ndarray = None,
38
- normalize: str = None,
40
+ normalize: Optional[str] = None,
39
41
  ):
40
42
  """
41
43
  Initialize a confusion matrix plan with the given configuration.
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  from enum import Enum
16
- from typing import Union
16
+ from typing import Optional, Union
17
17
 
18
18
  import mlrun.errors
19
19
  from mlrun.artifacts import Artifact, DatasetArtifact
@@ -49,8 +49,8 @@ class DatasetPlan(MLPlan):
49
49
  def __init__(
50
50
  self,
51
51
  purpose: Union[Purposes, str] = Purposes.OTHER,
52
- name: str = None,
53
- preview: int = None,
52
+ name: Optional[str] = None,
53
+ preview: Optional[int] = None,
54
54
  stats: bool = False,
55
55
  fmt: str = "parquet",
56
56
  ):
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  #
15
- from typing import Union
15
+ from typing import Optional, Union
16
16
 
17
17
  import numpy as np
18
18
  import pandas as pd
@@ -35,13 +35,13 @@ class ROCCurvePlan(MLPlotPlan):
35
35
 
36
36
  def __init__(
37
37
  self,
38
- pos_label: Union[str, int] = None,
38
+ pos_label: Optional[Union[str, int]] = None,
39
39
  sample_weight: np.ndarray = None,
40
40
  drop_intermediate: bool = True,
41
41
  average: str = "macro",
42
- max_fpr: float = None,
42
+ max_fpr: Optional[float] = None,
43
43
  multi_class: str = "raise",
44
- labels: list[str] = None,
44
+ labels: Optional[list[str]] = None,
45
45
  ):
46
46
  """
47
47
  Initialize a receiver operating characteristic plan with the given configuration.
@@ -11,6 +11,5 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- #
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
14
+
16
15
  from .auto_mlrun import AutoMLRun
@@ -11,9 +11,8 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- #
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
16
- from typing import Callable, Union
14
+
15
+ from typing import Callable, Optional, Union
17
16
 
18
17
  import mlrun
19
18
  from mlrun.artifacts import get_model
@@ -261,7 +260,7 @@ class AutoMLRun:
261
260
 
262
261
  @staticmethod
263
262
  def _get_framework(
264
- model: CommonTypes.ModelType = None, model_path: str = None
263
+ model: CommonTypes.ModelType = None, model_path: Optional[str] = None
265
264
  ) -> Union[tuple[str, dict]]:
266
265
  """
267
266
  Try to get the framework from the model or model path provided. The framework can be read from the model path
@@ -320,12 +319,16 @@ class AutoMLRun:
320
319
  @staticmethod
321
320
  def load_model(
322
321
  model_path: str,
323
- model_name: str = None,
322
+ model_name: Optional[str] = None,
324
323
  context: mlrun.MLClientCtx = None,
325
- modules_map: Union[dict[str, Union[None, str, list[str]]], str] = None,
326
- custom_objects_map: Union[dict[str, Union[str, list[str]]], str] = None,
327
- custom_objects_directory: str = None,
328
- framework: str = None,
324
+ modules_map: Optional[
325
+ Union[dict[str, Union[None, str, list[str]]], str]
326
+ ] = None,
327
+ custom_objects_map: Optional[
328
+ Union[dict[str, Union[str, list[str]]], str]
329
+ ] = None,
330
+ custom_objects_directory: Optional[str] = None,
331
+ framework: Optional[str] = None,
329
332
  **kwargs,
330
333
  ) -> ModelHandler:
331
334
  """
@@ -417,14 +420,18 @@ class AutoMLRun:
417
420
  @staticmethod
418
421
  def apply_mlrun(
419
422
  model: CommonTypes.ModelType = None,
420
- model_name: str = None,
423
+ model_name: Optional[str] = None,
421
424
  tag: str = "",
422
- model_path: str = None,
423
- modules_map: Union[dict[str, Union[None, str, list[str]]], str] = None,
424
- custom_objects_map: Union[dict[str, Union[str, list[str]]], str] = None,
425
- custom_objects_directory: str = None,
425
+ model_path: Optional[str] = None,
426
+ modules_map: Optional[
427
+ Union[dict[str, Union[None, str, list[str]]], str]
428
+ ] = None,
429
+ custom_objects_map: Optional[
430
+ Union[dict[str, Union[str, list[str]]], str]
431
+ ] = None,
432
+ custom_objects_directory: Optional[str] = None,
426
433
  context: mlrun.MLClientCtx = None,
427
- framework: str = None,
434
+ framework: Optional[str] = None,
428
435
  auto_log: bool = True,
429
436
  **kwargs,
430
437
  ) -> ModelHandler:
@@ -11,6 +11,5 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- #
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
14
+
16
15
  from .model_server import HuggingFaceModelServer
@@ -12,7 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from typing import Any
15
+ from typing import Any, Optional
16
16
 
17
17
  import numpy as np
18
18
  import transformers
@@ -32,14 +32,14 @@ class HuggingFaceModelServer(V2ModelServer):
32
32
  def __init__(
33
33
  self,
34
34
  context: mlrun.MLClientCtx = None,
35
- name: str = None,
36
- task: str = None,
37
- model_path: str = None,
38
- model_name: str = None,
39
- model_class: str = None,
40
- tokenizer_name: str = None,
41
- tokenizer_class: str = None,
42
- framework: str = None,
35
+ name: Optional[str] = None,
36
+ task: Optional[str] = None,
37
+ model_path: Optional[str] = None,
38
+ model_name: Optional[str] = None,
39
+ model_class: Optional[str] = None,
40
+ tokenizer_name: Optional[str] = None,
41
+ tokenizer_class: Optional[str] = None,
42
+ framework: Optional[str] = None,
43
43
  **class_args,
44
44
  ):
45
45
  """