mlrun 1.6.4rc2__py3-none-any.whl → 1.7.0rc20__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 (291) hide show
  1. mlrun/__init__.py +11 -1
  2. mlrun/__main__.py +26 -112
  3. mlrun/alerts/__init__.py +15 -0
  4. mlrun/alerts/alert.py +144 -0
  5. mlrun/api/schemas/__init__.py +5 -4
  6. mlrun/artifacts/__init__.py +8 -3
  7. mlrun/artifacts/base.py +46 -257
  8. mlrun/artifacts/dataset.py +11 -192
  9. mlrun/artifacts/manager.py +47 -48
  10. mlrun/artifacts/model.py +31 -159
  11. mlrun/artifacts/plots.py +23 -380
  12. mlrun/common/constants.py +69 -0
  13. mlrun/common/db/sql_session.py +2 -3
  14. mlrun/common/formatters/__init__.py +19 -0
  15. mlrun/common/formatters/artifact.py +21 -0
  16. mlrun/common/formatters/base.py +78 -0
  17. mlrun/common/formatters/function.py +41 -0
  18. mlrun/common/formatters/pipeline.py +53 -0
  19. mlrun/common/formatters/project.py +51 -0
  20. mlrun/common/helpers.py +1 -2
  21. mlrun/common/model_monitoring/helpers.py +9 -5
  22. mlrun/{runtimes → common/runtimes}/constants.py +37 -9
  23. mlrun/common/schemas/__init__.py +24 -4
  24. mlrun/common/schemas/alert.py +203 -0
  25. mlrun/common/schemas/api_gateway.py +148 -0
  26. mlrun/common/schemas/artifact.py +18 -8
  27. mlrun/common/schemas/auth.py +11 -5
  28. mlrun/common/schemas/background_task.py +1 -1
  29. mlrun/common/schemas/client_spec.py +4 -1
  30. mlrun/common/schemas/feature_store.py +16 -16
  31. mlrun/common/schemas/frontend_spec.py +8 -7
  32. mlrun/common/schemas/function.py +5 -1
  33. mlrun/common/schemas/hub.py +11 -18
  34. mlrun/common/schemas/memory_reports.py +2 -2
  35. mlrun/common/schemas/model_monitoring/__init__.py +18 -3
  36. mlrun/common/schemas/model_monitoring/constants.py +83 -26
  37. mlrun/common/schemas/model_monitoring/grafana.py +13 -9
  38. mlrun/common/schemas/model_monitoring/model_endpoints.py +99 -16
  39. mlrun/common/schemas/notification.py +4 -4
  40. mlrun/common/schemas/object.py +2 -2
  41. mlrun/{runtimes/mpijob/v1alpha1.py → common/schemas/pagination.py} +10 -13
  42. mlrun/common/schemas/pipeline.py +1 -10
  43. mlrun/common/schemas/project.py +24 -23
  44. mlrun/common/schemas/runtime_resource.py +8 -12
  45. mlrun/common/schemas/schedule.py +3 -3
  46. mlrun/common/schemas/tag.py +1 -2
  47. mlrun/common/schemas/workflow.py +2 -2
  48. mlrun/common/types.py +7 -1
  49. mlrun/config.py +54 -17
  50. mlrun/data_types/to_pandas.py +10 -12
  51. mlrun/datastore/__init__.py +5 -8
  52. mlrun/datastore/alibaba_oss.py +130 -0
  53. mlrun/datastore/azure_blob.py +17 -5
  54. mlrun/datastore/base.py +62 -39
  55. mlrun/datastore/datastore.py +28 -9
  56. mlrun/datastore/datastore_profile.py +146 -20
  57. mlrun/datastore/filestore.py +0 -1
  58. mlrun/datastore/google_cloud_storage.py +6 -2
  59. mlrun/datastore/hdfs.py +56 -0
  60. mlrun/datastore/inmem.py +2 -2
  61. mlrun/datastore/redis.py +6 -2
  62. mlrun/datastore/s3.py +9 -0
  63. mlrun/datastore/snowflake_utils.py +43 -0
  64. mlrun/datastore/sources.py +201 -96
  65. mlrun/datastore/spark_utils.py +1 -2
  66. mlrun/datastore/store_resources.py +7 -7
  67. mlrun/datastore/targets.py +358 -104
  68. mlrun/datastore/utils.py +72 -58
  69. mlrun/datastore/v3io.py +5 -1
  70. mlrun/db/base.py +185 -35
  71. mlrun/db/factory.py +1 -1
  72. mlrun/db/httpdb.py +614 -179
  73. mlrun/db/nopdb.py +210 -26
  74. mlrun/errors.py +12 -1
  75. mlrun/execution.py +41 -24
  76. mlrun/feature_store/__init__.py +0 -2
  77. mlrun/feature_store/api.py +40 -72
  78. mlrun/feature_store/common.py +1 -1
  79. mlrun/feature_store/feature_set.py +76 -55
  80. mlrun/feature_store/feature_vector.py +28 -30
  81. mlrun/feature_store/ingestion.py +7 -6
  82. mlrun/feature_store/retrieval/base.py +16 -11
  83. mlrun/feature_store/retrieval/conversion.py +11 -13
  84. mlrun/feature_store/retrieval/dask_merger.py +2 -0
  85. mlrun/feature_store/retrieval/job.py +9 -3
  86. mlrun/feature_store/retrieval/local_merger.py +2 -0
  87. mlrun/feature_store/retrieval/spark_merger.py +34 -24
  88. mlrun/feature_store/steps.py +37 -34
  89. mlrun/features.py +9 -20
  90. mlrun/frameworks/_common/artifacts_library.py +9 -9
  91. mlrun/frameworks/_common/mlrun_interface.py +5 -5
  92. mlrun/frameworks/_common/model_handler.py +48 -48
  93. mlrun/frameworks/_common/plan.py +2 -3
  94. mlrun/frameworks/_common/producer.py +3 -4
  95. mlrun/frameworks/_common/utils.py +5 -5
  96. mlrun/frameworks/_dl_common/loggers/logger.py +6 -7
  97. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +9 -9
  98. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +23 -47
  99. mlrun/frameworks/_ml_common/artifacts_library.py +1 -2
  100. mlrun/frameworks/_ml_common/loggers/logger.py +3 -4
  101. mlrun/frameworks/_ml_common/loggers/mlrun_logger.py +4 -5
  102. mlrun/frameworks/_ml_common/model_handler.py +24 -24
  103. mlrun/frameworks/_ml_common/pkl_model_server.py +2 -2
  104. mlrun/frameworks/_ml_common/plan.py +1 -1
  105. mlrun/frameworks/_ml_common/plans/calibration_curve_plan.py +2 -3
  106. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +2 -3
  107. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  108. mlrun/frameworks/_ml_common/plans/feature_importance_plan.py +3 -3
  109. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  110. mlrun/frameworks/_ml_common/utils.py +4 -4
  111. mlrun/frameworks/auto_mlrun/auto_mlrun.py +9 -9
  112. mlrun/frameworks/huggingface/model_server.py +4 -4
  113. mlrun/frameworks/lgbm/__init__.py +33 -33
  114. mlrun/frameworks/lgbm/callbacks/callback.py +2 -4
  115. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -5
  116. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -5
  117. mlrun/frameworks/lgbm/mlrun_interfaces/booster_mlrun_interface.py +1 -3
  118. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +6 -6
  119. mlrun/frameworks/lgbm/model_handler.py +10 -10
  120. mlrun/frameworks/lgbm/model_server.py +6 -6
  121. mlrun/frameworks/lgbm/utils.py +5 -5
  122. mlrun/frameworks/onnx/dataset.py +8 -8
  123. mlrun/frameworks/onnx/mlrun_interface.py +3 -3
  124. mlrun/frameworks/onnx/model_handler.py +6 -6
  125. mlrun/frameworks/onnx/model_server.py +7 -7
  126. mlrun/frameworks/parallel_coordinates.py +4 -3
  127. mlrun/frameworks/pytorch/__init__.py +18 -18
  128. mlrun/frameworks/pytorch/callbacks/callback.py +4 -5
  129. mlrun/frameworks/pytorch/callbacks/logging_callback.py +17 -17
  130. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +11 -11
  131. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +23 -29
  132. mlrun/frameworks/pytorch/callbacks_handler.py +38 -38
  133. mlrun/frameworks/pytorch/mlrun_interface.py +20 -20
  134. mlrun/frameworks/pytorch/model_handler.py +17 -17
  135. mlrun/frameworks/pytorch/model_server.py +7 -7
  136. mlrun/frameworks/sklearn/__init__.py +13 -13
  137. mlrun/frameworks/sklearn/estimator.py +4 -4
  138. mlrun/frameworks/sklearn/metrics_library.py +14 -14
  139. mlrun/frameworks/sklearn/mlrun_interface.py +3 -6
  140. mlrun/frameworks/sklearn/model_handler.py +2 -2
  141. mlrun/frameworks/tf_keras/__init__.py +10 -7
  142. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +15 -15
  143. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +11 -11
  144. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +19 -23
  145. mlrun/frameworks/tf_keras/mlrun_interface.py +9 -11
  146. mlrun/frameworks/tf_keras/model_handler.py +14 -14
  147. mlrun/frameworks/tf_keras/model_server.py +6 -6
  148. mlrun/frameworks/xgboost/__init__.py +13 -13
  149. mlrun/frameworks/xgboost/model_handler.py +6 -6
  150. mlrun/k8s_utils.py +14 -16
  151. mlrun/launcher/__init__.py +1 -1
  152. mlrun/launcher/base.py +16 -15
  153. mlrun/launcher/client.py +8 -6
  154. mlrun/launcher/factory.py +1 -1
  155. mlrun/launcher/local.py +17 -11
  156. mlrun/launcher/remote.py +16 -10
  157. mlrun/lists.py +7 -6
  158. mlrun/model.py +238 -73
  159. mlrun/model_monitoring/__init__.py +1 -1
  160. mlrun/model_monitoring/api.py +138 -315
  161. mlrun/model_monitoring/application.py +5 -296
  162. mlrun/model_monitoring/applications/__init__.py +24 -0
  163. mlrun/model_monitoring/applications/_application_steps.py +157 -0
  164. mlrun/model_monitoring/applications/base.py +282 -0
  165. mlrun/model_monitoring/applications/context.py +214 -0
  166. mlrun/model_monitoring/applications/evidently_base.py +211 -0
  167. mlrun/model_monitoring/applications/histogram_data_drift.py +349 -0
  168. mlrun/model_monitoring/applications/results.py +99 -0
  169. mlrun/model_monitoring/controller.py +104 -84
  170. mlrun/model_monitoring/controller_handler.py +13 -5
  171. mlrun/model_monitoring/db/__init__.py +18 -0
  172. mlrun/model_monitoring/{stores → db/stores}/__init__.py +43 -36
  173. mlrun/model_monitoring/db/stores/base/__init__.py +15 -0
  174. mlrun/model_monitoring/{stores/model_endpoint_store.py → db/stores/base/store.py} +64 -40
  175. mlrun/model_monitoring/db/stores/sqldb/__init__.py +13 -0
  176. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +71 -0
  177. mlrun/model_monitoring/{stores → db/stores/sqldb}/models/base.py +109 -5
  178. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +88 -0
  179. mlrun/model_monitoring/{stores/models/mysql.py → db/stores/sqldb/models/sqlite.py} +19 -13
  180. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +684 -0
  181. mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +13 -0
  182. mlrun/model_monitoring/{stores/kv_model_endpoint_store.py → db/stores/v3io_kv/kv_store.py} +310 -165
  183. mlrun/model_monitoring/db/tsdb/__init__.py +100 -0
  184. mlrun/model_monitoring/db/tsdb/base.py +329 -0
  185. mlrun/model_monitoring/db/tsdb/helpers.py +30 -0
  186. mlrun/model_monitoring/db/tsdb/tdengine/__init__.py +15 -0
  187. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +240 -0
  188. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +45 -0
  189. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +397 -0
  190. mlrun/model_monitoring/db/tsdb/v3io/__init__.py +15 -0
  191. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +117 -0
  192. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +630 -0
  193. mlrun/model_monitoring/evidently_application.py +6 -118
  194. mlrun/model_monitoring/features_drift_table.py +134 -106
  195. mlrun/model_monitoring/helpers.py +127 -28
  196. mlrun/model_monitoring/metrics/__init__.py +13 -0
  197. mlrun/model_monitoring/metrics/histogram_distance.py +127 -0
  198. mlrun/model_monitoring/model_endpoint.py +3 -2
  199. mlrun/model_monitoring/prometheus.py +1 -4
  200. mlrun/model_monitoring/stream_processing.py +62 -231
  201. mlrun/model_monitoring/tracking_policy.py +9 -2
  202. mlrun/model_monitoring/writer.py +152 -124
  203. mlrun/package/__init__.py +6 -6
  204. mlrun/package/context_handler.py +5 -5
  205. mlrun/package/packager.py +7 -7
  206. mlrun/package/packagers/default_packager.py +6 -6
  207. mlrun/package/packagers/numpy_packagers.py +15 -15
  208. mlrun/package/packagers/pandas_packagers.py +5 -5
  209. mlrun/package/packagers/python_standard_library_packagers.py +10 -10
  210. mlrun/package/packagers_manager.py +19 -23
  211. mlrun/package/utils/_formatter.py +6 -6
  212. mlrun/package/utils/_pickler.py +2 -2
  213. mlrun/package/utils/_supported_format.py +4 -4
  214. mlrun/package/utils/log_hint_utils.py +2 -2
  215. mlrun/package/utils/type_hint_utils.py +4 -9
  216. mlrun/platforms/__init__.py +11 -10
  217. mlrun/platforms/iguazio.py +24 -203
  218. mlrun/projects/operations.py +35 -21
  219. mlrun/projects/pipelines.py +68 -99
  220. mlrun/projects/project.py +830 -266
  221. mlrun/render.py +3 -11
  222. mlrun/run.py +162 -166
  223. mlrun/runtimes/__init__.py +62 -7
  224. mlrun/runtimes/base.py +39 -32
  225. mlrun/runtimes/daskjob.py +8 -8
  226. mlrun/runtimes/databricks_job/databricks_cancel_task.py +1 -1
  227. mlrun/runtimes/databricks_job/databricks_runtime.py +7 -7
  228. mlrun/runtimes/databricks_job/databricks_wrapper.py +1 -1
  229. mlrun/runtimes/funcdoc.py +0 -28
  230. mlrun/runtimes/function_reference.py +1 -1
  231. mlrun/runtimes/kubejob.py +28 -122
  232. mlrun/runtimes/local.py +6 -3
  233. mlrun/runtimes/mpijob/__init__.py +0 -20
  234. mlrun/runtimes/mpijob/abstract.py +9 -10
  235. mlrun/runtimes/mpijob/v1.py +1 -1
  236. mlrun/{model_monitoring/stores/models/sqlite.py → runtimes/nuclio/__init__.py} +7 -9
  237. mlrun/runtimes/nuclio/api_gateway.py +709 -0
  238. mlrun/runtimes/nuclio/application/__init__.py +15 -0
  239. mlrun/runtimes/nuclio/application/application.py +523 -0
  240. mlrun/runtimes/nuclio/application/reverse_proxy.go +95 -0
  241. mlrun/runtimes/{function.py → nuclio/function.py} +112 -73
  242. mlrun/runtimes/{nuclio.py → nuclio/nuclio.py} +6 -6
  243. mlrun/runtimes/{serving.py → nuclio/serving.py} +45 -51
  244. mlrun/runtimes/pod.py +286 -88
  245. mlrun/runtimes/remotesparkjob.py +2 -2
  246. mlrun/runtimes/sparkjob/spark3job.py +51 -34
  247. mlrun/runtimes/utils.py +7 -75
  248. mlrun/secrets.py +9 -5
  249. mlrun/serving/remote.py +2 -7
  250. mlrun/serving/routers.py +13 -10
  251. mlrun/serving/server.py +22 -26
  252. mlrun/serving/states.py +99 -25
  253. mlrun/serving/utils.py +3 -3
  254. mlrun/serving/v1_serving.py +6 -7
  255. mlrun/serving/v2_serving.py +59 -20
  256. mlrun/track/tracker.py +2 -1
  257. mlrun/track/tracker_manager.py +3 -3
  258. mlrun/track/trackers/mlflow_tracker.py +1 -2
  259. mlrun/utils/async_http.py +5 -7
  260. mlrun/utils/azure_vault.py +1 -1
  261. mlrun/utils/clones.py +1 -2
  262. mlrun/utils/condition_evaluator.py +3 -3
  263. mlrun/utils/db.py +3 -3
  264. mlrun/utils/helpers.py +183 -197
  265. mlrun/utils/http.py +2 -5
  266. mlrun/utils/logger.py +76 -14
  267. mlrun/utils/notifications/notification/__init__.py +17 -12
  268. mlrun/utils/notifications/notification/base.py +14 -2
  269. mlrun/utils/notifications/notification/console.py +2 -0
  270. mlrun/utils/notifications/notification/git.py +3 -1
  271. mlrun/utils/notifications/notification/ipython.py +3 -1
  272. mlrun/utils/notifications/notification/slack.py +101 -21
  273. mlrun/utils/notifications/notification/webhook.py +11 -1
  274. mlrun/utils/notifications/notification_pusher.py +155 -30
  275. mlrun/utils/retryer.py +208 -0
  276. mlrun/utils/singleton.py +1 -1
  277. mlrun/utils/v3io_clients.py +2 -4
  278. mlrun/utils/version/version.json +2 -2
  279. mlrun/utils/version/version.py +2 -6
  280. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/METADATA +31 -19
  281. mlrun-1.7.0rc20.dist-info/RECORD +353 -0
  282. mlrun/kfpops.py +0 -868
  283. mlrun/model_monitoring/batch.py +0 -1095
  284. mlrun/model_monitoring/stores/models/__init__.py +0 -27
  285. mlrun/model_monitoring/stores/sql_model_endpoint_store.py +0 -384
  286. mlrun/platforms/other.py +0 -306
  287. mlrun-1.6.4rc2.dist-info/RECORD +0 -314
  288. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/LICENSE +0 -0
  289. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/WHEEL +0 -0
  290. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/entry_points.txt +0 -0
  291. {mlrun-1.6.4rc2.dist-info → mlrun-1.7.0rc20.dist-info}/top_level.txt +0 -0
mlrun/db/nopdb.py CHANGED
@@ -14,8 +14,11 @@
14
14
 
15
15
 
16
16
  import datetime
17
- from typing import List, Optional, Union
17
+ from typing import Optional, Union
18
18
 
19
+ import mlrun.alerts
20
+ import mlrun.common.formatters
21
+ import mlrun.common.runtimes.constants
19
22
  import mlrun.common.schemas
20
23
  import mlrun.errors
21
24
 
@@ -76,10 +79,13 @@ class NopDB(RunDBInterface):
76
79
  def list_runs(
77
80
  self,
78
81
  name: Optional[str] = None,
79
- uid: Optional[Union[str, List[str]]] = None,
82
+ uid: Optional[Union[str, list[str]]] = None,
80
83
  project: Optional[str] = None,
81
- labels: Optional[Union[str, List[str]]] = None,
82
- state: Optional[str] = None,
84
+ labels: Optional[Union[str, list[str]]] = None,
85
+ state: Optional[
86
+ mlrun.common.runtimes.constants.RunStates
87
+ ] = None, # Backward compatibility
88
+ states: Optional[list[mlrun.common.runtimes.constants.RunStates]] = None,
83
89
  sort: bool = True,
84
90
  last: int = 0,
85
91
  iter: bool = False,
@@ -128,7 +134,18 @@ class NopDB(RunDBInterface):
128
134
  ):
129
135
  pass
130
136
 
131
- def del_artifact(self, key, tag="", project="", tree=None, uid=None):
137
+ def del_artifact(
138
+ self,
139
+ key,
140
+ tag="",
141
+ project="",
142
+ tree=None,
143
+ uid=None,
144
+ deletion_strategy: mlrun.common.schemas.artifact.ArtifactsDeletionStrategies = (
145
+ mlrun.common.schemas.artifact.ArtifactsDeletionStrategies.metadata_only
146
+ ),
147
+ secrets: dict = None,
148
+ ):
132
149
  pass
133
150
 
134
151
  def del_artifacts(self, name="", project="", tag="", labels=None):
@@ -196,8 +213,8 @@ class NopDB(RunDBInterface):
196
213
  def list_projects(
197
214
  self,
198
215
  owner: str = None,
199
- format_: mlrun.common.schemas.ProjectsFormat = mlrun.common.schemas.ProjectsFormat.name_only,
200
- labels: List[str] = None,
216
+ format_: mlrun.common.formatters.ProjectFormat = mlrun.common.formatters.ProjectFormat.name_only,
217
+ labels: list[str] = None,
201
218
  state: mlrun.common.schemas.ProjectState = None,
202
219
  ) -> mlrun.common.schemas.ProjectsOutput:
203
220
  pass
@@ -230,13 +247,13 @@ class NopDB(RunDBInterface):
230
247
  project: str,
231
248
  name: str = None,
232
249
  tag: str = None,
233
- entities: List[str] = None,
234
- labels: List[str] = None,
250
+ entities: list[str] = None,
251
+ labels: list[str] = None,
235
252
  ) -> mlrun.common.schemas.FeaturesOutput:
236
253
  pass
237
254
 
238
255
  def list_entities(
239
- self, project: str, name: str = None, tag: str = None, labels: List[str] = None
256
+ self, project: str, name: str = None, tag: str = None, labels: list[str] = None
240
257
  ) -> mlrun.common.schemas.EntitiesOutput:
241
258
  pass
242
259
 
@@ -246,9 +263,9 @@ class NopDB(RunDBInterface):
246
263
  name: str = None,
247
264
  tag: str = None,
248
265
  state: str = None,
249
- entities: List[str] = None,
250
- features: List[str] = None,
251
- labels: List[str] = None,
266
+ entities: list[str] = None,
267
+ features: list[str] = None,
268
+ labels: list[str] = None,
252
269
  partition_by: Union[
253
270
  mlrun.common.schemas.FeatureStorePartitionByField, str
254
271
  ] = None,
@@ -257,7 +274,7 @@ class NopDB(RunDBInterface):
257
274
  partition_order: Union[
258
275
  mlrun.common.schemas.OrderType, str
259
276
  ] = mlrun.common.schemas.OrderType.desc,
260
- ) -> List[dict]:
277
+ ) -> list[dict]:
261
278
  pass
262
279
 
263
280
  def store_feature_set(
@@ -306,7 +323,7 @@ class NopDB(RunDBInterface):
306
323
  name: str = None,
307
324
  tag: str = None,
308
325
  state: str = None,
309
- labels: List[str] = None,
326
+ labels: list[str] = None,
310
327
  partition_by: Union[
311
328
  mlrun.common.schemas.FeatureStorePartitionByField, str
312
329
  ] = None,
@@ -315,7 +332,7 @@ class NopDB(RunDBInterface):
315
332
  partition_order: Union[
316
333
  mlrun.common.schemas.OrderType, str
317
334
  ] = mlrun.common.schemas.OrderType.desc,
318
- ) -> List[dict]:
335
+ ) -> list[dict]:
319
336
  pass
320
337
 
321
338
  def store_feature_vector(
@@ -351,8 +368,8 @@ class NopDB(RunDBInterface):
351
368
  namespace: str = None,
352
369
  timeout: int = 30,
353
370
  format_: Union[
354
- str, mlrun.common.schemas.PipelinesFormat
355
- ] = mlrun.common.schemas.PipelinesFormat.summary,
371
+ str, mlrun.common.formatters.PipelineFormat
372
+ ] = mlrun.common.formatters.PipelineFormat.summary,
356
373
  project: str = None,
357
374
  ):
358
375
  pass
@@ -365,8 +382,8 @@ class NopDB(RunDBInterface):
365
382
  page_token: str = "",
366
383
  filter_: str = "",
367
384
  format_: Union[
368
- str, mlrun.common.schemas.PipelinesFormat
369
- ] = mlrun.common.schemas.PipelinesFormat.metadata_only,
385
+ str, mlrun.common.formatters.PipelineFormat
386
+ ] = mlrun.common.formatters.PipelineFormat.metadata_only,
370
387
  page_size: int = None,
371
388
  ) -> mlrun.common.schemas.PipelinesOutput:
372
389
  pass
@@ -388,7 +405,7 @@ class NopDB(RunDBInterface):
388
405
  provider: Union[
389
406
  str, mlrun.common.schemas.SecretProviderName
390
407
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
391
- secrets: List[str] = None,
408
+ secrets: list[str] = None,
392
409
  ) -> mlrun.common.schemas.SecretsData:
393
410
  pass
394
411
 
@@ -408,7 +425,7 @@ class NopDB(RunDBInterface):
408
425
  provider: Union[
409
426
  str, mlrun.common.schemas.SecretProviderName
410
427
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
411
- secrets: List[str] = None,
428
+ secrets: list[str] = None,
412
429
  ):
413
430
  pass
414
431
 
@@ -438,10 +455,10 @@ class NopDB(RunDBInterface):
438
455
  project: str,
439
456
  model: Optional[str] = None,
440
457
  function: Optional[str] = None,
441
- labels: List[str] = None,
458
+ labels: list[str] = None,
442
459
  start: str = "now-1h",
443
460
  end: str = "now",
444
- metrics: Optional[List[str]] = None,
461
+ metrics: Optional[list[str]] = None,
445
462
  ):
446
463
  pass
447
464
 
@@ -451,7 +468,7 @@ class NopDB(RunDBInterface):
451
468
  endpoint_id: str,
452
469
  start: Optional[str] = None,
453
470
  end: Optional[str] = None,
454
- metrics: Optional[List[str]] = None,
471
+ metrics: Optional[list[str]] = None,
455
472
  features: bool = False,
456
473
  ):
457
474
  pass
@@ -506,12 +523,100 @@ class NopDB(RunDBInterface):
506
523
  ):
507
524
  pass
508
525
 
526
+ def store_api_gateway(
527
+ self,
528
+ api_gateway: Union[
529
+ mlrun.common.schemas.APIGateway,
530
+ mlrun.runtimes.nuclio.api_gateway.APIGateway,
531
+ ],
532
+ project: str = None,
533
+ ) -> mlrun.common.schemas.APIGateway:
534
+ pass
535
+
536
+ def list_api_gateways(self, project=None):
537
+ pass
538
+
539
+ def get_api_gateway(self, name, project=None):
540
+ pass
541
+
542
+ def delete_api_gateway(self, name, project=None):
543
+ pass
544
+
509
545
  def verify_authorization(
510
546
  self,
511
547
  authorization_verification_input: mlrun.common.schemas.AuthorizationVerificationInput,
512
548
  ):
513
549
  pass
514
550
 
551
+ def remote_builder(
552
+ self,
553
+ func: "mlrun.runtimes.BaseRuntime",
554
+ with_mlrun: bool,
555
+ mlrun_version_specifier: Optional[str] = None,
556
+ skip_deployed: bool = False,
557
+ builder_env: Optional[dict] = None,
558
+ force_build: bool = False,
559
+ ):
560
+ pass
561
+
562
+ def deploy_nuclio_function(
563
+ self,
564
+ func: "mlrun.runtimes.RemoteRuntime",
565
+ builder_env: Optional[dict] = None,
566
+ ):
567
+ pass
568
+
569
+ def get_builder_status(
570
+ self,
571
+ func: "mlrun.runtimes.BaseRuntime",
572
+ offset: int = 0,
573
+ logs: bool = True,
574
+ last_log_timestamp: float = 0.0,
575
+ verbose: bool = False,
576
+ ):
577
+ pass
578
+
579
+ def get_nuclio_deploy_status(
580
+ self,
581
+ func: "mlrun.runtimes.RemoteRuntime",
582
+ last_log_timestamp: float = 0.0,
583
+ verbose: bool = False,
584
+ ):
585
+ pass
586
+
587
+ def set_run_notifications(
588
+ self,
589
+ project: str,
590
+ runs: list[mlrun.model.RunObject],
591
+ notifications: list[mlrun.model.Notification],
592
+ ):
593
+ pass
594
+
595
+ def store_run_notifications(
596
+ self,
597
+ notification_objects: list[mlrun.model.Notification],
598
+ run_uid: str,
599
+ project: str = None,
600
+ mask_params: bool = True,
601
+ ):
602
+ pass
603
+
604
+ def store_alert_notifications(
605
+ self,
606
+ session,
607
+ notification_objects: list[mlrun.model.Notification],
608
+ alert_id: str,
609
+ project: str,
610
+ mask_params: bool = True,
611
+ ):
612
+ pass
613
+
614
+ def get_log_size(self, uid, project=""):
615
+ pass
616
+
617
+ def watch_log(self, uid, project="", watch=True, offset=0):
618
+ pass
619
+
515
620
  def get_datastore_profile(
516
621
  self, name: str, project: str
517
622
  ) -> Optional[mlrun.common.schemas.DatastoreProfile]:
@@ -522,10 +627,89 @@ class NopDB(RunDBInterface):
522
627
 
523
628
  def list_datastore_profiles(
524
629
  self, project: str
525
- ) -> List[mlrun.common.schemas.DatastoreProfile]:
630
+ ) -> list[mlrun.common.schemas.DatastoreProfile]:
526
631
  pass
527
632
 
528
633
  def store_datastore_profile(
529
634
  self, profile: mlrun.common.schemas.DatastoreProfile, project: str
530
635
  ):
531
636
  pass
637
+
638
+ def function_status(self, project, name, kind, selector):
639
+ pass
640
+
641
+ def start_function(
642
+ self, func_url: str = None, function: "mlrun.runtimes.BaseRuntime" = None
643
+ ):
644
+ pass
645
+
646
+ def submit_workflow(
647
+ self,
648
+ project: str,
649
+ name: str,
650
+ workflow_spec: Union[
651
+ "mlrun.projects.pipelines.WorkflowSpec",
652
+ "mlrun.common.schemas.WorkflowSpec",
653
+ dict,
654
+ ],
655
+ arguments: Optional[dict] = None,
656
+ artifact_path: Optional[str] = None,
657
+ source: Optional[str] = None,
658
+ run_name: Optional[str] = None,
659
+ namespace: Optional[str] = None,
660
+ notifications: list["mlrun.model.Notification"] = None,
661
+ ) -> "mlrun.common.schemas.WorkflowResponse":
662
+ pass
663
+
664
+ def update_model_monitoring_controller(
665
+ self,
666
+ project: str,
667
+ base_period: int = 10,
668
+ image: str = "mlrun/mlrun",
669
+ ):
670
+ pass
671
+
672
+ def enable_model_monitoring(
673
+ self,
674
+ project: str,
675
+ base_period: int = 10,
676
+ image: str = "mlrun/mlrun",
677
+ deploy_histogram_data_drift_app: bool = True,
678
+ ) -> None:
679
+ pass
680
+
681
+ def deploy_histogram_data_drift_app(
682
+ self, project: str, image: str = "mlrun/mlrun"
683
+ ) -> None:
684
+ raise NotImplementedError
685
+
686
+ def generate_event(
687
+ self, name: str, event_data: Union[dict, mlrun.common.schemas.Event], project=""
688
+ ):
689
+ pass
690
+
691
+ def store_alert_config(
692
+ self,
693
+ alert_name: str,
694
+ alert_data: Union[dict, mlrun.alerts.alert.AlertConfig],
695
+ project="",
696
+ ):
697
+ pass
698
+
699
+ def get_alert_config(self, alert_name: str, project=""):
700
+ pass
701
+
702
+ def list_alerts_configs(self, project=""):
703
+ pass
704
+
705
+ def delete_alert_config(self, alert_name: str, project=""):
706
+ pass
707
+
708
+ def reset_alert_config(self, alert_name: str, project=""):
709
+ pass
710
+
711
+ def get_alert_template(self, template_name: str):
712
+ pass
713
+
714
+ def list_alert_templates(self):
715
+ pass
mlrun/errors.py CHANGED
@@ -73,7 +73,7 @@ class MLRunHTTPStatusError(MLRunHTTPError):
73
73
  error_status_code = None
74
74
 
75
75
  def __init__(self, *args, response: requests.Response = None, **kwargs):
76
- super(MLRunHTTPStatusError, self).__init__(
76
+ super().__init__(
77
77
  *args, response=response, status_code=self.error_status_code, **kwargs
78
78
  )
79
79
 
@@ -155,6 +155,10 @@ class MLRunNotFoundError(MLRunHTTPStatusError):
155
155
  error_status_code = HTTPStatus.NOT_FOUND.value
156
156
 
157
157
 
158
+ class MLRunPaginationEndOfResultsError(MLRunNotFoundError):
159
+ pass
160
+
161
+
158
162
  class MLRunBadRequestError(MLRunHTTPStatusError):
159
163
  error_status_code = HTTPStatus.BAD_REQUEST.value
160
164
 
@@ -183,6 +187,10 @@ class MLRunInternalServerError(MLRunHTTPStatusError):
183
187
  error_status_code = HTTPStatus.INTERNAL_SERVER_ERROR.value
184
188
 
185
189
 
190
+ class MLRunNotImplementedServerError(MLRunHTTPStatusError):
191
+ error_status_code = HTTPStatus.NOT_IMPLEMENTED.value
192
+
193
+
186
194
  class MLRunServiceUnavailableError(MLRunHTTPStatusError):
187
195
  error_status_code = HTTPStatus.SERVICE_UNAVAILABLE.value
188
196
 
@@ -234,4 +242,7 @@ STATUS_ERRORS = {
234
242
  HTTPStatus.PRECONDITION_FAILED.value: MLRunPreconditionFailedError,
235
243
  HTTPStatus.INTERNAL_SERVER_ERROR.value: MLRunInternalServerError,
236
244
  HTTPStatus.SERVICE_UNAVAILABLE.value: MLRunServiceUnavailableError,
245
+ HTTPStatus.NOT_IMPLEMENTED.value: MLRunNotImplementedServerError,
237
246
  }
247
+
248
+ EXPECTED_ERRORS = (MLRunPaginationEndOfResultsError,)
mlrun/execution.py CHANGED
@@ -15,13 +15,14 @@
15
15
  import os
16
16
  import uuid
17
17
  from copy import deepcopy
18
- from typing import List, Union
18
+ from typing import Union
19
19
 
20
20
  import numpy as np
21
21
  import yaml
22
22
  from dateutil import parser
23
23
 
24
24
  import mlrun
25
+ import mlrun.common.constants as mlrun_constants
25
26
  from mlrun.artifacts import ModelArtifact
26
27
  from mlrun.datastore.store_resources import get_store_resource
27
28
  from mlrun.errors import MLRunInvalidArgumentError
@@ -45,7 +46,7 @@ from .utils import (
45
46
  )
46
47
 
47
48
 
48
- class MLClientCtx(object):
49
+ class MLClientCtx:
49
50
  """ML Execution Client Context
50
51
 
51
52
  The context is generated and injected to the function using the ``function.run()``
@@ -129,7 +130,9 @@ class MLClientCtx(object):
129
130
  @property
130
131
  def tag(self):
131
132
  """Run tag (uid or workflow id if exists)"""
132
- return self._labels.get("workflow") or self._uid
133
+ return (
134
+ self._labels.get(mlrun_constants.MLRunInternalLabels.workflow) or self._uid
135
+ )
133
136
 
134
137
  @property
135
138
  def state(self):
@@ -224,12 +227,12 @@ class MLClientCtx(object):
224
227
  with context.get_child_context(myparam=param) as child:
225
228
  accuracy = child_handler(child, df, **child.parameters)
226
229
  accuracy_sum += accuracy
227
- child.log_result('accuracy', accuracy)
230
+ child.log_result("accuracy", accuracy)
228
231
  if accuracy > best_accuracy:
229
232
  child.mark_as_best()
230
233
  best_accuracy = accuracy
231
234
 
232
- context.log_result('avg_accuracy', accuracy_sum / len(param_list))
235
+ context.log_result("avg_accuracy", accuracy_sum / len(param_list))
233
236
 
234
237
  :param params: Extra (or override) params to parent context
235
238
  :param with_parent_params: Child will copy the parent parameters and add to them
@@ -289,7 +292,9 @@ class MLClientCtx(object):
289
292
 
290
293
  Example::
291
294
 
292
- feature_vector = context.get_store_resource("store://feature-vectors/default/myvec")
295
+ feature_vector = context.get_store_resource(
296
+ "store://feature-vectors/default/myvec"
297
+ )
293
298
  dataset = context.get_store_resource("store://artifacts/default/mydata")
294
299
 
295
300
  :param url: Store resource uri/path, store://<type>/<project>/<name>:<version>
@@ -327,8 +332,10 @@ class MLClientCtx(object):
327
332
  "uri": uri,
328
333
  "owner": get_in(self._labels, "owner"),
329
334
  }
330
- if "workflow" in self._labels:
331
- resp["workflow"] = self._labels["workflow"]
335
+ if mlrun_constants.MLRunInternalLabels.workflow in self._labels:
336
+ resp[mlrun_constants.MLRunInternalLabels.workflow] = self._labels[
337
+ mlrun_constants.MLRunInternalLabels.workflow
338
+ ]
332
339
  return resp
333
340
 
334
341
  @classmethod
@@ -394,7 +401,7 @@ class MLClientCtx(object):
394
401
  self._set_input(k, v)
395
402
 
396
403
  if host and not is_api:
397
- self.set_label("host", host)
404
+ self.set_label(mlrun_constants.MLRunInternalLabels.host, host)
398
405
 
399
406
  start = get_in(attrs, "status.start_time")
400
407
  if start:
@@ -421,7 +428,7 @@ class MLClientCtx(object):
421
428
 
422
429
  Example::
423
430
 
424
- data_path=context.artifact_subpath('data')
431
+ data_path = context.artifact_subpath("data")
425
432
 
426
433
  """
427
434
  return os.path.join(self.artifact_path, *subpaths)
@@ -525,7 +532,7 @@ class MLClientCtx(object):
525
532
 
526
533
  Example::
527
534
 
528
- context.log_result('accuracy', 0.85)
535
+ context.log_result("accuracy", 0.85)
529
536
 
530
537
  :param key: Result key
531
538
  :param value: Result value
@@ -539,7 +546,7 @@ class MLClientCtx(object):
539
546
 
540
547
  Example::
541
548
 
542
- context.log_results({'accuracy': 0.85, 'loss': 0.2})
549
+ context.log_results({"accuracy": 0.85, "loss": 0.2})
543
550
 
544
551
  :param results: Key/value dict or results
545
552
  :param commit: Commit (write to DB now vs wait for the end of the run)
@@ -674,7 +681,9 @@ class MLClientCtx(object):
674
681
  "age": [42, 52, 36, 24, 73],
675
682
  "testScore": [25, 94, 57, 62, 70],
676
683
  }
677
- df = pd.DataFrame(raw_data, columns=["first_name", "last_name", "age", "testScore"])
684
+ df = pd.DataFrame(
685
+ raw_data, columns=["first_name", "last_name", "age", "testScore"]
686
+ )
678
687
  context.log_dataset("mydf", df=df, stats=True)
679
688
 
680
689
  :param key: Artifact key
@@ -738,8 +747,8 @@ class MLClientCtx(object):
738
747
  artifact_path=None,
739
748
  upload=True,
740
749
  labels=None,
741
- inputs: List[Feature] = None,
742
- outputs: List[Feature] = None,
750
+ inputs: list[Feature] = None,
751
+ outputs: list[Feature] = None,
743
752
  feature_vector: str = None,
744
753
  feature_weights: list = None,
745
754
  training_set=None,
@@ -752,13 +761,16 @@ class MLClientCtx(object):
752
761
 
753
762
  Example::
754
763
 
755
- context.log_model("model", body=dumps(model),
756
- model_file="model.pkl",
757
- metrics=context.results,
758
- training_set=training_df,
759
- label_column='label',
760
- feature_vector=feature_vector_uri,
761
- labels={"app": "fraud"})
764
+ context.log_model(
765
+ "model",
766
+ body=dumps(model),
767
+ model_file="model.pkl",
768
+ metrics=context.results,
769
+ training_set=training_df,
770
+ label_column="label",
771
+ feature_vector=feature_vector_uri,
772
+ labels={"app": "fraud"},
773
+ )
762
774
 
763
775
  :param key: Artifact key or artifact class ()
764
776
  :param body: Will use the body as the artifact content
@@ -983,10 +995,15 @@ class MLClientCtx(object):
983
995
  # If it's a OpenMPI job, get the global rank and compare to the logging rank (worker) set in MLRun's
984
996
  # configuration:
985
997
  labels = self.labels
986
- if "host" in labels and labels.get("kind", "job") == "mpijob":
998
+ if (
999
+ mlrun_constants.MLRunInternalLabels.host in labels
1000
+ and labels.get(mlrun_constants.MLRunInternalLabels.kind, "job") == "mpijob"
1001
+ ):
987
1002
  # The host (pod name) of each worker is created by k8s, and by default it uses the rank number as the id in
988
1003
  # the following template: ...-worker-<rank>
989
- rank = int(labels["host"].rsplit("-", 1)[1])
1004
+ rank = int(
1005
+ labels[mlrun_constants.MLRunInternalLabels.host].rsplit("-", 1)[1]
1006
+ )
990
1007
  return rank == mlrun.mlconf.packagers.logging_worker
991
1008
 
992
1009
  # Single worker is always the logging worker:
@@ -19,7 +19,6 @@ __all__ = [
19
19
  "get_online_feature_service",
20
20
  "ingest",
21
21
  "preview",
22
- "deploy_ingestion_service",
23
22
  "deploy_ingestion_service_v2",
24
23
  "delete_feature_set",
25
24
  "delete_feature_vector",
@@ -41,7 +40,6 @@ from ..features import Entity, Feature
41
40
  from .api import (
42
41
  delete_feature_set,
43
42
  delete_feature_vector,
44
- deploy_ingestion_service,
45
43
  deploy_ingestion_service_v2,
46
44
  get_feature_set,
47
45
  get_feature_vector,