mlrun 1.7.2rc3__py3-none-any.whl → 1.8.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 (250) hide show
  1. mlrun/__init__.py +18 -18
  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/formatters/project.py +9 -0
  16. mlrun/common/model_monitoring/__init__.py +0 -3
  17. mlrun/common/model_monitoring/helpers.py +1 -1
  18. mlrun/common/runtimes/constants.py +1 -2
  19. mlrun/common/schemas/__init__.py +7 -2
  20. mlrun/common/schemas/alert.py +31 -18
  21. mlrun/common/schemas/api_gateway.py +3 -3
  22. mlrun/common/schemas/artifact.py +7 -13
  23. mlrun/common/schemas/auth.py +6 -4
  24. mlrun/common/schemas/background_task.py +7 -7
  25. mlrun/common/schemas/client_spec.py +2 -2
  26. mlrun/common/schemas/clusterization_spec.py +2 -2
  27. mlrun/common/schemas/common.py +53 -3
  28. mlrun/common/schemas/datastore_profile.py +1 -1
  29. mlrun/common/schemas/feature_store.py +9 -9
  30. mlrun/common/schemas/frontend_spec.py +4 -4
  31. mlrun/common/schemas/function.py +10 -10
  32. mlrun/common/schemas/hub.py +1 -1
  33. mlrun/common/schemas/k8s.py +3 -3
  34. mlrun/common/schemas/memory_reports.py +3 -3
  35. mlrun/common/schemas/model_monitoring/__init__.py +8 -1
  36. mlrun/common/schemas/model_monitoring/constants.py +62 -12
  37. mlrun/common/schemas/model_monitoring/grafana.py +1 -1
  38. mlrun/common/schemas/model_monitoring/model_endpoint_v2.py +149 -0
  39. mlrun/common/schemas/model_monitoring/model_endpoints.py +22 -6
  40. mlrun/common/schemas/notification.py +18 -3
  41. mlrun/common/schemas/object.py +1 -1
  42. mlrun/common/schemas/pagination.py +4 -4
  43. mlrun/common/schemas/partition.py +137 -0
  44. mlrun/common/schemas/pipeline.py +2 -2
  45. mlrun/common/schemas/project.py +22 -17
  46. mlrun/common/schemas/runs.py +2 -2
  47. mlrun/common/schemas/runtime_resource.py +5 -5
  48. mlrun/common/schemas/schedule.py +1 -1
  49. mlrun/common/schemas/secret.py +1 -1
  50. mlrun/common/schemas/tag.py +3 -3
  51. mlrun/common/schemas/workflow.py +5 -5
  52. mlrun/config.py +65 -15
  53. mlrun/data_types/__init__.py +0 -2
  54. mlrun/data_types/data_types.py +0 -1
  55. mlrun/data_types/infer.py +3 -1
  56. mlrun/data_types/spark.py +4 -4
  57. mlrun/data_types/to_pandas.py +2 -11
  58. mlrun/datastore/__init__.py +0 -2
  59. mlrun/datastore/alibaba_oss.py +4 -1
  60. mlrun/datastore/azure_blob.py +4 -1
  61. mlrun/datastore/base.py +12 -4
  62. mlrun/datastore/datastore.py +9 -3
  63. mlrun/datastore/datastore_profile.py +20 -20
  64. mlrun/datastore/dbfs_store.py +4 -1
  65. mlrun/datastore/filestore.py +4 -1
  66. mlrun/datastore/google_cloud_storage.py +4 -1
  67. mlrun/datastore/hdfs.py +4 -1
  68. mlrun/datastore/inmem.py +4 -1
  69. mlrun/datastore/redis.py +4 -1
  70. mlrun/datastore/s3.py +4 -1
  71. mlrun/datastore/sources.py +51 -49
  72. mlrun/datastore/store_resources.py +0 -2
  73. mlrun/datastore/targets.py +22 -23
  74. mlrun/datastore/utils.py +2 -2
  75. mlrun/datastore/v3io.py +4 -1
  76. mlrun/datastore/wasbfs/fs.py +13 -12
  77. mlrun/db/base.py +170 -64
  78. mlrun/db/factory.py +3 -0
  79. mlrun/db/httpdb.py +986 -238
  80. mlrun/db/nopdb.py +155 -57
  81. mlrun/errors.py +2 -2
  82. mlrun/execution.py +55 -29
  83. mlrun/feature_store/__init__.py +0 -2
  84. mlrun/feature_store/api.py +40 -40
  85. mlrun/feature_store/common.py +9 -9
  86. mlrun/feature_store/feature_set.py +20 -18
  87. mlrun/feature_store/feature_vector.py +27 -24
  88. mlrun/feature_store/retrieval/base.py +14 -9
  89. mlrun/feature_store/retrieval/job.py +2 -1
  90. mlrun/feature_store/steps.py +2 -2
  91. mlrun/features.py +30 -13
  92. mlrun/frameworks/__init__.py +1 -2
  93. mlrun/frameworks/_common/__init__.py +1 -2
  94. mlrun/frameworks/_common/artifacts_library.py +2 -2
  95. mlrun/frameworks/_common/mlrun_interface.py +10 -6
  96. mlrun/frameworks/_common/model_handler.py +29 -27
  97. mlrun/frameworks/_common/producer.py +3 -1
  98. mlrun/frameworks/_dl_common/__init__.py +1 -2
  99. mlrun/frameworks/_dl_common/loggers/__init__.py +1 -2
  100. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +4 -4
  101. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +3 -3
  102. mlrun/frameworks/_ml_common/__init__.py +1 -2
  103. mlrun/frameworks/_ml_common/loggers/__init__.py +1 -2
  104. mlrun/frameworks/_ml_common/model_handler.py +21 -21
  105. mlrun/frameworks/_ml_common/plans/__init__.py +1 -2
  106. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +3 -1
  107. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  108. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  109. mlrun/frameworks/auto_mlrun/__init__.py +1 -2
  110. mlrun/frameworks/auto_mlrun/auto_mlrun.py +22 -15
  111. mlrun/frameworks/huggingface/__init__.py +1 -2
  112. mlrun/frameworks/huggingface/model_server.py +9 -9
  113. mlrun/frameworks/lgbm/__init__.py +47 -44
  114. mlrun/frameworks/lgbm/callbacks/__init__.py +1 -2
  115. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -2
  116. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -2
  117. mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -2
  118. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +5 -5
  119. mlrun/frameworks/lgbm/model_handler.py +15 -11
  120. mlrun/frameworks/lgbm/model_server.py +11 -7
  121. mlrun/frameworks/lgbm/utils.py +2 -2
  122. mlrun/frameworks/onnx/__init__.py +1 -2
  123. mlrun/frameworks/onnx/dataset.py +3 -3
  124. mlrun/frameworks/onnx/mlrun_interface.py +2 -2
  125. mlrun/frameworks/onnx/model_handler.py +7 -5
  126. mlrun/frameworks/onnx/model_server.py +8 -6
  127. mlrun/frameworks/parallel_coordinates.py +11 -11
  128. mlrun/frameworks/pytorch/__init__.py +22 -23
  129. mlrun/frameworks/pytorch/callbacks/__init__.py +1 -2
  130. mlrun/frameworks/pytorch/callbacks/callback.py +2 -1
  131. mlrun/frameworks/pytorch/callbacks/logging_callback.py +15 -8
  132. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +19 -12
  133. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +22 -15
  134. mlrun/frameworks/pytorch/callbacks_handler.py +36 -30
  135. mlrun/frameworks/pytorch/mlrun_interface.py +17 -17
  136. mlrun/frameworks/pytorch/model_handler.py +21 -17
  137. mlrun/frameworks/pytorch/model_server.py +13 -9
  138. mlrun/frameworks/sklearn/__init__.py +19 -18
  139. mlrun/frameworks/sklearn/estimator.py +2 -2
  140. mlrun/frameworks/sklearn/metric.py +3 -3
  141. mlrun/frameworks/sklearn/metrics_library.py +8 -6
  142. mlrun/frameworks/sklearn/mlrun_interface.py +3 -2
  143. mlrun/frameworks/sklearn/model_handler.py +4 -3
  144. mlrun/frameworks/tf_keras/__init__.py +11 -12
  145. mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -2
  146. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +17 -14
  147. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +15 -12
  148. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +21 -18
  149. mlrun/frameworks/tf_keras/model_handler.py +17 -13
  150. mlrun/frameworks/tf_keras/model_server.py +12 -8
  151. mlrun/frameworks/xgboost/__init__.py +19 -18
  152. mlrun/frameworks/xgboost/model_handler.py +13 -9
  153. mlrun/launcher/base.py +3 -4
  154. mlrun/launcher/local.py +1 -1
  155. mlrun/launcher/remote.py +1 -1
  156. mlrun/lists.py +4 -3
  157. mlrun/model.py +110 -46
  158. mlrun/model_monitoring/__init__.py +1 -2
  159. mlrun/model_monitoring/api.py +6 -6
  160. mlrun/model_monitoring/applications/_application_steps.py +13 -15
  161. mlrun/model_monitoring/applications/histogram_data_drift.py +41 -15
  162. mlrun/model_monitoring/applications/results.py +55 -3
  163. mlrun/model_monitoring/controller.py +185 -223
  164. mlrun/model_monitoring/db/_schedules.py +156 -0
  165. mlrun/model_monitoring/db/_stats.py +189 -0
  166. mlrun/model_monitoring/db/stores/__init__.py +1 -1
  167. mlrun/model_monitoring/db/stores/base/store.py +6 -65
  168. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -25
  169. mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -97
  170. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +2 -58
  171. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -15
  172. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +6 -257
  173. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +9 -271
  174. mlrun/model_monitoring/db/tsdb/base.py +76 -24
  175. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +61 -6
  176. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
  177. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +253 -28
  178. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
  179. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +35 -17
  180. mlrun/model_monitoring/helpers.py +91 -1
  181. mlrun/model_monitoring/model_endpoint.py +4 -2
  182. mlrun/model_monitoring/stream_processing.py +16 -13
  183. mlrun/model_monitoring/tracking_policy.py +10 -3
  184. mlrun/model_monitoring/writer.py +47 -26
  185. mlrun/package/__init__.py +3 -6
  186. mlrun/package/context_handler.py +1 -1
  187. mlrun/package/packager.py +12 -9
  188. mlrun/package/packagers/__init__.py +0 -2
  189. mlrun/package/packagers/default_packager.py +14 -11
  190. mlrun/package/packagers/numpy_packagers.py +16 -7
  191. mlrun/package/packagers/pandas_packagers.py +18 -18
  192. mlrun/package/packagers/python_standard_library_packagers.py +25 -11
  193. mlrun/package/packagers_manager.py +31 -14
  194. mlrun/package/utils/__init__.py +0 -3
  195. mlrun/package/utils/_pickler.py +6 -6
  196. mlrun/platforms/__init__.py +3 -16
  197. mlrun/platforms/iguazio.py +4 -1
  198. mlrun/projects/operations.py +27 -27
  199. mlrun/projects/pipelines.py +34 -35
  200. mlrun/projects/project.py +535 -182
  201. mlrun/run.py +13 -10
  202. mlrun/runtimes/__init__.py +1 -3
  203. mlrun/runtimes/base.py +15 -11
  204. mlrun/runtimes/daskjob.py +9 -9
  205. mlrun/runtimes/generators.py +2 -1
  206. mlrun/runtimes/kubejob.py +4 -5
  207. mlrun/runtimes/mounts.py +572 -0
  208. mlrun/runtimes/mpijob/__init__.py +0 -2
  209. mlrun/runtimes/mpijob/abstract.py +7 -6
  210. mlrun/runtimes/nuclio/api_gateway.py +7 -7
  211. mlrun/runtimes/nuclio/application/application.py +11 -11
  212. mlrun/runtimes/nuclio/function.py +13 -13
  213. mlrun/runtimes/nuclio/serving.py +9 -9
  214. mlrun/runtimes/pod.py +154 -45
  215. mlrun/runtimes/remotesparkjob.py +3 -2
  216. mlrun/runtimes/sparkjob/__init__.py +0 -2
  217. mlrun/runtimes/sparkjob/spark3job.py +21 -11
  218. mlrun/runtimes/utils.py +6 -5
  219. mlrun/serving/merger.py +6 -4
  220. mlrun/serving/remote.py +18 -17
  221. mlrun/serving/routers.py +27 -27
  222. mlrun/serving/server.py +1 -1
  223. mlrun/serving/states.py +76 -71
  224. mlrun/serving/utils.py +13 -2
  225. mlrun/serving/v1_serving.py +3 -2
  226. mlrun/serving/v2_serving.py +4 -4
  227. mlrun/track/__init__.py +1 -1
  228. mlrun/track/tracker.py +2 -2
  229. mlrun/track/trackers/mlflow_tracker.py +6 -5
  230. mlrun/utils/async_http.py +1 -1
  231. mlrun/utils/helpers.py +70 -16
  232. mlrun/utils/logger.py +106 -4
  233. mlrun/utils/notifications/notification/__init__.py +22 -19
  234. mlrun/utils/notifications/notification/base.py +33 -14
  235. mlrun/utils/notifications/notification/console.py +6 -6
  236. mlrun/utils/notifications/notification/git.py +11 -11
  237. mlrun/utils/notifications/notification/ipython.py +10 -9
  238. mlrun/utils/notifications/notification/mail.py +149 -0
  239. mlrun/utils/notifications/notification/slack.py +6 -6
  240. mlrun/utils/notifications/notification/webhook.py +18 -22
  241. mlrun/utils/notifications/notification_pusher.py +43 -31
  242. mlrun/utils/regex.py +3 -1
  243. mlrun/utils/version/version.json +2 -2
  244. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/METADATA +18 -14
  245. mlrun-1.8.0rc2.dist-info/RECORD +358 -0
  246. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/WHEEL +1 -1
  247. mlrun-1.7.2rc3.dist-info/RECORD +0 -351
  248. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/LICENSE +0 -0
  249. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/entry_points.txt +0 -0
  250. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/top_level.txt +0 -0
mlrun/runtimes/utils.py CHANGED
@@ -18,6 +18,7 @@ import os
18
18
  import re
19
19
  from io import StringIO
20
20
  from sys import stderr
21
+ from typing import Optional
21
22
 
22
23
  import pandas as pd
23
24
 
@@ -147,7 +148,7 @@ def add_code_metadata(path=""):
147
148
 
148
149
  def results_to_iter(results, runspec, execution):
149
150
  if not results:
150
- logger.error("got an empty results list in to_iter")
151
+ logger.error("Got an empty results list in to_iter")
151
152
  return
152
153
 
153
154
  iter = []
@@ -174,7 +175,7 @@ def results_to_iter(results, runspec, execution):
174
175
 
175
176
  if not iter:
176
177
  execution.set_state("completed", commit=True)
177
- logger.warning("warning!, zero iteration results")
178
+ logger.warning("Warning!, zero iteration results")
178
179
  return
179
180
  if hasattr(pd, "json_normalize"):
180
181
  df = pd.json_normalize(iter).sort_values("iter")
@@ -189,10 +190,10 @@ def results_to_iter(results, runspec, execution):
189
190
  item, id = selector(results, criteria)
190
191
  if runspec.spec.selector and not id:
191
192
  logger.warning(
192
- f"no best result selected, check selector ({criteria}) or results"
193
+ f"No best result selected, check selector ({criteria}) or results"
193
194
  )
194
195
  if id:
195
- logger.info(f"best iteration={id}, used criteria {criteria}")
196
+ logger.info(f"Best iteration={id}, used criteria {criteria}")
196
197
  task = results[item] if id and results else None
197
198
  execution.log_iteration_results(id, summary, task)
198
199
 
@@ -432,7 +433,7 @@ def enrich_function_from_dict(function, function_dict):
432
433
 
433
434
  def enrich_run_labels(
434
435
  labels: dict,
435
- labels_to_enrich: list[RunLabels] = None,
436
+ labels_to_enrich: Optional[list[RunLabels]] = None,
436
437
  ):
437
438
  labels_enrichment = {
438
439
  RunLabels.owner: os.environ.get("V3IO_USERNAME") or getpass.getuser(),
mlrun/serving/merger.py CHANGED
@@ -13,6 +13,8 @@
13
13
  # limitations under the License.
14
14
  #
15
15
 
16
+ from typing import Optional
17
+
16
18
  import storey
17
19
 
18
20
 
@@ -37,10 +39,10 @@ class CacheEntry:
37
39
  class Merge(storey.Flow):
38
40
  def __init__(
39
41
  self,
40
- full_event: bool = None,
41
- key_path: str = None,
42
- max_behind: int = None,
43
- expected_num_events: int = None,
42
+ full_event: Optional[bool] = None,
43
+ key_path: Optional[str] = None,
44
+ max_behind: Optional[int] = None,
45
+ expected_num_events: Optional[int] = None,
44
46
  **kwargs,
45
47
  ):
46
48
  """Merge multiple events based on event id or provided key path
mlrun/serving/remote.py CHANGED
@@ -14,6 +14,7 @@
14
14
  #
15
15
  import asyncio
16
16
  import json
17
+ from typing import Optional
17
18
 
18
19
  import aiohttp
19
20
  import requests
@@ -40,14 +41,14 @@ class RemoteStep(storey.SendToHttp):
40
41
  def __init__(
41
42
  self,
42
43
  url: str,
43
- subpath: str = None,
44
- method: str = None,
45
- headers: dict = None,
46
- url_expression: str = None,
47
- body_expression: str = None,
44
+ subpath: Optional[str] = None,
45
+ method: Optional[str] = None,
46
+ headers: Optional[dict] = None,
47
+ url_expression: Optional[str] = None,
48
+ body_expression: Optional[str] = None,
48
49
  return_json: bool = True,
49
- input_path: str = None,
50
- result_path: str = None,
50
+ input_path: Optional[str] = None,
51
+ result_path: Optional[str] = None,
51
52
  max_in_flight=None,
52
53
  retries=None,
53
54
  backoff_factor=None,
@@ -57,7 +58,7 @@ class RemoteStep(storey.SendToHttp):
57
58
  """class for calling remote endpoints
58
59
 
59
60
  sync and async graph step implementation for request/resp to remote service (class shortcut = "$remote")
60
- url can be an http(s) url (e.g. "https://myservice/path") or an mlrun function uri ([project/]name).
61
+ url can be an http(s) url (e.g. `https://myservice/path`) or an mlrun function uri ([project/]name).
61
62
  alternatively the url_expression can be specified to build the url from the event (e.g. "event['url']").
62
63
 
63
64
  example pipeline::
@@ -241,15 +242,15 @@ class RemoteStep(storey.SendToHttp):
241
242
  class BatchHttpRequests(_ConcurrentJobExecution):
242
243
  def __init__(
243
244
  self,
244
- url: str = None,
245
- subpath: str = None,
246
- method: str = None,
247
- headers: dict = None,
248
- url_expression: str = None,
249
- body_expression: str = None,
245
+ url: Optional[str] = None,
246
+ subpath: Optional[str] = None,
247
+ method: Optional[str] = None,
248
+ headers: Optional[dict] = None,
249
+ url_expression: Optional[str] = None,
250
+ body_expression: Optional[str] = None,
250
251
  return_json: bool = True,
251
- input_path: str = None,
252
- result_path: str = None,
252
+ input_path: Optional[str] = None,
253
+ result_path: Optional[str] = None,
253
254
  retries=None,
254
255
  backoff_factor=None,
255
256
  timeout=None,
@@ -258,7 +259,7 @@ class BatchHttpRequests(_ConcurrentJobExecution):
258
259
  """class for calling remote endpoints in parallel
259
260
 
260
261
  sync and async graph step implementation for request/resp to remote service (class shortcut = "$remote")
261
- url can be an http(s) url (e.g. "https://myservice/path") or an mlrun function uri ([project/]name).
262
+ url can be an http(s) url (e.g. `https://myservice/path`) or an mlrun function uri ([project/]name).
262
263
  alternatively the url_expression can be specified to build the url from the event (e.g. "event['url']").
263
264
 
264
265
  example pipeline::
mlrun/serving/routers.py CHANGED
@@ -46,13 +46,13 @@ class BaseModelRouter(RouterToDict):
46
46
  def __init__(
47
47
  self,
48
48
  context=None,
49
- name: str = None,
49
+ name: typing.Optional[str] = None,
50
50
  routes=None,
51
- protocol: str = None,
52
- url_prefix: str = None,
53
- health_prefix: str = None,
54
- input_path: str = None,
55
- result_path: str = None,
51
+ protocol: typing.Optional[str] = None,
52
+ url_prefix: typing.Optional[str] = None,
53
+ health_prefix: typing.Optional[str] = None,
54
+ input_path: typing.Optional[str] = None,
55
+ result_path: typing.Optional[str] = None,
56
56
  **kwargs,
57
57
  ):
58
58
  """Model Serving Router, route between child models
@@ -249,11 +249,11 @@ class ParallelRun(BaseModelRouter):
249
249
  def __init__(
250
250
  self,
251
251
  context=None,
252
- name: str = None,
252
+ name: typing.Optional[str] = None,
253
253
  routes=None,
254
- protocol: str = None,
255
- url_prefix: str = None,
256
- health_prefix: str = None,
254
+ protocol: typing.Optional[str] = None,
255
+ url_prefix: typing.Optional[str] = None,
256
+ health_prefix: typing.Optional[str] = None,
257
257
  extend_event=None,
258
258
  executor_type: Union[ParallelRunnerModes, str] = ParallelRunnerModes.thread,
259
259
  **kwargs,
@@ -481,13 +481,13 @@ class VotingEnsemble(ParallelRun):
481
481
  def __init__(
482
482
  self,
483
483
  context=None,
484
- name: str = None,
484
+ name: typing.Optional[str] = None,
485
485
  routes=None,
486
- protocol: str = None,
487
- url_prefix: str = None,
488
- health_prefix: str = None,
489
- vote_type: str = None,
490
- weights: dict[str, float] = None,
486
+ protocol: typing.Optional[str] = None,
487
+ url_prefix: typing.Optional[str] = None,
488
+ health_prefix: typing.Optional[str] = None,
489
+ vote_type: typing.Optional[str] = None,
490
+ weights: typing.Optional[dict[str, float]] = None,
491
491
  executor_type: Union[ParallelRunnerModes, str] = ParallelRunnerModes.thread,
492
492
  format_response_with_col_name_flag: bool = False,
493
493
  prediction_col_name: str = "prediction",
@@ -1130,13 +1130,13 @@ class EnrichmentModelRouter(ModelRouter):
1130
1130
  def __init__(
1131
1131
  self,
1132
1132
  context=None,
1133
- name: str = None,
1133
+ name: typing.Optional[str] = None,
1134
1134
  routes=None,
1135
- protocol: str = None,
1136
- url_prefix: str = None,
1137
- health_prefix: str = None,
1135
+ protocol: typing.Optional[str] = None,
1136
+ url_prefix: typing.Optional[str] = None,
1137
+ health_prefix: typing.Optional[str] = None,
1138
1138
  feature_vector_uri: str = "",
1139
- impute_policy: dict = None,
1139
+ impute_policy: typing.Optional[dict] = None,
1140
1140
  **kwargs,
1141
1141
  ):
1142
1142
  """Model router with feature enrichment (from the feature store)
@@ -1211,16 +1211,16 @@ class EnrichmentVotingEnsemble(VotingEnsemble):
1211
1211
  def __init__(
1212
1212
  self,
1213
1213
  context=None,
1214
- name: str = None,
1214
+ name: typing.Optional[str] = None,
1215
1215
  routes=None,
1216
1216
  protocol=None,
1217
- url_prefix: str = None,
1218
- health_prefix: str = None,
1219
- vote_type: str = None,
1217
+ url_prefix: typing.Optional[str] = None,
1218
+ health_prefix: typing.Optional[str] = None,
1219
+ vote_type: typing.Optional[str] = None,
1220
1220
  executor_type: Union[ParallelRunnerModes, str] = ParallelRunnerModes.thread,
1221
- prediction_col_name: str = None,
1221
+ prediction_col_name: typing.Optional[str] = None,
1222
1222
  feature_vector_uri: str = "",
1223
- impute_policy: dict = None,
1223
+ impute_policy: typing.Optional[dict] = None,
1224
1224
  **kwargs,
1225
1225
  ):
1226
1226
  """Voting Ensemble with feature enrichment (from the feature store)
mlrun/serving/server.py CHANGED
@@ -196,7 +196,7 @@ class GraphServer(ModelObj):
196
196
  def test(
197
197
  self,
198
198
  path: str = "/",
199
- body: Union[str, bytes, dict] = None,
199
+ body: Optional[Union[str, bytes, dict]] = None,
200
200
  method: str = "",
201
201
  headers: Optional[str] = None,
202
202
  content_type: Optional[str] = None,
mlrun/serving/states.py CHANGED
@@ -25,7 +25,7 @@ import pathlib
25
25
  import traceback
26
26
  from copy import copy, deepcopy
27
27
  from inspect import getfullargspec, signature
28
- from typing import Any, Union
28
+ from typing import Any, Optional, Union
29
29
 
30
30
  import storey.utils
31
31
 
@@ -104,7 +104,12 @@ class BaseStep(ModelObj):
104
104
  default_shape = "ellipse"
105
105
  _dict_fields = ["kind", "comment", "after", "on_error"]
106
106
 
107
- def __init__(self, name: str = None, after: list = None, shape: str = None):
107
+ def __init__(
108
+ self,
109
+ name: Optional[str] = None,
110
+ after: Optional[list] = None,
111
+ shape: Optional[str] = None,
112
+ ):
108
113
  self.name = name
109
114
  self._parent = None
110
115
  self.comment = None
@@ -154,14 +159,14 @@ class BaseStep(ModelObj):
154
159
 
155
160
  def error_handler(
156
161
  self,
157
- name: str = None,
162
+ name: Optional[str] = None,
158
163
  class_name=None,
159
164
  handler=None,
160
165
  before=None,
161
166
  function=None,
162
- full_event: bool = None,
163
- input_path: str = None,
164
- result_path: str = None,
167
+ full_event: Optional[bool] = None,
168
+ input_path: Optional[str] = None,
169
+ result_path: Optional[str] = None,
165
170
  **class_args,
166
171
  ):
167
172
  """set error handler on a step or the entire graph (to be executed on failure/raise)
@@ -297,13 +302,13 @@ class BaseStep(ModelObj):
297
302
  def to(
298
303
  self,
299
304
  class_name: Union[str, StepToDict] = None,
300
- name: str = None,
301
- handler: str = None,
302
- graph_shape: str = None,
303
- function: str = None,
304
- full_event: bool = None,
305
- input_path: str = None,
306
- result_path: str = None,
305
+ name: Optional[str] = None,
306
+ handler: Optional[str] = None,
307
+ graph_shape: Optional[str] = None,
308
+ function: Optional[str] = None,
309
+ full_event: Optional[bool] = None,
310
+ input_path: Optional[str] = None,
311
+ result_path: Optional[str] = None,
307
312
  **class_args,
308
313
  ):
309
314
  """add a step right after this step and return the new step
@@ -404,16 +409,16 @@ class TaskStep(BaseStep):
404
409
 
405
410
  def __init__(
406
411
  self,
407
- class_name: Union[str, type] = None,
408
- class_args: dict = None,
409
- handler: str = None,
410
- name: str = None,
411
- after: list = None,
412
- full_event: bool = None,
413
- function: str = None,
414
- responder: bool = None,
415
- input_path: str = None,
416
- result_path: str = None,
412
+ class_name: Optional[Union[str, type]] = None,
413
+ class_args: Optional[dict] = None,
414
+ handler: Optional[str] = None,
415
+ name: Optional[str] = None,
416
+ after: Optional[list] = None,
417
+ full_event: Optional[bool] = None,
418
+ function: Optional[str] = None,
419
+ responder: Optional[bool] = None,
420
+ input_path: Optional[str] = None,
421
+ result_path: Optional[str] = None,
417
422
  ):
418
423
  super().__init__(name, after)
419
424
  self.class_name = class_name
@@ -607,16 +612,16 @@ class MonitoringApplicationStep(TaskStep):
607
612
 
608
613
  def __init__(
609
614
  self,
610
- class_name: Union[str, type] = None,
611
- class_args: dict = None,
612
- handler: str = None,
613
- name: str = None,
614
- after: list = None,
615
- full_event: bool = None,
616
- function: str = None,
617
- responder: bool = None,
618
- input_path: str = None,
619
- result_path: str = None,
615
+ class_name: Optional[Union[str, type]] = None,
616
+ class_args: Optional[dict] = None,
617
+ handler: Optional[str] = None,
618
+ name: Optional[str] = None,
619
+ after: Optional[list] = None,
620
+ full_event: Optional[bool] = None,
621
+ function: Optional[str] = None,
622
+ responder: Optional[bool] = None,
623
+ input_path: Optional[str] = None,
624
+ result_path: Optional[str] = None,
620
625
  ):
621
626
  super().__init__(
622
627
  class_name=class_name,
@@ -641,16 +646,16 @@ class ErrorStep(TaskStep):
641
646
 
642
647
  def __init__(
643
648
  self,
644
- class_name: Union[str, type] = None,
645
- class_args: dict = None,
646
- handler: str = None,
647
- name: str = None,
648
- after: list = None,
649
- full_event: bool = None,
650
- function: str = None,
651
- responder: bool = None,
652
- input_path: str = None,
653
- result_path: str = None,
649
+ class_name: Optional[Union[str, type]] = None,
650
+ class_args: Optional[dict] = None,
651
+ handler: Optional[str] = None,
652
+ name: Optional[str] = None,
653
+ after: Optional[list] = None,
654
+ full_event: Optional[bool] = None,
655
+ function: Optional[str] = None,
656
+ responder: Optional[bool] = None,
657
+ input_path: Optional[str] = None,
658
+ result_path: Optional[str] = None,
654
659
  ):
655
660
  super().__init__(
656
661
  class_name=class_name,
@@ -678,14 +683,14 @@ class RouterStep(TaskStep):
678
683
 
679
684
  def __init__(
680
685
  self,
681
- class_name: Union[str, type] = None,
682
- class_args: dict = None,
683
- handler: str = None,
684
- routes: list = None,
685
- name: str = None,
686
- function: str = None,
687
- input_path: str = None,
688
- result_path: str = None,
686
+ class_name: Optional[Union[str, type]] = None,
687
+ class_args: Optional[dict] = None,
688
+ handler: Optional[str] = None,
689
+ routes: Optional[list] = None,
690
+ name: Optional[str] = None,
691
+ function: Optional[str] = None,
692
+ input_path: Optional[str] = None,
693
+ result_path: Optional[str] = None,
689
694
  ):
690
695
  super().__init__(
691
696
  class_name,
@@ -813,12 +818,12 @@ class QueueStep(BaseStep):
813
818
 
814
819
  def __init__(
815
820
  self,
816
- name: str = None,
817
- path: str = None,
818
- after: list = None,
819
- shards: int = None,
820
- retention_in_hours: int = None,
821
- trigger_args: dict = None,
821
+ name: Optional[str] = None,
822
+ path: Optional[str] = None,
823
+ after: Optional[list] = None,
824
+ shards: Optional[int] = None,
825
+ retention_in_hours: Optional[int] = None,
826
+ trigger_args: Optional[dict] = None,
822
827
  **options,
823
828
  ):
824
829
  super().__init__(name, after)
@@ -850,13 +855,13 @@ class QueueStep(BaseStep):
850
855
  def to(
851
856
  self,
852
857
  class_name: Union[str, StepToDict] = None,
853
- name: str = None,
854
- handler: str = None,
855
- graph_shape: str = None,
856
- function: str = None,
857
- full_event: bool = None,
858
- input_path: str = None,
859
- result_path: str = None,
858
+ name: Optional[str] = None,
859
+ handler: Optional[str] = None,
860
+ graph_shape: Optional[str] = None,
861
+ function: Optional[str] = None,
862
+ full_event: Optional[bool] = None,
863
+ input_path: Optional[str] = None,
864
+ result_path: Optional[str] = None,
860
865
  **class_args,
861
866
  ):
862
867
  if not function:
@@ -905,7 +910,7 @@ class FlowStep(BaseStep):
905
910
  self,
906
911
  name=None,
907
912
  steps=None,
908
- after: list = None,
913
+ after: Optional[list] = None,
909
914
  engine=None,
910
915
  final_step=None,
911
916
  ):
@@ -948,9 +953,9 @@ class FlowStep(BaseStep):
948
953
  before=None,
949
954
  graph_shape=None,
950
955
  function=None,
951
- full_event: bool = None,
952
- input_path: str = None,
953
- result_path: str = None,
956
+ full_event: Optional[bool] = None,
957
+ input_path: Optional[str] = None,
958
+ result_path: Optional[str] = None,
954
959
  **class_args,
955
960
  ):
956
961
  """add task, queue or router step/class to the flow
@@ -1037,7 +1042,7 @@ class FlowStep(BaseStep):
1037
1042
  self._last_added = step
1038
1043
  return step
1039
1044
 
1040
- def clear_children(self, steps: list = None):
1045
+ def clear_children(self, steps: Optional[list] = None):
1041
1046
  """remove some or all of the states, empty/None for all"""
1042
1047
  if not steps:
1043
1048
  steps = self._steps.keys()
@@ -1554,8 +1559,8 @@ def params_to_step(
1554
1559
  graph_shape=None,
1555
1560
  function=None,
1556
1561
  full_event=None,
1557
- input_path: str = None,
1558
- result_path: str = None,
1562
+ input_path: Optional[str] = None,
1563
+ result_path: Optional[str] = None,
1559
1564
  class_args=None,
1560
1565
  ):
1561
1566
  """return step object from provided params or classes/objects"""
mlrun/serving/utils.py CHANGED
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
  import inspect
16
+ from typing import Optional
16
17
 
17
18
  from mlrun.utils import get_in, update_in
18
19
 
@@ -55,7 +56,12 @@ class StepToDict:
55
56
  "kwargs",
56
57
  ]
57
58
 
58
- def to_dict(self, fields: list = None, exclude: list = None, strip: bool = False):
59
+ def to_dict(
60
+ self,
61
+ fields: Optional[list] = None,
62
+ exclude: Optional[list] = None,
63
+ strip: bool = False,
64
+ ):
59
65
  """convert the step object to a python dictionary"""
60
66
  fields = fields or getattr(self, "_dict_fields", None)
61
67
  if not fields:
@@ -105,5 +111,10 @@ class MonitoringApplicationToDict(StepToDict):
105
111
  class RouterToDict(StepToDict):
106
112
  _STEP_KIND = "router"
107
113
 
108
- def to_dict(self, fields: list = None, exclude: list = None, strip: bool = False):
114
+ def to_dict(
115
+ self,
116
+ fields: Optional[list] = None,
117
+ exclude: Optional[list] = None,
118
+ strip: bool = False,
119
+ ):
109
120
  return super().to_dict(exclude=["routes"], strip=strip)
@@ -18,6 +18,7 @@ import socket
18
18
  from copy import deepcopy
19
19
  from datetime import datetime
20
20
  from io import BytesIO
21
+ from typing import Optional
21
22
  from urllib.request import urlopen
22
23
 
23
24
  import nuclio
@@ -33,7 +34,7 @@ serving_handler = "handler"
33
34
  def new_v1_model_server(
34
35
  name,
35
36
  model_class: str,
36
- models: dict = None,
37
+ models: Optional[dict] = None,
37
38
  filename="",
38
39
  protocol="",
39
40
  image="",
@@ -68,7 +69,7 @@ def new_v1_model_server(
68
69
 
69
70
 
70
71
  class MLModelServer:
71
- def __init__(self, name: str, model_dir: str = None, model=None):
72
+ def __init__(self, name: str, model_dir: Optional[str] = None, model=None):
72
73
  self.name = name
73
74
  self.ready = False
74
75
  self.model_dir = model_dir
@@ -33,12 +33,12 @@ class V2ModelServer(StepToDict):
33
33
  def __init__(
34
34
  self,
35
35
  context=None,
36
- name: str = None,
37
- model_path: str = None,
36
+ name: Optional[str] = None,
37
+ model_path: Optional[str] = None,
38
38
  model=None,
39
39
  protocol=None,
40
- input_path: str = None,
41
- result_path: str = None,
40
+ input_path: Optional[str] = None,
41
+ result_path: Optional[str] = None,
42
42
  shard_by_endpoint: Optional[bool] = None,
43
43
  **kwargs,
44
44
  ):
mlrun/track/__init__.py CHANGED
@@ -11,6 +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
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
14
+
15
15
  from mlrun.track.tracker import Tracker
16
16
  from mlrun.track.tracker_manager import TrackerManager
mlrun/track/tracker.py CHANGED
@@ -13,7 +13,7 @@
13
13
  # limitations under the License.
14
14
 
15
15
  from abc import ABC, abstractmethod
16
- from typing import Any, Union
16
+ from typing import Any, Optional, Union
17
17
 
18
18
  from mlrun.artifacts import Artifact, ModelArtifact
19
19
  from mlrun.execution import MLClientCtx
@@ -63,7 +63,7 @@ class Tracker(ABC):
63
63
  project: MlrunProject,
64
64
  reference_id: Any,
65
65
  function_name: str,
66
- handler: str = None,
66
+ handler: Optional[str] = None,
67
67
  **kwargs,
68
68
  ) -> RunObject:
69
69
  """
@@ -15,6 +15,7 @@ import os
15
15
  import pathlib
16
16
  import tempfile
17
17
  import zipfile
18
+ from typing import Optional
18
19
 
19
20
  import mlflow
20
21
  import mlflow.entities
@@ -190,7 +191,7 @@ class MLFlowTracker(Tracker):
190
191
  project: MlrunProject,
191
192
  reference_id: str,
192
193
  function_name: str,
193
- handler: str = None,
194
+ handler: Optional[str] = None,
194
195
  **kwargs,
195
196
  ) -> RunObject:
196
197
  """
@@ -251,9 +252,9 @@ class MLFlowTracker(Tracker):
251
252
  self,
252
253
  project: MlrunProject,
253
254
  reference_id: str,
254
- key: str = None,
255
- metrics: dict = None,
256
- extra_data: dict = None,
255
+ key: Optional[str] = None,
256
+ metrics: Optional[dict] = None,
257
+ extra_data: Optional[dict] = None,
257
258
  ) -> ModelArtifact:
258
259
  """
259
260
  Import a model from MLFlow to MLRun.
@@ -290,7 +291,7 @@ class MLFlowTracker(Tracker):
290
291
  return model
291
292
 
292
293
  def import_artifact(
293
- self, project: MlrunProject, reference_id: str, key: str = None
294
+ self, project: MlrunProject, reference_id: str, key: Optional[str] = None
294
295
  ) -> Artifact:
295
296
  """
296
297
  Import an artifact from MLFlow to MLRun.
mlrun/utils/async_http.py CHANGED
@@ -42,7 +42,7 @@ class AsyncClientWithRetry(RetryClient):
42
42
  retry_on_exception: bool = True,
43
43
  raise_for_status: bool = True,
44
44
  blacklisted_methods: typing.Optional[list[str]] = None,
45
- logger: logging.Logger = None,
45
+ logger: Optional[logging.Logger] = None,
46
46
  *args,
47
47
  **kwargs,
48
48
  ):