mlrun 1.7.2rc3__py3-none-any.whl → 1.8.0rc2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mlrun might be problematic. Click here for more details.

Files changed (250) hide show
  1. mlrun/__init__.py +18 -18
  2. mlrun/__main__.py +3 -3
  3. mlrun/alerts/alert.py +19 -12
  4. mlrun/artifacts/__init__.py +0 -2
  5. mlrun/artifacts/base.py +34 -11
  6. mlrun/artifacts/dataset.py +16 -16
  7. mlrun/artifacts/manager.py +13 -13
  8. mlrun/artifacts/model.py +66 -53
  9. mlrun/common/constants.py +6 -0
  10. mlrun/common/formatters/__init__.py +1 -0
  11. mlrun/common/formatters/feature_set.py +1 -0
  12. mlrun/common/formatters/function.py +1 -0
  13. mlrun/common/formatters/model_endpoint.py +30 -0
  14. mlrun/common/formatters/pipeline.py +1 -2
  15. mlrun/common/formatters/project.py +9 -0
  16. mlrun/common/model_monitoring/__init__.py +0 -3
  17. mlrun/common/model_monitoring/helpers.py +1 -1
  18. mlrun/common/runtimes/constants.py +1 -2
  19. mlrun/common/schemas/__init__.py +7 -2
  20. mlrun/common/schemas/alert.py +31 -18
  21. mlrun/common/schemas/api_gateway.py +3 -3
  22. mlrun/common/schemas/artifact.py +7 -13
  23. mlrun/common/schemas/auth.py +6 -4
  24. mlrun/common/schemas/background_task.py +7 -7
  25. mlrun/common/schemas/client_spec.py +2 -2
  26. mlrun/common/schemas/clusterization_spec.py +2 -2
  27. mlrun/common/schemas/common.py +53 -3
  28. mlrun/common/schemas/datastore_profile.py +1 -1
  29. mlrun/common/schemas/feature_store.py +9 -9
  30. mlrun/common/schemas/frontend_spec.py +4 -4
  31. mlrun/common/schemas/function.py +10 -10
  32. mlrun/common/schemas/hub.py +1 -1
  33. mlrun/common/schemas/k8s.py +3 -3
  34. mlrun/common/schemas/memory_reports.py +3 -3
  35. mlrun/common/schemas/model_monitoring/__init__.py +8 -1
  36. mlrun/common/schemas/model_monitoring/constants.py +62 -12
  37. mlrun/common/schemas/model_monitoring/grafana.py +1 -1
  38. mlrun/common/schemas/model_monitoring/model_endpoint_v2.py +149 -0
  39. mlrun/common/schemas/model_monitoring/model_endpoints.py +22 -6
  40. mlrun/common/schemas/notification.py +18 -3
  41. mlrun/common/schemas/object.py +1 -1
  42. mlrun/common/schemas/pagination.py +4 -4
  43. mlrun/common/schemas/partition.py +137 -0
  44. mlrun/common/schemas/pipeline.py +2 -2
  45. mlrun/common/schemas/project.py +22 -17
  46. mlrun/common/schemas/runs.py +2 -2
  47. mlrun/common/schemas/runtime_resource.py +5 -5
  48. mlrun/common/schemas/schedule.py +1 -1
  49. mlrun/common/schemas/secret.py +1 -1
  50. mlrun/common/schemas/tag.py +3 -3
  51. mlrun/common/schemas/workflow.py +5 -5
  52. mlrun/config.py +65 -15
  53. mlrun/data_types/__init__.py +0 -2
  54. mlrun/data_types/data_types.py +0 -1
  55. mlrun/data_types/infer.py +3 -1
  56. mlrun/data_types/spark.py +4 -4
  57. mlrun/data_types/to_pandas.py +2 -11
  58. mlrun/datastore/__init__.py +0 -2
  59. mlrun/datastore/alibaba_oss.py +4 -1
  60. mlrun/datastore/azure_blob.py +4 -1
  61. mlrun/datastore/base.py +12 -4
  62. mlrun/datastore/datastore.py +9 -3
  63. mlrun/datastore/datastore_profile.py +20 -20
  64. mlrun/datastore/dbfs_store.py +4 -1
  65. mlrun/datastore/filestore.py +4 -1
  66. mlrun/datastore/google_cloud_storage.py +4 -1
  67. mlrun/datastore/hdfs.py +4 -1
  68. mlrun/datastore/inmem.py +4 -1
  69. mlrun/datastore/redis.py +4 -1
  70. mlrun/datastore/s3.py +4 -1
  71. mlrun/datastore/sources.py +51 -49
  72. mlrun/datastore/store_resources.py +0 -2
  73. mlrun/datastore/targets.py +22 -23
  74. mlrun/datastore/utils.py +2 -2
  75. mlrun/datastore/v3io.py +4 -1
  76. mlrun/datastore/wasbfs/fs.py +13 -12
  77. mlrun/db/base.py +170 -64
  78. mlrun/db/factory.py +3 -0
  79. mlrun/db/httpdb.py +986 -238
  80. mlrun/db/nopdb.py +155 -57
  81. mlrun/errors.py +2 -2
  82. mlrun/execution.py +55 -29
  83. mlrun/feature_store/__init__.py +0 -2
  84. mlrun/feature_store/api.py +40 -40
  85. mlrun/feature_store/common.py +9 -9
  86. mlrun/feature_store/feature_set.py +20 -18
  87. mlrun/feature_store/feature_vector.py +27 -24
  88. mlrun/feature_store/retrieval/base.py +14 -9
  89. mlrun/feature_store/retrieval/job.py +2 -1
  90. mlrun/feature_store/steps.py +2 -2
  91. mlrun/features.py +30 -13
  92. mlrun/frameworks/__init__.py +1 -2
  93. mlrun/frameworks/_common/__init__.py +1 -2
  94. mlrun/frameworks/_common/artifacts_library.py +2 -2
  95. mlrun/frameworks/_common/mlrun_interface.py +10 -6
  96. mlrun/frameworks/_common/model_handler.py +29 -27
  97. mlrun/frameworks/_common/producer.py +3 -1
  98. mlrun/frameworks/_dl_common/__init__.py +1 -2
  99. mlrun/frameworks/_dl_common/loggers/__init__.py +1 -2
  100. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +4 -4
  101. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +3 -3
  102. mlrun/frameworks/_ml_common/__init__.py +1 -2
  103. mlrun/frameworks/_ml_common/loggers/__init__.py +1 -2
  104. mlrun/frameworks/_ml_common/model_handler.py +21 -21
  105. mlrun/frameworks/_ml_common/plans/__init__.py +1 -2
  106. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +3 -1
  107. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  108. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  109. mlrun/frameworks/auto_mlrun/__init__.py +1 -2
  110. mlrun/frameworks/auto_mlrun/auto_mlrun.py +22 -15
  111. mlrun/frameworks/huggingface/__init__.py +1 -2
  112. mlrun/frameworks/huggingface/model_server.py +9 -9
  113. mlrun/frameworks/lgbm/__init__.py +47 -44
  114. mlrun/frameworks/lgbm/callbacks/__init__.py +1 -2
  115. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -2
  116. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -2
  117. mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -2
  118. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +5 -5
  119. mlrun/frameworks/lgbm/model_handler.py +15 -11
  120. mlrun/frameworks/lgbm/model_server.py +11 -7
  121. mlrun/frameworks/lgbm/utils.py +2 -2
  122. mlrun/frameworks/onnx/__init__.py +1 -2
  123. mlrun/frameworks/onnx/dataset.py +3 -3
  124. mlrun/frameworks/onnx/mlrun_interface.py +2 -2
  125. mlrun/frameworks/onnx/model_handler.py +7 -5
  126. mlrun/frameworks/onnx/model_server.py +8 -6
  127. mlrun/frameworks/parallel_coordinates.py +11 -11
  128. mlrun/frameworks/pytorch/__init__.py +22 -23
  129. mlrun/frameworks/pytorch/callbacks/__init__.py +1 -2
  130. mlrun/frameworks/pytorch/callbacks/callback.py +2 -1
  131. mlrun/frameworks/pytorch/callbacks/logging_callback.py +15 -8
  132. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +19 -12
  133. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +22 -15
  134. mlrun/frameworks/pytorch/callbacks_handler.py +36 -30
  135. mlrun/frameworks/pytorch/mlrun_interface.py +17 -17
  136. mlrun/frameworks/pytorch/model_handler.py +21 -17
  137. mlrun/frameworks/pytorch/model_server.py +13 -9
  138. mlrun/frameworks/sklearn/__init__.py +19 -18
  139. mlrun/frameworks/sklearn/estimator.py +2 -2
  140. mlrun/frameworks/sklearn/metric.py +3 -3
  141. mlrun/frameworks/sklearn/metrics_library.py +8 -6
  142. mlrun/frameworks/sklearn/mlrun_interface.py +3 -2
  143. mlrun/frameworks/sklearn/model_handler.py +4 -3
  144. mlrun/frameworks/tf_keras/__init__.py +11 -12
  145. mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -2
  146. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +17 -14
  147. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +15 -12
  148. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +21 -18
  149. mlrun/frameworks/tf_keras/model_handler.py +17 -13
  150. mlrun/frameworks/tf_keras/model_server.py +12 -8
  151. mlrun/frameworks/xgboost/__init__.py +19 -18
  152. mlrun/frameworks/xgboost/model_handler.py +13 -9
  153. mlrun/launcher/base.py +3 -4
  154. mlrun/launcher/local.py +1 -1
  155. mlrun/launcher/remote.py +1 -1
  156. mlrun/lists.py +4 -3
  157. mlrun/model.py +110 -46
  158. mlrun/model_monitoring/__init__.py +1 -2
  159. mlrun/model_monitoring/api.py +6 -6
  160. mlrun/model_monitoring/applications/_application_steps.py +13 -15
  161. mlrun/model_monitoring/applications/histogram_data_drift.py +41 -15
  162. mlrun/model_monitoring/applications/results.py +55 -3
  163. mlrun/model_monitoring/controller.py +185 -223
  164. mlrun/model_monitoring/db/_schedules.py +156 -0
  165. mlrun/model_monitoring/db/_stats.py +189 -0
  166. mlrun/model_monitoring/db/stores/__init__.py +1 -1
  167. mlrun/model_monitoring/db/stores/base/store.py +6 -65
  168. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -25
  169. mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -97
  170. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +2 -58
  171. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -15
  172. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +6 -257
  173. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +9 -271
  174. mlrun/model_monitoring/db/tsdb/base.py +76 -24
  175. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +61 -6
  176. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
  177. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +253 -28
  178. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
  179. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +35 -17
  180. mlrun/model_monitoring/helpers.py +91 -1
  181. mlrun/model_monitoring/model_endpoint.py +4 -2
  182. mlrun/model_monitoring/stream_processing.py +16 -13
  183. mlrun/model_monitoring/tracking_policy.py +10 -3
  184. mlrun/model_monitoring/writer.py +47 -26
  185. mlrun/package/__init__.py +3 -6
  186. mlrun/package/context_handler.py +1 -1
  187. mlrun/package/packager.py +12 -9
  188. mlrun/package/packagers/__init__.py +0 -2
  189. mlrun/package/packagers/default_packager.py +14 -11
  190. mlrun/package/packagers/numpy_packagers.py +16 -7
  191. mlrun/package/packagers/pandas_packagers.py +18 -18
  192. mlrun/package/packagers/python_standard_library_packagers.py +25 -11
  193. mlrun/package/packagers_manager.py +31 -14
  194. mlrun/package/utils/__init__.py +0 -3
  195. mlrun/package/utils/_pickler.py +6 -6
  196. mlrun/platforms/__init__.py +3 -16
  197. mlrun/platforms/iguazio.py +4 -1
  198. mlrun/projects/operations.py +27 -27
  199. mlrun/projects/pipelines.py +34 -35
  200. mlrun/projects/project.py +535 -182
  201. mlrun/run.py +13 -10
  202. mlrun/runtimes/__init__.py +1 -3
  203. mlrun/runtimes/base.py +15 -11
  204. mlrun/runtimes/daskjob.py +9 -9
  205. mlrun/runtimes/generators.py +2 -1
  206. mlrun/runtimes/kubejob.py +4 -5
  207. mlrun/runtimes/mounts.py +572 -0
  208. mlrun/runtimes/mpijob/__init__.py +0 -2
  209. mlrun/runtimes/mpijob/abstract.py +7 -6
  210. mlrun/runtimes/nuclio/api_gateway.py +7 -7
  211. mlrun/runtimes/nuclio/application/application.py +11 -11
  212. mlrun/runtimes/nuclio/function.py +13 -13
  213. mlrun/runtimes/nuclio/serving.py +9 -9
  214. mlrun/runtimes/pod.py +154 -45
  215. mlrun/runtimes/remotesparkjob.py +3 -2
  216. mlrun/runtimes/sparkjob/__init__.py +0 -2
  217. mlrun/runtimes/sparkjob/spark3job.py +21 -11
  218. mlrun/runtimes/utils.py +6 -5
  219. mlrun/serving/merger.py +6 -4
  220. mlrun/serving/remote.py +18 -17
  221. mlrun/serving/routers.py +27 -27
  222. mlrun/serving/server.py +1 -1
  223. mlrun/serving/states.py +76 -71
  224. mlrun/serving/utils.py +13 -2
  225. mlrun/serving/v1_serving.py +3 -2
  226. mlrun/serving/v2_serving.py +4 -4
  227. mlrun/track/__init__.py +1 -1
  228. mlrun/track/tracker.py +2 -2
  229. mlrun/track/trackers/mlflow_tracker.py +6 -5
  230. mlrun/utils/async_http.py +1 -1
  231. mlrun/utils/helpers.py +70 -16
  232. mlrun/utils/logger.py +106 -4
  233. mlrun/utils/notifications/notification/__init__.py +22 -19
  234. mlrun/utils/notifications/notification/base.py +33 -14
  235. mlrun/utils/notifications/notification/console.py +6 -6
  236. mlrun/utils/notifications/notification/git.py +11 -11
  237. mlrun/utils/notifications/notification/ipython.py +10 -9
  238. mlrun/utils/notifications/notification/mail.py +149 -0
  239. mlrun/utils/notifications/notification/slack.py +6 -6
  240. mlrun/utils/notifications/notification/webhook.py +18 -22
  241. mlrun/utils/notifications/notification_pusher.py +43 -31
  242. mlrun/utils/regex.py +3 -1
  243. mlrun/utils/version/version.json +2 -2
  244. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/METADATA +18 -14
  245. mlrun-1.8.0rc2.dist-info/RECORD +358 -0
  246. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/WHEEL +1 -1
  247. mlrun-1.7.2rc3.dist-info/RECORD +0 -351
  248. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/LICENSE +0 -0
  249. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/entry_points.txt +0 -0
  250. {mlrun-1.7.2rc3.dist-info → mlrun-1.8.0rc2.dist-info}/top_level.txt +0 -0
mlrun/db/nopdb.py CHANGED
@@ -104,7 +104,7 @@ class NopDB(RunDBInterface):
104
104
  name: Optional[str] = None,
105
105
  uid: Optional[Union[str, list[str]]] = None,
106
106
  project: Optional[str] = None,
107
- labels: Optional[Union[str, list[str]]] = None,
107
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
108
108
  state: Optional[
109
109
  mlrun.common.runtimes.constants.RunStates
110
110
  ] = None, # Backward compatibility
@@ -112,10 +112,10 @@ class NopDB(RunDBInterface):
112
112
  sort: bool = True,
113
113
  last: int = 0,
114
114
  iter: bool = False,
115
- start_time_from: datetime.datetime = None,
116
- start_time_to: datetime.datetime = None,
117
- last_update_time_from: datetime.datetime = None,
118
- last_update_time_to: datetime.datetime = None,
115
+ start_time_from: Optional[datetime.datetime] = None,
116
+ start_time_to: Optional[datetime.datetime] = None,
117
+ last_update_time_from: Optional[datetime.datetime] = None,
118
+ last_update_time_to: Optional[datetime.datetime] = None,
119
119
  partition_by: Union[mlrun.common.schemas.RunPartitionByField, str] = None,
120
120
  rows_per_partition: int = 1,
121
121
  partition_sort_by: Union[mlrun.common.schemas.SortField, str] = None,
@@ -127,10 +127,27 @@ class NopDB(RunDBInterface):
127
127
  ):
128
128
  return mlrun.lists.RunList()
129
129
 
130
+ def paginated_list_runs(
131
+ self,
132
+ *args,
133
+ page: Optional[int] = None,
134
+ page_size: Optional[int] = None,
135
+ page_token: Optional[str] = None,
136
+ **kwargs,
137
+ ):
138
+ return mlrun.lists.RunList(), None
139
+
130
140
  def del_run(self, uid, project="", iter=0):
131
141
  pass
132
142
 
133
- def del_runs(self, name="", project="", labels=None, state="", days_ago=0):
143
+ def del_runs(
144
+ self,
145
+ name: str = "",
146
+ project: str = "",
147
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
148
+ state: Optional[mlrun.common.runtimes.constants.RunStates] = None,
149
+ days_ago: int = 0,
150
+ ):
134
151
  pass
135
152
 
136
153
  def store_artifact(
@@ -155,19 +172,29 @@ class NopDB(RunDBInterface):
155
172
  name="",
156
173
  project="",
157
174
  tag="",
158
- labels=None,
175
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
159
176
  since=None,
160
177
  until=None,
161
- iter: int = None,
178
+ iter: Optional[int] = None,
162
179
  best_iteration: bool = False,
163
- kind: str = None,
180
+ kind: Optional[str] = None,
164
181
  category: Union[str, mlrun.common.schemas.ArtifactCategories] = None,
165
- tree: str = None,
182
+ tree: Optional[str] = None,
166
183
  format_: mlrun.common.formatters.ArtifactFormat = mlrun.common.formatters.ArtifactFormat.full,
167
- limit: int = None,
184
+ limit: Optional[int] = None,
168
185
  ):
169
186
  return mlrun.lists.ArtifactList()
170
187
 
188
+ def paginated_list_artifacts(
189
+ self,
190
+ *args,
191
+ page: Optional[int] = None,
192
+ page_size: Optional[int] = None,
193
+ page_token: Optional[str] = None,
194
+ **kwargs,
195
+ ):
196
+ return mlrun.lists.ArtifactList(), None
197
+
171
198
  def del_artifact(
172
199
  self,
173
200
  key,
@@ -178,12 +205,18 @@ class NopDB(RunDBInterface):
178
205
  deletion_strategy: mlrun.common.schemas.artifact.ArtifactsDeletionStrategies = (
179
206
  mlrun.common.schemas.artifact.ArtifactsDeletionStrategies.metadata_only
180
207
  ),
181
- secrets: dict = None,
208
+ secrets: Optional[dict] = None,
182
209
  iter=None,
183
210
  ):
184
211
  pass
185
212
 
186
- def del_artifacts(self, name="", project="", tag="", labels=None):
213
+ def del_artifacts(
214
+ self,
215
+ name="",
216
+ project="",
217
+ tag="",
218
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
219
+ ):
187
220
  pass
188
221
 
189
222
  def store_function(self, function, name, project="", tag="", versioned=False):
@@ -196,10 +229,28 @@ class NopDB(RunDBInterface):
196
229
  pass
197
230
 
198
231
  def list_functions(
199
- self, name=None, project="", tag="", labels=None, since=None, until=None
232
+ self,
233
+ name: Optional[str] = None,
234
+ project: Optional[str] = None,
235
+ tag: Optional[str] = None,
236
+ kind: Optional[str] = None,
237
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
238
+ format_: mlrun.common.formatters.FunctionFormat = mlrun.common.formatters.FunctionFormat.full,
239
+ since: Optional[datetime.datetime] = None,
240
+ until: Optional[datetime.datetime] = None,
200
241
  ):
201
242
  return []
202
243
 
244
+ def paginated_list_functions(
245
+ self,
246
+ *args,
247
+ page: Optional[int] = None,
248
+ page_size: Optional[int] = None,
249
+ page_token: Optional[str] = None,
250
+ **kwargs,
251
+ ):
252
+ return [], None
253
+
203
254
  def tag_objects(
204
255
  self,
205
256
  project: str,
@@ -249,9 +300,9 @@ class NopDB(RunDBInterface):
249
300
 
250
301
  def list_projects(
251
302
  self,
252
- owner: str = None,
303
+ owner: Optional[str] = None,
253
304
  format_: mlrun.common.formatters.ProjectFormat = mlrun.common.formatters.ProjectFormat.name_only,
254
- labels: list[str] = None,
305
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
255
306
  state: mlrun.common.schemas.ProjectState = None,
256
307
  ) -> mlrun.common.schemas.ProjectsOutput:
257
308
  pass
@@ -275,49 +326,61 @@ class NopDB(RunDBInterface):
275
326
  pass
276
327
 
277
328
  def get_feature_set(
278
- self, name: str, project: str = "", tag: str = None, uid: str = None
329
+ self,
330
+ name: str,
331
+ project: str = "",
332
+ tag: Optional[str] = None,
333
+ uid: Optional[str] = None,
279
334
  ) -> dict:
280
335
  pass
281
336
 
282
337
  def list_features(
283
338
  self,
284
339
  project: str,
285
- name: str = None,
286
- tag: str = None,
287
- entities: list[str] = None,
288
- labels: list[str] = None,
340
+ name: Optional[str] = None,
341
+ tag: Optional[str] = None,
342
+ entities: Optional[list[str]] = None,
343
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
289
344
  ) -> mlrun.common.schemas.FeaturesOutput:
290
345
  pass
291
346
 
292
347
  def list_features_v2(
293
348
  self,
294
349
  project: str,
295
- name: str = None,
296
- tag: str = None,
297
- entities: list[str] = None,
298
- labels: list[str] = None,
350
+ name: Optional[str] = None,
351
+ tag: Optional[str] = None,
352
+ entities: Optional[list[str]] = None,
353
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
299
354
  ) -> mlrun.common.schemas.FeaturesOutputV2:
300
355
  pass
301
356
 
302
357
  def list_entities(
303
- self, project: str, name: str = None, tag: str = None, labels: list[str] = None
358
+ self,
359
+ project: str,
360
+ name: Optional[str] = None,
361
+ tag: Optional[str] = None,
362
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
304
363
  ) -> mlrun.common.schemas.EntitiesOutput:
305
364
  pass
306
365
 
307
366
  def list_entities_v2(
308
- self, project: str, name: str = None, tag: str = None, labels: list[str] = None
367
+ self,
368
+ project: str,
369
+ name: Optional[str] = None,
370
+ tag: Optional[str] = None,
371
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
309
372
  ) -> mlrun.common.schemas.EntitiesOutputV2:
310
373
  pass
311
374
 
312
375
  def list_feature_sets(
313
376
  self,
314
377
  project: str = "",
315
- name: str = None,
316
- tag: str = None,
317
- state: str = None,
318
- entities: list[str] = None,
319
- features: list[str] = None,
320
- labels: list[str] = None,
378
+ name: Optional[str] = None,
379
+ tag: Optional[str] = None,
380
+ state: Optional[str] = None,
381
+ entities: Optional[list[str]] = None,
382
+ features: Optional[list[str]] = None,
383
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
321
384
  partition_by: Union[
322
385
  mlrun.common.schemas.FeatureStorePartitionByField, str
323
386
  ] = None,
@@ -368,17 +431,21 @@ class NopDB(RunDBInterface):
368
431
  pass
369
432
 
370
433
  def get_feature_vector(
371
- self, name: str, project: str = "", tag: str = None, uid: str = None
434
+ self,
435
+ name: str,
436
+ project: str = "",
437
+ tag: Optional[str] = None,
438
+ uid: Optional[str] = None,
372
439
  ) -> dict:
373
440
  pass
374
441
 
375
442
  def list_feature_vectors(
376
443
  self,
377
444
  project: str = "",
378
- name: str = None,
379
- tag: str = None,
380
- state: str = None,
381
- labels: list[str] = None,
445
+ name: Optional[str] = None,
446
+ tag: Optional[str] = None,
447
+ state: Optional[str] = None,
448
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
382
449
  partition_by: Union[
383
450
  mlrun.common.schemas.FeatureStorePartitionByField, str
384
451
  ] = None,
@@ -420,26 +487,26 @@ class NopDB(RunDBInterface):
420
487
  def get_pipeline(
421
488
  self,
422
489
  run_id: str,
423
- namespace: str = None,
490
+ namespace: Optional[str] = None,
424
491
  timeout: int = 30,
425
492
  format_: Union[
426
493
  str, mlrun.common.formatters.PipelineFormat
427
494
  ] = mlrun.common.formatters.PipelineFormat.summary,
428
- project: str = None,
495
+ project: Optional[str] = None,
429
496
  ):
430
497
  pass
431
498
 
432
499
  def list_pipelines(
433
500
  self,
434
501
  project: str,
435
- namespace: str = None,
502
+ namespace: Optional[str] = None,
436
503
  sort_by: str = "",
437
504
  page_token: str = "",
438
505
  filter_: str = "",
439
506
  format_: Union[
440
507
  str, mlrun.common.formatters.PipelineFormat
441
508
  ] = mlrun.common.formatters.PipelineFormat.metadata_only,
442
- page_size: int = None,
509
+ page_size: Optional[int] = None,
443
510
  ) -> mlrun.common.schemas.PipelinesOutput:
444
511
  return mlrun.common.schemas.PipelinesOutput(runs=[], total_size=0)
445
512
 
@@ -449,7 +516,7 @@ class NopDB(RunDBInterface):
449
516
  provider: Union[
450
517
  str, mlrun.common.schemas.SecretProviderName
451
518
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
452
- secrets: dict = None,
519
+ secrets: Optional[dict] = None,
453
520
  ):
454
521
  pass
455
522
 
@@ -460,7 +527,7 @@ class NopDB(RunDBInterface):
460
527
  provider: Union[
461
528
  str, mlrun.common.schemas.SecretProviderName
462
529
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
463
- secrets: list[str] = None,
530
+ secrets: Optional[list[str]] = None,
464
531
  ) -> mlrun.common.schemas.SecretsData:
465
532
  pass
466
533
 
@@ -470,7 +537,7 @@ class NopDB(RunDBInterface):
470
537
  provider: Union[
471
538
  str, mlrun.common.schemas.SecretProviderName
472
539
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
473
- token: str = None,
540
+ token: Optional[str] = None,
474
541
  ) -> mlrun.common.schemas.SecretKeysData:
475
542
  pass
476
543
 
@@ -480,7 +547,7 @@ class NopDB(RunDBInterface):
480
547
  provider: Union[
481
548
  str, mlrun.common.schemas.SecretProviderName
482
549
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
483
- secrets: list[str] = None,
550
+ secrets: Optional[list[str]] = None,
484
551
  ):
485
552
  pass
486
553
 
@@ -490,7 +557,7 @@ class NopDB(RunDBInterface):
490
557
  provider: Union[
491
558
  str, mlrun.common.schemas.SecretProviderName
492
559
  ] = mlrun.common.schemas.SecretProviderName.vault,
493
- secrets: dict = None,
560
+ secrets: Optional[dict] = None,
494
561
  ):
495
562
  pass
496
563
 
@@ -510,7 +577,7 @@ class NopDB(RunDBInterface):
510
577
  project: str,
511
578
  model: Optional[str] = None,
512
579
  function: Optional[str] = None,
513
- labels: list[str] = None,
580
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
514
581
  start: str = "now-1h",
515
582
  end: str = "now",
516
583
  metrics: Optional[list[str]] = None,
@@ -560,9 +627,9 @@ class NopDB(RunDBInterface):
560
627
  def get_hub_catalog(
561
628
  self,
562
629
  source_name: str,
563
- channel: str = None,
564
- version: str = None,
565
- tag: str = None,
630
+ channel: Optional[str] = None,
631
+ version: Optional[str] = None,
632
+ tag: Optional[str] = None,
566
633
  force_refresh: bool = False,
567
634
  ):
568
635
  pass
@@ -572,7 +639,7 @@ class NopDB(RunDBInterface):
572
639
  source_name: str,
573
640
  item_name: str,
574
641
  channel: str = "development",
575
- version: str = None,
642
+ version: Optional[str] = None,
576
643
  tag: str = "latest",
577
644
  force_refresh: bool = False,
578
645
  ):
@@ -584,7 +651,7 @@ class NopDB(RunDBInterface):
584
651
  mlrun.common.schemas.APIGateway,
585
652
  mlrun.runtimes.nuclio.api_gateway.APIGateway,
586
653
  ],
587
- project: str = None,
654
+ project: Optional[str] = None,
588
655
  ) -> mlrun.common.schemas.APIGateway:
589
656
  pass
590
657
 
@@ -628,6 +695,7 @@ class NopDB(RunDBInterface):
628
695
  logs: bool = True,
629
696
  last_log_timestamp: float = 0.0,
630
697
  verbose: bool = False,
698
+ events_offset: int = 0,
631
699
  ):
632
700
  pass
633
701
 
@@ -651,7 +719,7 @@ class NopDB(RunDBInterface):
651
719
  self,
652
720
  notification_objects: list[mlrun.model.Notification],
653
721
  run_uid: str,
654
- project: str = None,
722
+ project: Optional[str] = None,
655
723
  mask_params: bool = True,
656
724
  ):
657
725
  pass
@@ -694,7 +762,9 @@ class NopDB(RunDBInterface):
694
762
  pass
695
763
 
696
764
  def start_function(
697
- self, func_url: str = None, function: "mlrun.runtimes.BaseRuntime" = None
765
+ self,
766
+ func_url: Optional[str] = None,
767
+ function: "mlrun.runtimes.BaseRuntime" = None,
698
768
  ):
699
769
  pass
700
770
 
@@ -712,7 +782,7 @@ class NopDB(RunDBInterface):
712
782
  source: Optional[str] = None,
713
783
  run_name: Optional[str] = None,
714
784
  namespace: Optional[str] = None,
715
- notifications: list["mlrun.model.Notification"] = None,
785
+ notifications: Optional[list["mlrun.model.Notification"]] = None,
716
786
  ) -> "mlrun.common.schemas.WorkflowResponse":
717
787
  pass
718
788
 
@@ -742,7 +812,7 @@ class NopDB(RunDBInterface):
742
812
  delete_stream_function: bool = False,
743
813
  delete_histogram_data_drift_app: bool = True,
744
814
  delete_user_applications: bool = False,
745
- user_application_list: list[str] = None,
815
+ user_application_list: Optional[list[str]] = None,
746
816
  ) -> bool:
747
817
  pass
748
818
 
@@ -774,6 +844,7 @@ class NopDB(RunDBInterface):
774
844
  alert_name: str,
775
845
  alert_data: Union[dict, mlrun.alerts.alert.AlertConfig],
776
846
  project="",
847
+ force_reset: bool = False,
777
848
  ):
778
849
  pass
779
850
 
@@ -794,3 +865,30 @@ class NopDB(RunDBInterface):
794
865
 
795
866
  def list_alert_templates(self):
796
867
  pass
868
+
869
+ def list_alert_activations(
870
+ self,
871
+ project: Optional[str] = None,
872
+ name: Optional[str] = None,
873
+ since: Optional[datetime.datetime] = None,
874
+ until: Optional[datetime.datetime] = None,
875
+ entity: Optional[str] = None,
876
+ severity: Optional[
877
+ list[Union[mlrun.common.schemas.alert.AlertSeverity, str]]
878
+ ] = None,
879
+ entity_kind: Optional[
880
+ Union[mlrun.common.schemas.alert.EventEntityKind, str]
881
+ ] = None,
882
+ event_kind: Optional[Union[mlrun.common.schemas.alert.EventKind, str]] = None,
883
+ ):
884
+ pass
885
+
886
+ def paginated_list_alert_activations(
887
+ self,
888
+ *args,
889
+ page: Optional[int] = None,
890
+ page_size: Optional[int] = None,
891
+ page_token: Optional[str] = None,
892
+ **kwargs,
893
+ ):
894
+ pass
mlrun/errors.py CHANGED
@@ -86,7 +86,7 @@ def raise_for_status(
86
86
  requests.Response,
87
87
  aiohttp.ClientResponse,
88
88
  ],
89
- message: str = None,
89
+ message: typing.Optional[str] = None,
90
90
  ):
91
91
  """
92
92
  Raise a specific MLRunSDK error depending on the given response status code.
@@ -107,7 +107,7 @@ def raise_for_status(
107
107
  raise MLRunHTTPError(error_message, response=response) from exc
108
108
 
109
109
 
110
- def err_for_status_code(status_code: int, message: str = None):
110
+ def err_for_status_code(status_code: int, message: typing.Optional[str] = None):
111
111
  """
112
112
  Return a specific MLRunSDK error depending on the given response status code.
113
113
  If no specific error exists, returns an MLRunHTTPError.
mlrun/execution.py CHANGED
@@ -15,8 +15,9 @@
15
15
  import logging
16
16
  import os
17
17
  import uuid
18
+ import warnings
18
19
  from copy import deepcopy
19
- from typing import Union
20
+ from typing import Optional, Union
20
21
 
21
22
  import numpy as np
22
23
  import yaml
@@ -25,11 +26,10 @@ from dateutil import parser
25
26
  import mlrun
26
27
  import mlrun.common.constants as mlrun_constants
27
28
  import mlrun.common.formatters
28
- from mlrun.artifacts import ModelArtifact
29
+ from mlrun.artifacts import Artifact, DatasetArtifact, ModelArtifact
29
30
  from mlrun.datastore.store_resources import get_store_resource
30
31
  from mlrun.errors import MLRunInvalidArgumentError
31
32
 
32
- from .artifacts import DatasetArtifact
33
33
  from .artifacts.manager import ArtifactManager, dict_to_artifact, extend_artifact_path
34
34
  from .datastore import store_manager
35
35
  from .features import Feature
@@ -194,6 +194,11 @@ class MLClientCtx:
194
194
  """Dictionary of artifacts (read-only)"""
195
195
  return deepcopy(self._artifacts_manager.artifact_list())
196
196
 
197
+ @property
198
+ def artifact_uris(self):
199
+ """Dictionary of artifact URIs (read-only)"""
200
+ return deepcopy(self._artifacts_manager.artifact_uris)
201
+
197
202
  @property
198
203
  def in_path(self):
199
204
  """Default input path for data objects"""
@@ -296,7 +301,7 @@ class MLClientCtx:
296
301
  )
297
302
  self._parent.log_iteration_results(self._iteration, None, self.to_dict())
298
303
 
299
- def get_store_resource(self, url, secrets: dict = None):
304
+ def get_store_resource(self, url, secrets: Optional[dict] = None):
300
305
  """Get mlrun data resource (feature set/vector, artifact, item) from url.
301
306
 
302
307
  Example::
@@ -317,7 +322,7 @@ class MLClientCtx:
317
322
  data_store_secrets=secrets,
318
323
  )
319
324
 
320
- def get_dataitem(self, url, secrets: dict = None):
325
+ def get_dataitem(self, url, secrets: Optional[dict] = None):
321
326
  """Get mlrun dataitem from url
322
327
 
323
328
  Example::
@@ -425,8 +430,11 @@ class MLClientCtx:
425
430
  self._results = status.get("results", self._results)
426
431
  for artifact in status.get("artifacts", []):
427
432
  artifact_obj = dict_to_artifact(artifact)
428
- key = artifact_obj.key
429
- self._artifacts_manager.artifacts[key] = artifact_obj
433
+ self._artifacts_manager.artifact_uris[artifact_obj.key] = (
434
+ artifact_obj.uri
435
+ )
436
+ for key, uri in status.get("artifact_uris", {}).items():
437
+ self._artifacts_manager.artifact_uris[key] = uri
430
438
  self._state = status.get("state", self._state)
431
439
 
432
440
  # No need to store the run for every worker
@@ -573,22 +581,25 @@ class MLClientCtx:
573
581
  """Reserved for internal use"""
574
582
 
575
583
  if best:
584
+ # Recreate the best iteration context for the interface of getting its artifacts
585
+ best_context = MLClientCtx.from_dict(
586
+ task, store_run=False, include_status=True
587
+ )
576
588
  self._results["best_iteration"] = best
577
- for k, v in get_in(task, ["status", "results"], {}).items():
578
- self._results[k] = v
579
- for artifact in get_in(task, ["status", RunKeys.artifacts], []):
580
- self._artifacts_manager.artifacts[artifact["metadata"]["key"]] = (
581
- artifact
582
- )
589
+ for key, result in best_context.results.items():
590
+ self._results[key] = result
591
+ for key, artifact_uri in best_context.artifact_uris.items():
592
+ self._artifacts_manager.artifact_uris[key] = artifact_uri
593
+ artifact = best_context.get_artifact(key)
583
594
  self._artifacts_manager.link_artifact(
584
595
  self.project,
585
596
  self.name,
586
597
  self.tag,
587
- artifact["metadata"]["key"],
598
+ key,
588
599
  self.iteration,
589
- artifact["spec"]["target_path"],
600
+ artifact.target_path,
601
+ db_key=artifact.db_key,
590
602
  link_iteration=best,
591
- db_key=artifact["spec"]["db_key"],
592
603
  )
593
604
 
594
605
  if summary is not None:
@@ -679,7 +690,7 @@ class MLClientCtx:
679
690
  db_key=None,
680
691
  target_path="",
681
692
  extra_data=None,
682
- label_column: str = None,
693
+ label_column: Optional[str] = None,
683
694
  **kwargs,
684
695
  ):
685
696
  """Log a dataset artifact and optionally upload it to datastore
@@ -760,12 +771,12 @@ class MLClientCtx:
760
771
  artifact_path=None,
761
772
  upload=True,
762
773
  labels=None,
763
- inputs: list[Feature] = None,
764
- outputs: list[Feature] = None,
765
- feature_vector: str = None,
766
- feature_weights: list = None,
774
+ inputs: Optional[list[Feature]] = None,
775
+ outputs: Optional[list[Feature]] = None,
776
+ feature_vector: Optional[str] = None,
777
+ feature_weights: Optional[list] = None,
767
778
  training_set=None,
768
- label_column: Union[str, list] = None,
779
+ label_column: Optional[Union[str, list]] = None,
769
780
  extra_data=None,
770
781
  db_key=None,
771
782
  **kwargs,
@@ -788,7 +799,7 @@ class MLClientCtx:
788
799
  :param key: Artifact key or artifact class ()
789
800
  :param body: Will use the body as the artifact content
790
801
  :param model_file: Path to the local model file we upload (see also model_dir)
791
- or to a model file data url (e.g. http://host/path/model.pkl)
802
+ or to a model file data url (e.g. `http://host/path/model.pkl`)
792
803
  :param model_dir: Path to the local dir holding the model file and extra files
793
804
  :param artifact_path: Target artifact path (when not using the default)
794
805
  to define a subpath under the default location use:
@@ -852,10 +863,18 @@ class MLClientCtx:
852
863
 
853
864
  def get_cached_artifact(self, key):
854
865
  """Return a logged artifact from cache (for potential updates)"""
855
- return self._artifacts_manager.artifacts[key]
866
+ warnings.warn(
867
+ "get_cached_artifact is deprecated in 1.8.0 and will be removed in 1.10.0. Use get_artifact instead.",
868
+ FutureWarning,
869
+ )
870
+ return self.get_artifact(key)
871
+
872
+ def get_artifact(self, key: str) -> Artifact:
873
+ artifact_uri = self._artifacts_manager.artifact_uris[key]
874
+ return self.get_store_resource(artifact_uri)
856
875
 
857
- def update_artifact(self, artifact_object):
858
- """Update an artifact object in the cache and the DB"""
876
+ def update_artifact(self, artifact_object: Artifact):
877
+ """Update an artifact object in the DB and the cached uri"""
859
878
  self._artifacts_manager.update_artifact(self, artifact_object)
860
879
 
861
880
  def commit(self, message: str = "", completed=False):
@@ -885,7 +904,12 @@ class MLClientCtx:
885
904
  if completed and not self.iteration:
886
905
  mlrun.runtimes.utils.global_context.set(None)
887
906
 
888
- def set_state(self, execution_state: str = None, error: str = None, commit=True):
907
+ def set_state(
908
+ self,
909
+ execution_state: Optional[str] = None,
910
+ error: Optional[str] = None,
911
+ commit=True,
912
+ ):
889
913
  """
890
914
  Modify and store the execution state or mark an error and update the run state accordingly.
891
915
  This method allows to set the run state to 'completed' in the DB which is discouraged.
@@ -1013,7 +1037,7 @@ class MLClientCtx:
1013
1037
  set_if_not_none(struct["status"], "commit", self._commit)
1014
1038
  set_if_not_none(struct["status"], "iterations", self._iteration_results)
1015
1039
 
1016
- struct["status"][RunKeys.artifacts] = self._artifacts_manager.artifact_list()
1040
+ struct["status"][RunKeys.artifact_uris] = self._artifacts_manager.artifact_uris
1017
1041
  self._data_stores.to_dict(struct["spec"])
1018
1042
  return struct
1019
1043
 
@@ -1107,7 +1131,9 @@ class MLClientCtx:
1107
1131
  set_if_not_none(struct, "status.commit", self._commit)
1108
1132
  set_if_not_none(struct, "status.iterations", self._iteration_results)
1109
1133
 
1110
- struct[f"status.{RunKeys.artifacts}"] = self._artifacts_manager.artifact_list()
1134
+ struct[f"status.{RunKeys.artifact_uris}"] = (
1135
+ self._artifacts_manager.artifact_uris
1136
+ )
1111
1137
  return struct
1112
1138
 
1113
1139
  def _init_dbs(self, rundb):
@@ -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
16
-
17
15
  __all__ = [
18
16
  "get_offline_features",
19
17
  "get_online_feature_service",