mlrun 1.7.2rc3__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 -13
  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.2rc3.dist-info → mlrun-1.8.0rc1.dist-info}/METADATA +186 -186
  217. mlrun-1.8.0rc1.dist-info/RECORD +356 -0
  218. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc1.dist-info}/WHEEL +1 -1
  219. mlrun-1.7.2rc3.dist-info/RECORD +0 -351
  220. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc1.dist-info}/LICENSE +0 -0
  221. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc1.dist-info}/entry_points.txt +0 -0
  222. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc1.dist-info}/top_level.txt +0 -0
mlrun/run.py CHANGED
@@ -30,15 +30,15 @@ from typing import Optional, Union
30
30
 
31
31
  import nuclio
32
32
  import yaml
33
- from mlrun_pipelines.common.models import RunStatuses
34
- from mlrun_pipelines.common.ops import format_summary_from_kfp_run, show_kfp_run
35
- from mlrun_pipelines.utils import get_client
36
33
 
37
34
  import mlrun.common.constants as mlrun_constants
38
35
  import mlrun.common.formatters
39
36
  import mlrun.common.schemas
40
37
  import mlrun.errors
41
38
  import mlrun.utils.helpers
39
+ from mlrun_pipelines.common.models import RunStatuses
40
+ from mlrun_pipelines.common.ops import format_summary_from_kfp_run, show_kfp_run
41
+ from mlrun_pipelines.utils import get_client
42
42
 
43
43
  from .common.helpers import parse_versioned_object_uri
44
44
  from .config import config as mlconf
@@ -200,7 +200,7 @@ def get_or_create_ctx(
200
200
  event=None,
201
201
  spec: Optional[dict] = None,
202
202
  with_env: bool = True,
203
- rundb: str = "",
203
+ rundb: Union[str, "mlrun.db.RunDBInterface"] = "",
204
204
  project: str = "",
205
205
  upload_artifacts: bool = False,
206
206
  labels: Optional[dict] = None,
@@ -306,7 +306,7 @@ def get_or_create_ctx(
306
306
  out = rundb or mlconf.dbpath or environ.get("MLRUN_DBPATH")
307
307
  if out:
308
308
  autocommit = True
309
- logger.info(f"logging run results to: {out}")
309
+ logger.info(f"Logging run results to: {out}")
310
310
 
311
311
  newspec["metadata"]["project"] = (
312
312
  newspec["metadata"].get("project") or project or mlconf.default_project
@@ -434,7 +434,7 @@ def new_function(
434
434
  mode: Optional[str] = None,
435
435
  handler: Optional[str] = None,
436
436
  source: Optional[str] = None,
437
- requirements: Union[str, list[str]] = None,
437
+ requirements: Optional[Union[str, list[str]]] = None,
438
438
  kfp: Optional[bool] = None,
439
439
  requirements_file: str = "",
440
440
  ):
@@ -909,10 +909,10 @@ def _run_pipeline(
909
909
  def wait_for_pipeline_completion(
910
910
  run_id,
911
911
  timeout=60 * 60,
912
- expected_statuses: list[str] = None,
912
+ expected_statuses: Optional[list[str]] = None,
913
913
  namespace=None,
914
914
  remote=True,
915
- project: str = None,
915
+ project: Optional[str] = None,
916
916
  ):
917
917
  """Wait for Pipeline status, timeout in sec
918
918
 
@@ -1004,7 +1004,7 @@ def get_pipeline(
1004
1004
  format_: Union[
1005
1005
  str, mlrun.common.formatters.PipelineFormat
1006
1006
  ] = mlrun.common.formatters.PipelineFormat.summary,
1007
- project: str = None,
1007
+ project: Optional[str] = None,
1008
1008
  remote: bool = True,
1009
1009
  ):
1010
1010
  """Get Pipeline status
@@ -12,8 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
16
-
17
15
  __all__ = [
18
16
  "BaseRuntime",
19
17
  "KubejobRuntime",
@@ -60,7 +58,7 @@ from ..serving import MLModelServer, new_v1_model_server # noqa isort: skip
60
58
  def new_model_server(
61
59
  name,
62
60
  model_class: str,
63
- models: dict = None,
61
+ models: typing.Optional[dict] = None,
64
62
  filename="",
65
63
  protocol="",
66
64
  image="",
mlrun/runtimes/base.py CHANGED
@@ -21,7 +21,6 @@ from os import environ
21
21
  from typing import Callable, Optional, Union
22
22
 
23
23
  import requests.exceptions
24
- from mlrun_pipelines.common.ops import mlrun_op
25
24
  from nuclio.build import mlrun_footer
26
25
 
27
26
  import mlrun.common.constants
@@ -35,6 +34,7 @@ import mlrun.utils.helpers
35
34
  import mlrun.utils.notifications
36
35
  import mlrun.utils.regex
37
36
  from mlrun.utils.helpers import generate_object_uri, verify_field_regex
37
+ from mlrun_pipelines.common.ops import mlrun_op
38
38
 
39
39
  from ..config import config
40
40
  from ..datastore import store_manager
@@ -517,7 +517,7 @@ class BaseRuntime(ModelObj):
517
517
  run_results = resp["status"].get("results", {})
518
518
  if generator.eval_stop_condition(run_results):
519
519
  logger.info(
520
- f"reached early stop condition ({generator.options.stop_condition}), stopping iterations!"
520
+ f"Reached early stop condition ({generator.options.stop_condition}), stopping iterations!"
521
521
  )
522
522
  results.append(resp)
523
523
  break
@@ -529,7 +529,7 @@ class BaseRuntime(ModelObj):
529
529
  resp = self._update_run_state(task=task, err=error_string)
530
530
  num_errors += 1
531
531
  if num_errors > generator.max_errors:
532
- logger.error("too many errors, stopping iterations!")
532
+ logger.error("Too many errors, stopping iterations!")
533
533
  results.append(resp)
534
534
  break
535
535
 
@@ -553,9 +553,9 @@ class BaseRuntime(ModelObj):
553
553
 
554
554
  def _update_run_state(
555
555
  self,
556
- resp: dict = None,
556
+ resp: Optional[dict] = None,
557
557
  task: RunObject = None,
558
- err: Union[Exception, str] = None,
558
+ err: Optional[Union[Exception, str]] = None,
559
559
  run_format: mlrun.common.formatters.RunFormat = mlrun.common.formatters.RunFormat.full,
560
560
  ) -> typing.Optional[dict]:
561
561
  """update the task state in the DB"""
@@ -644,7 +644,10 @@ class BaseRuntime(ModelObj):
644
644
  return updates
645
645
 
646
646
  def full_image_path(
647
- self, image=None, client_version: str = None, client_python_version: str = None
647
+ self,
648
+ image=None,
649
+ client_version: Optional[str] = None,
650
+ client_python_version: Optional[str] = None,
648
651
  ):
649
652
  image = image or self.spec.image or ""
650
653
 
@@ -669,16 +672,16 @@ class BaseRuntime(ModelObj):
669
672
  handler=None,
670
673
  name: str = "",
671
674
  project: str = "",
672
- params: dict = None,
675
+ params: Optional[dict] = None,
673
676
  hyperparams=None,
674
677
  selector="",
675
678
  hyper_param_options: HyperParamOptions = None,
676
- inputs: dict = None,
677
- outputs: list = None,
679
+ inputs: Optional[dict] = None,
680
+ outputs: Optional[list] = None,
678
681
  workdir: str = "",
679
682
  artifact_path: str = "",
680
683
  image: str = "",
681
- labels: dict = None,
684
+ labels: Optional[dict] = None,
682
685
  use_db=True,
683
686
  verbose=None,
684
687
  scrape_metrics=False,
mlrun/runtimes/daskjob.py CHANGED
@@ -363,7 +363,7 @@ class DaskCluster(KubejobRuntime):
363
363
  skip_deployed=False,
364
364
  is_kfp=False,
365
365
  mlrun_version_specifier=None,
366
- builder_env: dict = None,
366
+ builder_env: Optional[dict] = None,
367
367
  show_on_failure: bool = False,
368
368
  force_build: bool = False,
369
369
  ):
@@ -406,9 +406,9 @@ class DaskCluster(KubejobRuntime):
406
406
 
407
407
  def with_scheduler_limits(
408
408
  self,
409
- mem: str = None,
410
- cpu: str = None,
411
- gpus: int = None,
409
+ mem: Optional[str] = None,
410
+ cpu: Optional[str] = None,
411
+ gpus: Optional[int] = None,
412
412
  gpu_type: str = "nvidia.com/gpu",
413
413
  patch: bool = False,
414
414
  ):
@@ -422,9 +422,9 @@ class DaskCluster(KubejobRuntime):
422
422
 
423
423
  def with_worker_limits(
424
424
  self,
425
- mem: str = None,
426
- cpu: str = None,
427
- gpus: int = None,
425
+ mem: Optional[str] = None,
426
+ cpu: Optional[str] = None,
427
+ gpus: Optional[int] = None,
428
428
  gpu_type: str = "nvidia.com/gpu",
429
429
  patch: bool = False,
430
430
  ):
@@ -442,7 +442,7 @@ class DaskCluster(KubejobRuntime):
442
442
  )
443
443
 
444
444
  def with_scheduler_requests(
445
- self, mem: str = None, cpu: str = None, patch: bool = False
445
+ self, mem: Optional[str] = None, cpu: Optional[str] = None, patch: bool = False
446
446
  ):
447
447
  """
448
448
  set scheduler pod resources requests
@@ -451,7 +451,7 @@ class DaskCluster(KubejobRuntime):
451
451
  self.spec._verify_and_set_requests("scheduler_resources", mem, cpu, patch=patch)
452
452
 
453
453
  def with_worker_requests(
454
- self, mem: str = None, cpu: str = None, patch: bool = False
454
+ self, mem: Optional[str] = None, cpu: Optional[str] = None, patch: bool = False
455
455
  ):
456
456
  """
457
457
  set worker pod resources requests
@@ -15,6 +15,7 @@ import json
15
15
  import random
16
16
  import sys
17
17
  from copy import deepcopy
18
+ from typing import Optional
18
19
 
19
20
  import pandas as pd
20
21
 
@@ -26,7 +27,7 @@ default_max_iterations = 10
26
27
  default_max_errors = 3
27
28
 
28
29
 
29
- def get_generator(spec: RunSpec, execution, param_file_secrets: dict = None):
30
+ def get_generator(spec: RunSpec, execution, param_file_secrets: Optional[dict] = None):
30
31
  options = spec.hyper_param_options
31
32
  strategy = spec.strategy or options.strategy
32
33
  if not spec.is_hyper_job() or strategy == "custom":
mlrun/runtimes/kubejob.py CHANGED
@@ -14,11 +14,10 @@
14
14
  import typing
15
15
  import warnings
16
16
 
17
- from mlrun_pipelines.common.ops import build_op
18
-
19
17
  import mlrun.common.schemas
20
18
  import mlrun.db
21
19
  import mlrun.errors
20
+ from mlrun_pipelines.common.ops import build_op
22
21
 
23
22
  from ..model import RunObject
24
23
  from .pod import KubeResource
@@ -76,7 +75,7 @@ class KubejobRuntime(KubeResource):
76
75
  self,
77
76
  image="",
78
77
  base_image=None,
79
- commands: list = None,
78
+ commands: typing.Optional[list] = None,
80
79
  secret=None,
81
80
  source=None,
82
81
  extra=None,
@@ -148,7 +147,7 @@ class KubejobRuntime(KubeResource):
148
147
  skip_deployed: bool = False,
149
148
  is_kfp: bool = False,
150
149
  mlrun_version_specifier: typing.Optional[bool] = None,
151
- builder_env: dict = None,
150
+ builder_env: typing.Optional[dict] = None,
152
151
  show_on_failure: bool = False,
153
152
  force_build: bool = False,
154
153
  ) -> bool:
@@ -190,7 +189,7 @@ class KubejobRuntime(KubeResource):
190
189
  self,
191
190
  image=None,
192
191
  base_image=None,
193
- commands: list = None,
192
+ commands: typing.Optional[list] = None,
194
193
  secret_name="",
195
194
  with_mlrun=True,
196
195
  skip_deployed=False,
@@ -12,8 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
16
-
17
15
  from dependency_injector import containers, providers
18
16
 
19
17
  from mlrun.config import config
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
  import abc
15
15
  import os
16
+ from typing import Optional
16
17
 
17
18
  from mlrun.config import config
18
19
  from mlrun.runtimes.kubejob import KubejobRuntime
@@ -117,7 +118,7 @@ class AbstractMPIJobRuntime(KubejobRuntime, abc.ABC):
117
118
  return {}
118
119
 
119
120
  def with_tracing(
120
- self, log_file_path: str = None, enable_cycle_markers: bool = False
121
+ self, log_file_path: Optional[str] = None, enable_cycle_markers: bool = False
121
122
  ):
122
123
  """Add Horovod Timeline activity tracking to the job to analyse
123
124
  its performance.
@@ -149,11 +150,11 @@ class AbstractMPIJobRuntime(KubejobRuntime, abc.ABC):
149
150
 
150
151
  def with_autotune(
151
152
  self,
152
- log_file_path: str = None,
153
- warmup_samples: int = None,
154
- steps_per_sample: int = None,
155
- bayes_opt_max_samples: int = None,
156
- gaussian_process_noise: float = None,
153
+ log_file_path: Optional[str] = None,
154
+ warmup_samples: Optional[int] = None,
155
+ steps_per_sample: Optional[int] = None,
156
+ bayes_opt_max_samples: Optional[int] = None,
157
+ gaussian_process_noise: Optional[float] = None,
157
158
  ):
158
159
  """Adds an Autotuner to help optimize Horovod's Parameters for better performance.
159
160
 
@@ -118,10 +118,10 @@ class APIGatewayMetadata(ModelObj):
118
118
  def __init__(
119
119
  self,
120
120
  name: str,
121
- namespace: str = None,
122
- labels: dict = None,
123
- annotations: dict = None,
124
- creation_timestamp: str = None,
121
+ namespace: Optional[str] = None,
122
+ labels: Optional[dict] = None,
123
+ annotations: Optional[dict] = None,
124
+ creation_timestamp: Optional[str] = None,
125
125
  ):
126
126
  """
127
127
  :param name: The name of the API gateway
@@ -169,9 +169,9 @@ class APIGatewaySpec(ModelObj):
169
169
  "mlrun.runtimes.nuclio.serving.ServingRuntime",
170
170
  "mlrun.runtimes.nuclio.application.ApplicationRuntime",
171
171
  ],
172
- project: str = None,
172
+ project: Optional[str] = None,
173
173
  description: str = "",
174
- host: str = None,
174
+ host: Optional[str] = None,
175
175
  path: str = "/",
176
176
  authentication: Optional[APIGatewayAuthenticator] = NoneAuth(),
177
177
  canary: Optional[list[int]] = None,
@@ -389,7 +389,7 @@ class APIGateway(ModelObj):
389
389
  def invoke(
390
390
  self,
391
391
  method="POST",
392
- headers: dict = None,
392
+ headers: Optional[dict] = None,
393
393
  credentials: Optional[tuple[str, str]] = None,
394
394
  path: Optional[str] = None,
395
395
  body: Optional[Union[str, bytes, dict]] = None,
@@ -275,7 +275,7 @@ class ApplicationRuntime(RemoteRuntime):
275
275
  tag="",
276
276
  verbose=False,
277
277
  auth_info: schemas.AuthInfo = None,
278
- builder_env: dict = None,
278
+ builder_env: typing.Optional[dict] = None,
279
279
  force_build: bool = False,
280
280
  with_mlrun=None,
281
281
  skip_deployed=False,
@@ -367,7 +367,7 @@ class ApplicationRuntime(RemoteRuntime):
367
367
  source,
368
368
  workdir=None,
369
369
  pull_at_runtime: bool = False,
370
- target_dir: str = None,
370
+ target_dir: typing.Optional[str] = None,
371
371
  ):
372
372
  """load the code from git/tar/zip archive at build
373
373
 
@@ -426,12 +426,12 @@ class ApplicationRuntime(RemoteRuntime):
426
426
 
427
427
  def create_api_gateway(
428
428
  self,
429
- name: str = None,
430
- path: str = None,
429
+ name: typing.Optional[str] = None,
430
+ path: typing.Optional[str] = None,
431
431
  direct_port_access: bool = False,
432
432
  authentication_mode: schemas.APIGatewayAuthenticationMode = None,
433
- authentication_creds: tuple[str, str] = None,
434
- ssl_redirect: bool = None,
433
+ authentication_creds: typing.Optional[tuple[str, str]] = None,
434
+ ssl_redirect: typing.Optional[bool] = None,
435
435
  set_as_default: bool = False,
436
436
  gateway_timeout: typing.Optional[int] = None,
437
437
  ):
@@ -540,13 +540,13 @@ class ApplicationRuntime(RemoteRuntime):
540
540
  self,
541
541
  path: str = "",
542
542
  body: typing.Optional[typing.Union[str, bytes, dict]] = None,
543
- method: str = None,
544
- headers: dict = None,
543
+ method: typing.Optional[str] = None,
544
+ headers: typing.Optional[dict] = None,
545
545
  dashboard: str = "",
546
546
  force_external_address: bool = False,
547
547
  auth_info: schemas.AuthInfo = None,
548
- mock: bool = None,
549
- credentials: tuple[str, str] = None,
548
+ mock: typing.Optional[bool] = None,
549
+ credentials: typing.Optional[tuple[str, str]] = None,
550
550
  **http_client_kwargs,
551
551
  ):
552
552
  self._sync_api_gateway()
@@ -653,7 +653,7 @@ class ApplicationRuntime(RemoteRuntime):
653
653
 
654
654
  def _build_application_image(
655
655
  self,
656
- builder_env: dict = None,
656
+ builder_env: typing.Optional[dict] = None,
657
657
  force_build: bool = False,
658
658
  watch=True,
659
659
  with_mlrun=None,
@@ -26,9 +26,6 @@ import requests
26
26
  import semver
27
27
  from aiohttp.client import ClientSession
28
28
  from kubernetes import client
29
- from mlrun_pipelines.common.mounts import VolumeMount
30
- from mlrun_pipelines.common.ops import deploy_op
31
- from mlrun_pipelines.mounts import mount_v3io, v3io_cred
32
29
  from nuclio.deploy import find_dashboard_url, get_deploy_status
33
30
  from nuclio.triggers import V3IOStreamTrigger
34
31
 
@@ -50,6 +47,9 @@ from mlrun.runtimes.base import FunctionStatus, RunError
50
47
  from mlrun.runtimes.pod import KubeResource, KubeResourceSpec
51
48
  from mlrun.runtimes.utils import get_item_name, log_std
52
49
  from mlrun.utils import get_in, logger, update_in
50
+ from mlrun_pipelines.common.mounts import VolumeMount
51
+ from mlrun_pipelines.common.ops import deploy_op
52
+ from mlrun_pipelines.mounts import mount_v3io, v3io_cred
53
53
 
54
54
 
55
55
  def validate_nuclio_version_compatibility(*min_versions):
@@ -554,7 +554,7 @@ class RemoteRuntime(KubeResource):
554
554
  tag="",
555
555
  verbose=False,
556
556
  auth_info: AuthInfo = None,
557
- builder_env: dict = None,
557
+ builder_env: typing.Optional[dict] = None,
558
558
  force_build: bool = False,
559
559
  ):
560
560
  """Deploy the nuclio function to the cluster
@@ -693,7 +693,9 @@ class RemoteRuntime(KubeResource):
693
693
  super().with_priority_class(name)
694
694
 
695
695
  def with_service_type(
696
- self, service_type: str, add_templated_ingress_host_mode: str = None
696
+ self,
697
+ service_type: str,
698
+ add_templated_ingress_host_mode: typing.Optional[str] = None,
697
699
  ):
698
700
  """
699
701
  Enables to control the service type of the pod and the addition of templated ingress host
@@ -887,13 +889,13 @@ class RemoteRuntime(KubeResource):
887
889
  def invoke(
888
890
  self,
889
891
  path: str,
890
- body: typing.Union[str, bytes, dict] = None,
891
- method: str = None,
892
- headers: dict = None,
892
+ body: typing.Optional[typing.Union[str, bytes, dict]] = None,
893
+ method: typing.Optional[str] = None,
894
+ headers: typing.Optional[dict] = None,
893
895
  dashboard: str = "",
894
896
  force_external_address: bool = False,
895
897
  auth_info: AuthInfo = None,
896
- mock: bool = None,
898
+ mock: typing.Optional[bool] = None,
897
899
  **http_client_kwargs,
898
900
  ):
899
901
  """Invoke the remote (live) function and return the results
@@ -995,8 +997,8 @@ class RemoteRuntime(KubeResource):
995
997
 
996
998
  def with_sidecar(
997
999
  self,
998
- name: str = None,
999
- image: str = None,
1000
+ name: typing.Optional[str] = None,
1001
+ image: typing.Optional[str] = None,
1000
1002
  ports: typing.Optional[typing.Union[int, list[int]]] = None,
1001
1003
  command: typing.Optional[str] = None,
1002
1004
  args: typing.Optional[list[str]] = None,
@@ -1035,10 +1037,9 @@ class RemoteRuntime(KubeResource):
1035
1037
  if args and sidecar.get("command"):
1036
1038
  sidecar["args"] = mlrun.utils.helpers.as_list(args)
1037
1039
 
1038
- # put the configured resources on the sidecar container instead of the reverse proxy container
1040
+ # populate the sidecar resources from the function spec
1039
1041
  if self.spec.resources:
1040
1042
  sidecar["resources"] = self.spec.resources
1041
- self.spec.resources = None
1042
1043
 
1043
1044
  def _set_sidecar(self, name: str) -> dict:
1044
1045
  self.spec.config.setdefault("spec.sidecars", [])
@@ -51,7 +51,7 @@ if TYPE_CHECKING:
51
51
  def new_v2_model_server(
52
52
  name,
53
53
  model_class: str,
54
- models: dict = None,
54
+ models: Optional[dict] = None,
55
55
  filename="",
56
56
  protocol="",
57
57
  image="",
@@ -356,12 +356,12 @@ class ServingRuntime(RemoteRuntime):
356
356
  def add_model(
357
357
  self,
358
358
  key: str,
359
- model_path: str = None,
360
- class_name: str = None,
361
- model_url: str = None,
362
- handler: str = None,
363
- router_step: str = None,
364
- child_function: str = None,
359
+ model_path: Optional[str] = None,
360
+ class_name: Optional[str] = None,
361
+ model_url: Optional[str] = None,
362
+ handler: Optional[str] = None,
363
+ router_step: Optional[str] = None,
364
+ child_function: Optional[str] = None,
365
365
  **class_args,
366
366
  ):
367
367
  """add ml model and/or route to the function.
@@ -509,7 +509,7 @@ class ServingRuntime(RemoteRuntime):
509
509
  stream.path, group=group, shards=stream.shards, **trigger_args
510
510
  )
511
511
 
512
- def _deploy_function_refs(self, builder_env: dict = None):
512
+ def _deploy_function_refs(self, builder_env: Optional[dict] = None):
513
513
  """set metadata and deploy child functions"""
514
514
  for function_ref in self._spec.function_refs.values():
515
515
  logger.info(f"deploy child function {function_ref.name} ...")
@@ -583,7 +583,7 @@ class ServingRuntime(RemoteRuntime):
583
583
  tag="",
584
584
  verbose=False,
585
585
  auth_info: mlrun.common.schemas.AuthInfo = None,
586
- builder_env: dict = None,
586
+ builder_env: Optional[dict] = None,
587
587
  force_build: bool = False,
588
588
  ):
589
589
  """deploy model serving function to a local/remote cluster