mlrun 1.7.1rc10__py3-none-any.whl → 1.8.0rc11__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 (259) hide show
  1. mlrun/__init__.py +23 -21
  2. mlrun/__main__.py +3 -3
  3. mlrun/alerts/alert.py +148 -14
  4. mlrun/artifacts/__init__.py +2 -3
  5. mlrun/artifacts/base.py +55 -12
  6. mlrun/artifacts/dataset.py +16 -16
  7. mlrun/artifacts/document.py +378 -0
  8. mlrun/artifacts/manager.py +26 -17
  9. mlrun/artifacts/model.py +66 -53
  10. mlrun/common/constants.py +8 -0
  11. mlrun/common/formatters/__init__.py +1 -0
  12. mlrun/common/formatters/feature_set.py +1 -0
  13. mlrun/common/formatters/function.py +1 -0
  14. mlrun/{model_monitoring/db/stores/base/__init__.py → common/formatters/model_endpoint.py} +16 -1
  15. mlrun/common/formatters/pipeline.py +1 -2
  16. mlrun/common/formatters/project.py +9 -0
  17. mlrun/common/model_monitoring/__init__.py +0 -5
  18. mlrun/common/model_monitoring/helpers.py +1 -29
  19. mlrun/common/runtimes/constants.py +1 -2
  20. mlrun/common/schemas/__init__.py +6 -2
  21. mlrun/common/schemas/alert.py +111 -19
  22. mlrun/common/schemas/api_gateway.py +3 -3
  23. mlrun/common/schemas/artifact.py +11 -7
  24. mlrun/common/schemas/auth.py +6 -4
  25. mlrun/common/schemas/background_task.py +7 -7
  26. mlrun/common/schemas/client_spec.py +2 -3
  27. mlrun/common/schemas/clusterization_spec.py +2 -2
  28. mlrun/common/schemas/common.py +53 -3
  29. mlrun/common/schemas/constants.py +15 -0
  30. mlrun/common/schemas/datastore_profile.py +1 -1
  31. mlrun/common/schemas/feature_store.py +9 -9
  32. mlrun/common/schemas/frontend_spec.py +4 -4
  33. mlrun/common/schemas/function.py +10 -10
  34. mlrun/common/schemas/hub.py +1 -1
  35. mlrun/common/schemas/k8s.py +3 -3
  36. mlrun/common/schemas/memory_reports.py +3 -3
  37. mlrun/common/schemas/model_monitoring/__init__.py +2 -1
  38. mlrun/common/schemas/model_monitoring/constants.py +67 -14
  39. mlrun/common/schemas/model_monitoring/grafana.py +1 -1
  40. mlrun/common/schemas/model_monitoring/model_endpoints.py +92 -147
  41. mlrun/common/schemas/notification.py +24 -3
  42. mlrun/common/schemas/object.py +1 -1
  43. mlrun/common/schemas/pagination.py +4 -4
  44. mlrun/common/schemas/partition.py +137 -0
  45. mlrun/common/schemas/pipeline.py +2 -2
  46. mlrun/common/schemas/project.py +25 -17
  47. mlrun/common/schemas/runs.py +2 -2
  48. mlrun/common/schemas/runtime_resource.py +5 -5
  49. mlrun/common/schemas/schedule.py +1 -1
  50. mlrun/common/schemas/secret.py +1 -1
  51. mlrun/common/schemas/tag.py +3 -3
  52. mlrun/common/schemas/workflow.py +5 -5
  53. mlrun/config.py +68 -10
  54. mlrun/data_types/__init__.py +0 -2
  55. mlrun/data_types/data_types.py +1 -0
  56. mlrun/data_types/infer.py +3 -1
  57. mlrun/data_types/spark.py +5 -3
  58. mlrun/data_types/to_pandas.py +11 -2
  59. mlrun/datastore/__init__.py +2 -2
  60. mlrun/datastore/alibaba_oss.py +4 -1
  61. mlrun/datastore/azure_blob.py +4 -1
  62. mlrun/datastore/base.py +12 -4
  63. mlrun/datastore/datastore.py +9 -3
  64. mlrun/datastore/datastore_profile.py +79 -20
  65. mlrun/datastore/dbfs_store.py +4 -1
  66. mlrun/datastore/filestore.py +4 -1
  67. mlrun/datastore/google_cloud_storage.py +4 -1
  68. mlrun/datastore/hdfs.py +4 -1
  69. mlrun/datastore/inmem.py +4 -1
  70. mlrun/datastore/redis.py +4 -1
  71. mlrun/datastore/s3.py +4 -1
  72. mlrun/datastore/sources.py +52 -51
  73. mlrun/datastore/store_resources.py +7 -4
  74. mlrun/datastore/targets.py +23 -22
  75. mlrun/datastore/utils.py +2 -2
  76. mlrun/datastore/v3io.py +4 -1
  77. mlrun/datastore/vectorstore.py +229 -0
  78. mlrun/datastore/wasbfs/fs.py +13 -12
  79. mlrun/db/base.py +213 -83
  80. mlrun/db/factory.py +0 -3
  81. mlrun/db/httpdb.py +1265 -387
  82. mlrun/db/nopdb.py +205 -74
  83. mlrun/errors.py +2 -2
  84. mlrun/execution.py +136 -50
  85. mlrun/feature_store/__init__.py +0 -2
  86. mlrun/feature_store/api.py +41 -40
  87. mlrun/feature_store/common.py +9 -9
  88. mlrun/feature_store/feature_set.py +20 -18
  89. mlrun/feature_store/feature_vector.py +27 -24
  90. mlrun/feature_store/retrieval/base.py +14 -9
  91. mlrun/feature_store/retrieval/job.py +2 -1
  92. mlrun/feature_store/steps.py +2 -2
  93. mlrun/features.py +30 -13
  94. mlrun/frameworks/__init__.py +1 -2
  95. mlrun/frameworks/_common/__init__.py +1 -2
  96. mlrun/frameworks/_common/artifacts_library.py +2 -2
  97. mlrun/frameworks/_common/mlrun_interface.py +10 -6
  98. mlrun/frameworks/_common/model_handler.py +29 -27
  99. mlrun/frameworks/_common/producer.py +3 -1
  100. mlrun/frameworks/_dl_common/__init__.py +1 -2
  101. mlrun/frameworks/_dl_common/loggers/__init__.py +1 -2
  102. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +4 -4
  103. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +3 -3
  104. mlrun/frameworks/_ml_common/__init__.py +1 -2
  105. mlrun/frameworks/_ml_common/loggers/__init__.py +1 -2
  106. mlrun/frameworks/_ml_common/model_handler.py +21 -21
  107. mlrun/frameworks/_ml_common/plans/__init__.py +1 -2
  108. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +3 -1
  109. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  110. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  111. mlrun/frameworks/auto_mlrun/__init__.py +1 -2
  112. mlrun/frameworks/auto_mlrun/auto_mlrun.py +22 -15
  113. mlrun/frameworks/huggingface/__init__.py +1 -2
  114. mlrun/frameworks/huggingface/model_server.py +9 -9
  115. mlrun/frameworks/lgbm/__init__.py +47 -44
  116. mlrun/frameworks/lgbm/callbacks/__init__.py +1 -2
  117. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -2
  118. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -2
  119. mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -2
  120. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +5 -5
  121. mlrun/frameworks/lgbm/model_handler.py +15 -11
  122. mlrun/frameworks/lgbm/model_server.py +11 -7
  123. mlrun/frameworks/lgbm/utils.py +2 -2
  124. mlrun/frameworks/onnx/__init__.py +1 -2
  125. mlrun/frameworks/onnx/dataset.py +3 -3
  126. mlrun/frameworks/onnx/mlrun_interface.py +2 -2
  127. mlrun/frameworks/onnx/model_handler.py +7 -5
  128. mlrun/frameworks/onnx/model_server.py +8 -6
  129. mlrun/frameworks/parallel_coordinates.py +11 -11
  130. mlrun/frameworks/pytorch/__init__.py +22 -23
  131. mlrun/frameworks/pytorch/callbacks/__init__.py +1 -2
  132. mlrun/frameworks/pytorch/callbacks/callback.py +2 -1
  133. mlrun/frameworks/pytorch/callbacks/logging_callback.py +15 -8
  134. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +19 -12
  135. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +22 -15
  136. mlrun/frameworks/pytorch/callbacks_handler.py +36 -30
  137. mlrun/frameworks/pytorch/mlrun_interface.py +17 -17
  138. mlrun/frameworks/pytorch/model_handler.py +21 -17
  139. mlrun/frameworks/pytorch/model_server.py +13 -9
  140. mlrun/frameworks/sklearn/__init__.py +19 -18
  141. mlrun/frameworks/sklearn/estimator.py +2 -2
  142. mlrun/frameworks/sklearn/metric.py +3 -3
  143. mlrun/frameworks/sklearn/metrics_library.py +8 -6
  144. mlrun/frameworks/sklearn/mlrun_interface.py +3 -2
  145. mlrun/frameworks/sklearn/model_handler.py +4 -3
  146. mlrun/frameworks/tf_keras/__init__.py +11 -12
  147. mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -2
  148. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +17 -14
  149. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +15 -12
  150. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +21 -18
  151. mlrun/frameworks/tf_keras/model_handler.py +17 -13
  152. mlrun/frameworks/tf_keras/model_server.py +12 -8
  153. mlrun/frameworks/xgboost/__init__.py +19 -18
  154. mlrun/frameworks/xgboost/model_handler.py +13 -9
  155. mlrun/launcher/base.py +3 -4
  156. mlrun/launcher/local.py +1 -1
  157. mlrun/launcher/remote.py +1 -1
  158. mlrun/lists.py +4 -3
  159. mlrun/model.py +117 -46
  160. mlrun/model_monitoring/__init__.py +4 -4
  161. mlrun/model_monitoring/api.py +72 -59
  162. mlrun/model_monitoring/applications/_application_steps.py +17 -17
  163. mlrun/model_monitoring/applications/base.py +165 -6
  164. mlrun/model_monitoring/applications/context.py +88 -37
  165. mlrun/model_monitoring/applications/evidently_base.py +0 -1
  166. mlrun/model_monitoring/applications/histogram_data_drift.py +43 -21
  167. mlrun/model_monitoring/applications/results.py +55 -3
  168. mlrun/model_monitoring/controller.py +207 -239
  169. mlrun/model_monitoring/db/__init__.py +0 -2
  170. mlrun/model_monitoring/db/_schedules.py +156 -0
  171. mlrun/model_monitoring/db/_stats.py +189 -0
  172. mlrun/model_monitoring/db/tsdb/base.py +78 -25
  173. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +61 -6
  174. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
  175. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +255 -29
  176. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
  177. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +78 -17
  178. mlrun/model_monitoring/helpers.py +151 -49
  179. mlrun/model_monitoring/stream_processing.py +99 -283
  180. mlrun/model_monitoring/tracking_policy.py +10 -3
  181. mlrun/model_monitoring/writer.py +48 -36
  182. mlrun/package/__init__.py +3 -6
  183. mlrun/package/context_handler.py +1 -1
  184. mlrun/package/packager.py +12 -9
  185. mlrun/package/packagers/__init__.py +0 -2
  186. mlrun/package/packagers/default_packager.py +14 -11
  187. mlrun/package/packagers/numpy_packagers.py +16 -7
  188. mlrun/package/packagers/pandas_packagers.py +18 -18
  189. mlrun/package/packagers/python_standard_library_packagers.py +25 -11
  190. mlrun/package/packagers_manager.py +31 -14
  191. mlrun/package/utils/__init__.py +0 -3
  192. mlrun/package/utils/_pickler.py +6 -6
  193. mlrun/platforms/__init__.py +47 -16
  194. mlrun/platforms/iguazio.py +4 -1
  195. mlrun/projects/operations.py +27 -27
  196. mlrun/projects/pipelines.py +71 -36
  197. mlrun/projects/project.py +890 -220
  198. mlrun/run.py +53 -10
  199. mlrun/runtimes/__init__.py +1 -3
  200. mlrun/runtimes/base.py +15 -11
  201. mlrun/runtimes/daskjob.py +9 -9
  202. mlrun/runtimes/generators.py +2 -1
  203. mlrun/runtimes/kubejob.py +4 -5
  204. mlrun/runtimes/mounts.py +572 -0
  205. mlrun/runtimes/mpijob/__init__.py +0 -2
  206. mlrun/runtimes/mpijob/abstract.py +7 -6
  207. mlrun/runtimes/nuclio/api_gateway.py +7 -7
  208. mlrun/runtimes/nuclio/application/application.py +11 -11
  209. mlrun/runtimes/nuclio/function.py +19 -17
  210. mlrun/runtimes/nuclio/serving.py +18 -13
  211. mlrun/runtimes/pod.py +154 -45
  212. mlrun/runtimes/remotesparkjob.py +3 -2
  213. mlrun/runtimes/sparkjob/__init__.py +0 -2
  214. mlrun/runtimes/sparkjob/spark3job.py +21 -11
  215. mlrun/runtimes/utils.py +6 -5
  216. mlrun/serving/merger.py +6 -4
  217. mlrun/serving/remote.py +18 -17
  218. mlrun/serving/routers.py +185 -172
  219. mlrun/serving/server.py +7 -1
  220. mlrun/serving/states.py +97 -78
  221. mlrun/serving/utils.py +13 -2
  222. mlrun/serving/v1_serving.py +3 -2
  223. mlrun/serving/v2_serving.py +105 -72
  224. mlrun/track/__init__.py +1 -1
  225. mlrun/track/tracker.py +2 -2
  226. mlrun/track/trackers/mlflow_tracker.py +6 -5
  227. mlrun/utils/async_http.py +1 -1
  228. mlrun/utils/clones.py +1 -1
  229. mlrun/utils/helpers.py +63 -19
  230. mlrun/utils/logger.py +106 -4
  231. mlrun/utils/notifications/notification/__init__.py +22 -19
  232. mlrun/utils/notifications/notification/base.py +33 -14
  233. mlrun/utils/notifications/notification/console.py +6 -6
  234. mlrun/utils/notifications/notification/git.py +11 -11
  235. mlrun/utils/notifications/notification/ipython.py +10 -9
  236. mlrun/utils/notifications/notification/mail.py +176 -0
  237. mlrun/utils/notifications/notification/slack.py +6 -6
  238. mlrun/utils/notifications/notification/webhook.py +6 -6
  239. mlrun/utils/notifications/notification_pusher.py +86 -44
  240. mlrun/utils/regex.py +11 -2
  241. mlrun/utils/version/version.json +2 -2
  242. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/METADATA +29 -24
  243. mlrun-1.8.0rc11.dist-info/RECORD +347 -0
  244. mlrun/model_monitoring/db/stores/__init__.py +0 -136
  245. mlrun/model_monitoring/db/stores/base/store.py +0 -213
  246. mlrun/model_monitoring/db/stores/sqldb/__init__.py +0 -13
  247. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -71
  248. mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -190
  249. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +0 -103
  250. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -40
  251. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +0 -659
  252. mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +0 -13
  253. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +0 -726
  254. mlrun/model_monitoring/model_endpoint.py +0 -118
  255. mlrun-1.7.1rc10.dist-info/RECORD +0 -351
  256. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/LICENSE +0 -0
  257. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/WHEEL +0 -0
  258. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/entry_points.txt +0 -0
  259. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/top_level.txt +0 -0
@@ -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, Union
15
+ from typing import Any, Optional, Union
16
16
 
17
17
  import numpy as np
18
18
 
@@ -32,16 +32,20 @@ class LGBMModelServer(V2ModelServer):
32
32
  def __init__(
33
33
  self,
34
34
  context: mlrun.MLClientCtx = None,
35
- name: str = None,
35
+ name: Optional[str] = None,
36
36
  model: LGBMTypes.ModelType = None,
37
37
  model_path: LGBMTypes.PathType = None,
38
- model_name: str = None,
38
+ model_name: Optional[str] = None,
39
39
  model_format: str = LGBMModelHandler.ModelFormats.PKL,
40
- modules_map: Union[dict[str, Union[None, str, list[str]]], str] = None,
41
- custom_objects_map: Union[dict[str, Union[str, list[str]]], str] = None,
42
- custom_objects_directory: str = None,
40
+ modules_map: Optional[
41
+ Union[dict[str, Union[None, str, list[str]]], str]
42
+ ] = None,
43
+ custom_objects_map: Optional[
44
+ Union[dict[str, Union[str, list[str]]], str]
45
+ ] = None,
46
+ custom_objects_directory: Optional[str] = None,
43
47
  to_list: bool = True,
44
- protocol: str = None,
48
+ protocol: Optional[str] = None,
45
49
  **class_args,
46
50
  ):
47
51
  """
@@ -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 lightgbm as lgb
18
18
  import numpy as np
@@ -109,7 +109,7 @@ class LGBMUtils(MLUtils):
109
109
  def get_algorithm_functionality(
110
110
  model: MLTypes.ModelType = None,
111
111
  y: MLTypes.DatasetType = None,
112
- objective: str = None,
112
+ objective: Optional[str] = None,
113
113
  ) -> AlgorithmFunctionality:
114
114
  """
115
115
  Get the algorithm functionality of the LightGBM model. If SciKit-Learn API is used, pass the LGBBMModel and a y
@@ -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 .dataset import ONNXDataset
17
16
  from .model_handler import ONNXModelHandler
18
17
  from .model_server import ONNXModelServer
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  import math
16
- from typing import Callable, Union
16
+ from typing import Callable, Optional, Union
17
17
 
18
18
  import numpy as np
19
19
 
@@ -28,8 +28,8 @@ class ONNXDataset:
28
28
  x: Union[np.ndarray, list[np.ndarray]],
29
29
  y: Union[np.ndarray, list[np.ndarray]] = None,
30
30
  batch_size: int = 1,
31
- x_transforms: list[Callable[[np.ndarray], np.ndarray]] = None,
32
- y_transforms: list[Callable[[np.ndarray], np.ndarray]] = None,
31
+ x_transforms: Optional[list[Callable[[np.ndarray], np.ndarray]]] = None,
32
+ y_transforms: Optional[list[Callable[[np.ndarray], np.ndarray]]] = None,
33
33
  is_batched_transforms: bool = False,
34
34
  ):
35
35
  """
@@ -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 Callable
15
+ from typing import Callable, Optional
16
16
 
17
17
  import numpy as np
18
18
  import onnx
@@ -35,7 +35,7 @@ class ONNXMLRunInterface:
35
35
  def __init__(
36
36
  self,
37
37
  model: onnx.ModelProto,
38
- execution_providers: list[str] = None,
38
+ execution_providers: Optional[list[str]] = None,
39
39
  context: mlrun.MLClientCtx = None,
40
40
  ):
41
41
  # Set the context:
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  import os
16
- from typing import Union
16
+ from typing import Optional, Union
17
17
 
18
18
  import onnx
19
19
  import onnxoptimizer
@@ -35,8 +35,8 @@ class ONNXModelHandler(ModelHandler):
35
35
  def __init__(
36
36
  self,
37
37
  model: onnx.ModelProto = None,
38
- model_path: str = None,
39
- model_name: str = None,
38
+ model_path: Optional[str] = None,
39
+ model_name: Optional[str] = None,
40
40
  context: mlrun.MLClientCtx = None,
41
41
  **kwargs,
42
42
  ):
@@ -70,7 +70,7 @@ class ONNXModelHandler(ModelHandler):
70
70
 
71
71
  # TODO: output_path won't work well with logging artifacts. Need to look into changing the logic of 'log_artifact'.
72
72
  def save(
73
- self, output_path: str = None, **kwargs
73
+ self, output_path: Optional[str] = None, **kwargs
74
74
  ) -> Union[dict[str, Artifact], None]:
75
75
  """
76
76
  Save the handled model at the given output path. If a MLRun context is available, the saved model files will be
@@ -106,7 +106,9 @@ class ONNXModelHandler(ModelHandler):
106
106
  # Load the ONNX model:
107
107
  self._model = onnx.load(self._model_file)
108
108
 
109
- def optimize(self, optimizations: list[str] = None, fixed_point: bool = False):
109
+ def optimize(
110
+ self, optimizations: Optional[list[str]] = None, fixed_point: bool = False
111
+ ):
110
112
  """
111
113
  Use ONNX optimizer to optimize the ONNX model. The optimizations supported can be seen by calling
112
114
  'onnxoptimizer.get_available_passes()'
@@ -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, Union
15
+ from typing import Any, Optional, Union
16
16
 
17
17
  import numpy as np
18
18
  import onnx
@@ -33,12 +33,14 @@ class ONNXModelServer(V2ModelServer):
33
33
  def __init__(
34
34
  self,
35
35
  context: mlrun.MLClientCtx = None,
36
- name: str = None,
36
+ name: Optional[str] = None,
37
37
  model: onnx.ModelProto = None,
38
- model_path: str = None,
39
- model_name: str = None,
40
- execution_providers: list[Union[str, tuple[str, dict[str, Any]]]] = None,
41
- protocol: str = None,
38
+ model_path: Optional[str] = None,
39
+ model_name: Optional[str] = None,
40
+ execution_providers: Optional[
41
+ list[Union[str, tuple[str, dict[str, Any]]]]
42
+ ] = None,
43
+ protocol: Optional[str] = None,
42
44
  **class_args,
43
45
  ):
44
46
  """
@@ -11,10 +11,10 @@
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
- import datetime
14
+
16
15
  import os
17
- from typing import Union
16
+ from datetime import datetime
17
+ from typing import Optional, Union
18
18
 
19
19
  import numpy as np
20
20
  import pandas as pd
@@ -48,7 +48,7 @@ def _gen_dropdown_buttons(output_cols) -> list:
48
48
 
49
49
 
50
50
  def _gen_dimensions(
51
- df: pd.DataFrame, col: str, prefix: str = None, is_index=False
51
+ df: pd.DataFrame, col: str, prefix: Optional[str] = None, is_index=False
52
52
  ) -> dict:
53
53
  """
54
54
  Computes the plotting dimensions of each parameter/output col according to its type.
@@ -107,8 +107,8 @@ def gen_pcp_plot(
107
107
  source_df: pd.DataFrame,
108
108
  index_col: str,
109
109
  hide_identical: bool = True,
110
- exclude: list = None,
111
- colorscale: str = None,
110
+ exclude: Optional[list] = None,
111
+ colorscale: Optional[str] = None,
112
112
  ):
113
113
  """
114
114
  Creates a list composed of the data to be plotted as a Parallel Coordinate, this includes
@@ -240,11 +240,11 @@ def _runs_list_to_df(runs_list, extend_iterations=False):
240
240
  def compare_run_objects(
241
241
  runs_list: Union[mlrun.model.RunObject, list[mlrun.model.RunObject]],
242
242
  hide_identical: bool = True,
243
- exclude: list = None,
244
- show: bool = None,
243
+ exclude: Optional[list] = None,
244
+ show: Optional[bool] = None,
245
245
  extend_iterations=True,
246
246
  filename=None,
247
- colorscale: str = None,
247
+ colorscale: Optional[str] = None,
248
248
  ):
249
249
  """return/show parallel coordinates plot + table to compare between a list of runs or run iterations
250
250
 
@@ -292,9 +292,9 @@ def compare_db_runs(
292
292
  run_name=None,
293
293
  labels=None,
294
294
  iter=False,
295
- start_time_from: datetime = None,
295
+ start_time_from: Optional[datetime] = None,
296
296
  hide_identical: bool = True,
297
- exclude: list = None,
297
+ exclude: Optional[list] = None,
298
298
  show=None,
299
299
  colorscale: str = "Blues",
300
300
  filename=None,
@@ -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 Any, Union
14
+
15
+ from typing import Any, Optional, Union
17
16
 
18
17
  from torch.nn import Module
19
18
  from torch.optim import Optimizer
@@ -35,23 +34,23 @@ def train(
35
34
  loss_function: Module,
36
35
  optimizer: Optimizer,
37
36
  validation_set: DataLoader = None,
38
- metric_functions: list[PyTorchTypes.MetricFunctionType] = None,
37
+ metric_functions: Optional[list[PyTorchTypes.MetricFunctionType]] = None,
39
38
  scheduler=None,
40
39
  scheduler_step_frequency: Union[int, float, str] = "epoch",
41
40
  epochs: int = 1,
42
- training_iterations: int = None,
43
- validation_iterations: int = None,
44
- callbacks_list: list[Callback] = None,
41
+ training_iterations: Optional[int] = None,
42
+ validation_iterations: Optional[int] = None,
43
+ callbacks_list: Optional[list[Callback]] = None,
45
44
  use_cuda: bool = True,
46
- use_horovod: bool = None,
45
+ use_horovod: Optional[bool] = None,
47
46
  auto_log: bool = True,
48
- model_name: str = None,
49
- modules_map: Union[dict[str, Union[None, str, list[str]]], str] = None,
50
- custom_objects_map: Union[dict[str, Union[str, list[str]]], str] = None,
51
- custom_objects_directory: str = None,
52
- tensorboard_directory: str = None,
53
- mlrun_callback_kwargs: dict[str, Any] = None,
54
- tensorboard_callback_kwargs: dict[str, Any] = None,
47
+ model_name: Optional[str] = None,
48
+ modules_map: Optional[Union[dict[str, Union[None, str, list[str]]], str]] = None,
49
+ custom_objects_map: Optional[Union[dict[str, Union[str, list[str]]], str]] = None,
50
+ custom_objects_directory: Optional[str] = None,
51
+ tensorboard_directory: Optional[str] = None,
52
+ mlrun_callback_kwargs: Optional[dict[str, Any]] = None,
53
+ tensorboard_callback_kwargs: Optional[dict[str, Any]] = None,
55
54
  context: mlrun.MLClientCtx = None,
56
55
  ) -> PyTorchModelHandler:
57
56
  """
@@ -205,17 +204,17 @@ def evaluate(
205
204
  dataset: DataLoader,
206
205
  model: Module = None,
207
206
  loss_function: Module = None,
208
- metric_functions: list[PyTorchTypes.MetricFunctionType] = None,
209
- iterations: int = None,
210
- callbacks_list: list[Callback] = None,
207
+ metric_functions: Optional[list[PyTorchTypes.MetricFunctionType]] = None,
208
+ iterations: Optional[int] = None,
209
+ callbacks_list: Optional[list[Callback]] = None,
211
210
  use_cuda: bool = True,
212
211
  use_horovod: bool = False,
213
212
  auto_log: bool = True,
214
- model_name: str = None,
215
- modules_map: Union[dict[str, Union[None, str, list[str]]], str] = None,
216
- custom_objects_map: Union[dict[str, Union[str, list[str]]], str] = None,
217
- custom_objects_directory: str = None,
218
- mlrun_callback_kwargs: dict[str, Any] = None,
213
+ model_name: Optional[str] = None,
214
+ modules_map: Optional[Union[dict[str, Union[None, str, list[str]]], str]] = None,
215
+ custom_objects_map: Optional[Union[dict[str, Union[str, list[str]]], str]] = None,
216
+ custom_objects_directory: Optional[str] = None,
217
+ mlrun_callback_kwargs: Optional[dict[str, Any]] = None,
219
218
  context: mlrun.MLClientCtx = None,
220
219
  ) -> tuple[PyTorchModelHandler, list[PyTorchTypes.MetricValueType]]:
221
220
  """
@@ -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 .callback import Callback
17
16
  from .logging_callback import HyperparametersKeys, LoggingCallback
18
17
  from .mlrun_logging_callback import MLRunLoggingCallback
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  from abc import ABC, abstractmethod
16
+ from typing import Optional
16
17
 
17
18
  from torch import Tensor
18
19
  from torch.nn import Module
@@ -67,7 +68,7 @@ class Callback(ABC):
67
68
  validation_set: DataLoader = None,
68
69
  loss_function: Module = None,
69
70
  optimizer: Optimizer = None,
70
- metric_functions: list[PyTorchTypes.MetricFunctionType] = None,
71
+ metric_functions: Optional[list[PyTorchTypes.MetricFunctionType]] = None,
71
72
  scheduler=None,
72
73
  ):
73
74
  """
@@ -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 Callable, Union
15
+ from typing import Callable, Optional, Union
16
16
 
17
17
  import numpy as np
18
18
  from torch import Tensor
@@ -59,15 +59,22 @@ class LoggingCallback(Callback):
59
59
  def __init__(
60
60
  self,
61
61
  context: mlrun.MLClientCtx = None,
62
- dynamic_hyperparameters: dict[
63
- str,
64
- tuple[
62
+ dynamic_hyperparameters: Optional[
63
+ dict[
65
64
  str,
66
- Union[list[Union[str, int]], Callable[[], PyTorchTypes.TrackableType]],
67
- ],
65
+ tuple[
66
+ str,
67
+ Union[
68
+ list[Union[str, int]], Callable[[], PyTorchTypes.TrackableType]
69
+ ],
70
+ ],
71
+ ]
68
72
  ] = None,
69
- static_hyperparameters: dict[
70
- str, Union[PyTorchTypes.TrackableType, tuple[str, list[Union[str, int]]]]
73
+ static_hyperparameters: Optional[
74
+ dict[
75
+ str,
76
+ Union[PyTorchTypes.TrackableType, tuple[str, list[Union[str, int]]]],
77
+ ]
71
78
  ] = None,
72
79
  auto_log: bool = False,
73
80
  ):
@@ -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 Callable, Union
15
+ from typing import Callable, Optional, Union
16
16
 
17
17
  import torch
18
18
  from torch import Tensor
@@ -53,20 +53,27 @@ class MLRunLoggingCallback(LoggingCallback):
53
53
  context: mlrun.MLClientCtx,
54
54
  model_handler: PyTorchModelHandler,
55
55
  log_model_tag: str = "",
56
- log_model_labels: dict[str, PyTorchTypes.TrackableType] = None,
57
- log_model_parameters: dict[str, PyTorchTypes.TrackableType] = None,
58
- log_model_extra_data: dict[
59
- str, Union[PyTorchTypes.TrackableType, Artifact]
56
+ log_model_labels: Optional[dict[str, PyTorchTypes.TrackableType]] = None,
57
+ log_model_parameters: Optional[dict[str, PyTorchTypes.TrackableType]] = None,
58
+ log_model_extra_data: Optional[
59
+ dict[str, Union[PyTorchTypes.TrackableType, Artifact]]
60
60
  ] = None,
61
- dynamic_hyperparameters: dict[
62
- str,
63
- tuple[
61
+ dynamic_hyperparameters: Optional[
62
+ dict[
64
63
  str,
65
- Union[list[Union[str, int]], Callable[[], PyTorchTypes.TrackableType]],
66
- ],
64
+ tuple[
65
+ str,
66
+ Union[
67
+ list[Union[str, int]], Callable[[], PyTorchTypes.TrackableType]
68
+ ],
69
+ ],
70
+ ]
67
71
  ] = None,
68
- static_hyperparameters: dict[
69
- str, Union[PyTorchTypes.TrackableType, tuple[str, list[Union[str, int]]]]
72
+ static_hyperparameters: Optional[
73
+ dict[
74
+ str,
75
+ Union[PyTorchTypes.TrackableType, tuple[str, list[Union[str, int]]]],
76
+ ]
70
77
  ] = None,
71
78
  auto_log: bool = False,
72
79
  ):
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  from datetime import datetime
16
- from typing import Callable, Union
16
+ from typing import Callable, Optional, Union
17
17
 
18
18
  import torch
19
19
  from torch import Tensor
@@ -67,8 +67,8 @@ class _PyTorchTensorboardLogger(TensorboardLogger):
67
67
  Callable[[Union[Parameter]], Union[float, Parameter]]
68
68
  ],
69
69
  context: mlrun.MLClientCtx = None,
70
- tensorboard_directory: str = None,
71
- run_name: str = None,
70
+ tensorboard_directory: Optional[str] = None,
71
+ run_name: Optional[str] = None,
72
72
  update_frequency: Union[int, str] = "epoch",
73
73
  ):
74
74
  """
@@ -247,21 +247,28 @@ class TensorboardLoggingCallback(LoggingCallback):
247
247
  def __init__(
248
248
  self,
249
249
  context: mlrun.MLClientCtx = None,
250
- tensorboard_directory: str = None,
251
- run_name: str = None,
250
+ tensorboard_directory: Optional[str] = None,
251
+ run_name: Optional[str] = None,
252
252
  weights: Union[bool, list[str]] = False,
253
- statistics_functions: list[
254
- Callable[[Union[Parameter, Tensor]], Union[float, Tensor]]
253
+ statistics_functions: Optional[
254
+ list[Callable[[Union[Parameter, Tensor]], Union[float, Tensor]]]
255
255
  ] = None,
256
- dynamic_hyperparameters: dict[
257
- str,
258
- tuple[
256
+ dynamic_hyperparameters: Optional[
257
+ dict[
259
258
  str,
260
- Union[list[Union[str, int]], Callable[[], PyTorchTypes.TrackableType]],
261
- ],
259
+ tuple[
260
+ str,
261
+ Union[
262
+ list[Union[str, int]], Callable[[], PyTorchTypes.TrackableType]
263
+ ],
264
+ ],
265
+ ]
262
266
  ] = None,
263
- static_hyperparameters: dict[
264
- str, Union[PyTorchTypes.TrackableType, tuple[str, list[Union[str, int]]]]
267
+ static_hyperparameters: Optional[
268
+ dict[
269
+ str,
270
+ Union[PyTorchTypes.TrackableType, tuple[str, list[Union[str, int]]]],
271
+ ]
265
272
  ] = None,
266
273
  update_frequency: Union[int, str] = "epoch",
267
274
  auto_log: bool = False,
@@ -381,7 +388,7 @@ class TensorboardLoggingCallback(LoggingCallback):
381
388
  validation_set: DataLoader = None,
382
389
  loss_function: Module = None,
383
390
  optimizer: Optimizer = None,
384
- metric_functions: list[PyTorchTypes.MetricFunctionType] = None,
391
+ metric_functions: Optional[list[PyTorchTypes.MetricFunctionType]] = None,
385
392
  scheduler=None,
386
393
  ):
387
394
  """