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
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
@@ -73,6 +73,9 @@ from .utils import (
73
73
  update_in,
74
74
  )
75
75
 
76
+ if typing.TYPE_CHECKING:
77
+ from mlrun.datastore import DataItem
78
+
76
79
 
77
80
  def function_to_module(code="", workdir=None, secrets=None, silent=False):
78
81
  """Load code, notebook or mlrun function as .py module
@@ -200,7 +203,7 @@ def get_or_create_ctx(
200
203
  event=None,
201
204
  spec: Optional[dict] = None,
202
205
  with_env: bool = True,
203
- rundb: str = "",
206
+ rundb: Union[str, "mlrun.db.RunDBInterface"] = "",
204
207
  project: str = "",
205
208
  upload_artifacts: bool = False,
206
209
  labels: Optional[dict] = None,
@@ -306,7 +309,7 @@ def get_or_create_ctx(
306
309
  out = rundb or mlconf.dbpath or environ.get("MLRUN_DBPATH")
307
310
  if out:
308
311
  autocommit = True
309
- logger.info(f"logging run results to: {out}")
312
+ logger.info(f"Logging run results to: {out}")
310
313
 
311
314
  newspec["metadata"]["project"] = (
312
315
  newspec["metadata"].get("project") or project or mlconf.default_project
@@ -434,7 +437,7 @@ def new_function(
434
437
  mode: Optional[str] = None,
435
438
  handler: Optional[str] = None,
436
439
  source: Optional[str] = None,
437
- requirements: Union[str, list[str]] = None,
440
+ requirements: Optional[Union[str, list[str]]] = None,
438
441
  kfp: Optional[bool] = None,
439
442
  requirements_file: str = "",
440
443
  ):
@@ -906,13 +909,53 @@ def _run_pipeline(
906
909
  return pipeline_run_id
907
910
 
908
911
 
912
+ def retry_pipeline(
913
+ run_id: str,
914
+ project: Optional[str] = None,
915
+ namespace: Optional[str] = None,
916
+ ) -> str:
917
+ """Retry a pipeline run.
918
+
919
+ This function retries a previously executed pipeline run using the specified run ID. If the run is not in a
920
+ retryable state, a new run is created as a clone of the original run.
921
+
922
+ :param run_id: ID of the pipeline run to retry.
923
+ :param project: Optional; name of the project associated with the pipeline run.
924
+ :param namespace: Optional; Kubernetes namespace to use if not the default.
925
+
926
+ :returns: ID of the retried pipeline run or the ID of a cloned run if the original run is not retryable.
927
+ :raises ValueError: If access to the remote API service is not available.
928
+ """
929
+ mldb = mlrun.db.get_run_db()
930
+ if mldb.kind != "http":
931
+ raise ValueError(
932
+ "Retrying a pipeline requires access to remote API service. "
933
+ "Please set the dbpath URL."
934
+ )
935
+
936
+ pipeline_run_id = mldb.retry_pipeline(
937
+ run_id=run_id,
938
+ project=project,
939
+ namespace=namespace,
940
+ )
941
+ if pipeline_run_id == run_id:
942
+ logger.info(
943
+ f"Retried pipeline run ID={pipeline_run_id}, check UI for progress."
944
+ )
945
+ else:
946
+ logger.info(
947
+ f"Copy of pipeline {run_id} was retried as run ID={pipeline_run_id}, check UI for progress."
948
+ )
949
+ return pipeline_run_id
950
+
951
+
909
952
  def wait_for_pipeline_completion(
910
953
  run_id,
911
954
  timeout=60 * 60,
912
- expected_statuses: list[str] = None,
955
+ expected_statuses: Optional[list[str]] = None,
913
956
  namespace=None,
914
957
  remote=True,
915
- project: str = None,
958
+ project: Optional[str] = None,
916
959
  ):
917
960
  """Wait for Pipeline status, timeout in sec
918
961
 
@@ -1004,7 +1047,7 @@ def get_pipeline(
1004
1047
  format_: Union[
1005
1048
  str, mlrun.common.formatters.PipelineFormat
1006
1049
  ] = mlrun.common.formatters.PipelineFormat.summary,
1007
- project: str = None,
1050
+ project: Optional[str] = None,
1008
1051
  remote: bool = True,
1009
1052
  ):
1010
1053
  """Get Pipeline status
@@ -1089,7 +1132,7 @@ def get_object(url, secrets=None, size=None, offset=0, db=None):
1089
1132
  return stores.object(url=url).get(size, offset)
1090
1133
 
1091
1134
 
1092
- def get_dataitem(url, secrets=None, db=None) -> mlrun.datastore.DataItem:
1135
+ def get_dataitem(url, secrets=None, db=None) -> "DataItem":
1093
1136
  """get mlrun dataitem object (from path/url)"""
1094
1137
  stores = store_manager.set(secrets, db=db)
1095
1138
  return stores.object(url=url)
@@ -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,20 +21,21 @@ 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
28
27
  import mlrun.common.constants as mlrun_constants
28
+ import mlrun.common.formatters
29
+ import mlrun.common.runtimes
29
30
  import mlrun.common.schemas
30
31
  import mlrun.common.schemas.model_monitoring.constants as mm_constants
31
- import mlrun.db
32
32
  import mlrun.errors
33
33
  import mlrun.launcher.factory
34
34
  import mlrun.utils.helpers
35
35
  import mlrun.utils.notifications
36
36
  import mlrun.utils.regex
37
37
  from mlrun.utils.helpers import generate_object_uri, verify_field_regex
38
+ from mlrun_pipelines.common.ops import mlrun_op
38
39
 
39
40
  from ..config import config
40
41
  from ..datastore import store_manager
@@ -517,7 +518,7 @@ class BaseRuntime(ModelObj):
517
518
  run_results = resp["status"].get("results", {})
518
519
  if generator.eval_stop_condition(run_results):
519
520
  logger.info(
520
- f"reached early stop condition ({generator.options.stop_condition}), stopping iterations!"
521
+ f"Reached early stop condition ({generator.options.stop_condition}), stopping iterations!"
521
522
  )
522
523
  results.append(resp)
523
524
  break
@@ -529,7 +530,7 @@ class BaseRuntime(ModelObj):
529
530
  resp = self._update_run_state(task=task, err=error_string)
530
531
  num_errors += 1
531
532
  if num_errors > generator.max_errors:
532
- logger.error("too many errors, stopping iterations!")
533
+ logger.error("Too many errors, stopping iterations!")
533
534
  results.append(resp)
534
535
  break
535
536
 
@@ -553,9 +554,9 @@ class BaseRuntime(ModelObj):
553
554
 
554
555
  def _update_run_state(
555
556
  self,
556
- resp: dict = None,
557
+ resp: Optional[dict] = None,
557
558
  task: RunObject = None,
558
- err: Union[Exception, str] = None,
559
+ err: Optional[Union[Exception, str]] = None,
559
560
  run_format: mlrun.common.formatters.RunFormat = mlrun.common.formatters.RunFormat.full,
560
561
  ) -> typing.Optional[dict]:
561
562
  """update the task state in the DB"""
@@ -644,7 +645,10 @@ class BaseRuntime(ModelObj):
644
645
  return updates
645
646
 
646
647
  def full_image_path(
647
- self, image=None, client_version: str = None, client_python_version: str = None
648
+ self,
649
+ image=None,
650
+ client_version: Optional[str] = None,
651
+ client_python_version: Optional[str] = None,
648
652
  ):
649
653
  image = image or self.spec.image or ""
650
654
 
@@ -669,16 +673,16 @@ class BaseRuntime(ModelObj):
669
673
  handler=None,
670
674
  name: str = "",
671
675
  project: str = "",
672
- params: dict = None,
676
+ params: Optional[dict] = None,
673
677
  hyperparams=None,
674
678
  selector="",
675
679
  hyper_param_options: HyperParamOptions = None,
676
- inputs: dict = None,
677
- outputs: list = None,
680
+ inputs: Optional[dict] = None,
681
+ outputs: Optional[list] = None,
678
682
  workdir: str = "",
679
683
  artifact_path: str = "",
680
684
  image: str = "",
681
- labels: dict = None,
685
+ labels: Optional[dict] = None,
682
686
  use_db=True,
683
687
  verbose=None,
684
688
  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,