mlrun 1.7.1rc10__py3-none-any.whl → 1.8.0rc8__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 (257) 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 +1 -2
  5. mlrun/artifacts/base.py +46 -12
  6. mlrun/artifacts/dataset.py +16 -16
  7. mlrun/artifacts/document.py +334 -0
  8. mlrun/artifacts/manager.py +15 -13
  9. mlrun/artifacts/model.py +66 -53
  10. mlrun/common/constants.py +7 -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 +66 -14
  39. mlrun/common/schemas/model_monitoring/grafana.py +1 -1
  40. mlrun/common/schemas/model_monitoring/model_endpoints.py +91 -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 +67 -10
  54. mlrun/data_types/__init__.py +0 -2
  55. mlrun/data_types/infer.py +3 -1
  56. mlrun/data_types/spark.py +2 -1
  57. mlrun/datastore/__init__.py +0 -2
  58. mlrun/datastore/alibaba_oss.py +4 -1
  59. mlrun/datastore/azure_blob.py +4 -1
  60. mlrun/datastore/base.py +12 -4
  61. mlrun/datastore/datastore.py +9 -3
  62. mlrun/datastore/datastore_profile.py +79 -20
  63. mlrun/datastore/dbfs_store.py +4 -1
  64. mlrun/datastore/filestore.py +4 -1
  65. mlrun/datastore/google_cloud_storage.py +4 -1
  66. mlrun/datastore/hdfs.py +4 -1
  67. mlrun/datastore/inmem.py +4 -1
  68. mlrun/datastore/redis.py +4 -1
  69. mlrun/datastore/s3.py +4 -1
  70. mlrun/datastore/sources.py +52 -51
  71. mlrun/datastore/store_resources.py +0 -2
  72. mlrun/datastore/targets.py +21 -21
  73. mlrun/datastore/utils.py +2 -2
  74. mlrun/datastore/v3io.py +4 -1
  75. mlrun/datastore/vectorstore.py +194 -0
  76. mlrun/datastore/wasbfs/fs.py +13 -12
  77. mlrun/db/base.py +208 -82
  78. mlrun/db/factory.py +0 -3
  79. mlrun/db/httpdb.py +1237 -386
  80. mlrun/db/nopdb.py +201 -74
  81. mlrun/errors.py +2 -2
  82. mlrun/execution.py +136 -50
  83. mlrun/feature_store/__init__.py +0 -2
  84. mlrun/feature_store/api.py +41 -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 +117 -46
  158. mlrun/model_monitoring/__init__.py +4 -4
  159. mlrun/model_monitoring/api.py +61 -59
  160. mlrun/model_monitoring/applications/_application_steps.py +17 -17
  161. mlrun/model_monitoring/applications/base.py +165 -6
  162. mlrun/model_monitoring/applications/context.py +88 -37
  163. mlrun/model_monitoring/applications/evidently_base.py +0 -1
  164. mlrun/model_monitoring/applications/histogram_data_drift.py +43 -21
  165. mlrun/model_monitoring/applications/results.py +55 -3
  166. mlrun/model_monitoring/controller.py +207 -239
  167. mlrun/model_monitoring/db/__init__.py +0 -2
  168. mlrun/model_monitoring/db/_schedules.py +156 -0
  169. mlrun/model_monitoring/db/_stats.py +189 -0
  170. mlrun/model_monitoring/db/tsdb/base.py +78 -25
  171. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +61 -6
  172. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
  173. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +255 -29
  174. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
  175. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +78 -17
  176. mlrun/model_monitoring/helpers.py +152 -49
  177. mlrun/model_monitoring/stream_processing.py +99 -283
  178. mlrun/model_monitoring/tracking_policy.py +10 -3
  179. mlrun/model_monitoring/writer.py +48 -36
  180. mlrun/package/__init__.py +3 -6
  181. mlrun/package/context_handler.py +1 -1
  182. mlrun/package/packager.py +12 -9
  183. mlrun/package/packagers/__init__.py +0 -2
  184. mlrun/package/packagers/default_packager.py +14 -11
  185. mlrun/package/packagers/numpy_packagers.py +16 -7
  186. mlrun/package/packagers/pandas_packagers.py +18 -18
  187. mlrun/package/packagers/python_standard_library_packagers.py +25 -11
  188. mlrun/package/packagers_manager.py +31 -14
  189. mlrun/package/utils/__init__.py +0 -3
  190. mlrun/package/utils/_pickler.py +6 -6
  191. mlrun/platforms/__init__.py +47 -16
  192. mlrun/platforms/iguazio.py +4 -1
  193. mlrun/projects/operations.py +27 -27
  194. mlrun/projects/pipelines.py +71 -36
  195. mlrun/projects/project.py +865 -206
  196. mlrun/run.py +53 -10
  197. mlrun/runtimes/__init__.py +1 -3
  198. mlrun/runtimes/base.py +15 -11
  199. mlrun/runtimes/daskjob.py +9 -9
  200. mlrun/runtimes/generators.py +2 -1
  201. mlrun/runtimes/kubejob.py +4 -5
  202. mlrun/runtimes/mounts.py +572 -0
  203. mlrun/runtimes/mpijob/__init__.py +0 -2
  204. mlrun/runtimes/mpijob/abstract.py +7 -6
  205. mlrun/runtimes/nuclio/api_gateway.py +7 -7
  206. mlrun/runtimes/nuclio/application/application.py +11 -11
  207. mlrun/runtimes/nuclio/function.py +19 -17
  208. mlrun/runtimes/nuclio/serving.py +18 -11
  209. mlrun/runtimes/pod.py +154 -45
  210. mlrun/runtimes/remotesparkjob.py +3 -2
  211. mlrun/runtimes/sparkjob/__init__.py +0 -2
  212. mlrun/runtimes/sparkjob/spark3job.py +21 -11
  213. mlrun/runtimes/utils.py +6 -5
  214. mlrun/serving/merger.py +6 -4
  215. mlrun/serving/remote.py +18 -17
  216. mlrun/serving/routers.py +185 -172
  217. mlrun/serving/server.py +7 -1
  218. mlrun/serving/states.py +97 -78
  219. mlrun/serving/utils.py +13 -2
  220. mlrun/serving/v1_serving.py +3 -2
  221. mlrun/serving/v2_serving.py +74 -65
  222. mlrun/track/__init__.py +1 -1
  223. mlrun/track/tracker.py +2 -2
  224. mlrun/track/trackers/mlflow_tracker.py +6 -5
  225. mlrun/utils/async_http.py +1 -1
  226. mlrun/utils/clones.py +1 -1
  227. mlrun/utils/helpers.py +54 -16
  228. mlrun/utils/logger.py +106 -4
  229. mlrun/utils/notifications/notification/__init__.py +22 -19
  230. mlrun/utils/notifications/notification/base.py +33 -14
  231. mlrun/utils/notifications/notification/console.py +6 -6
  232. mlrun/utils/notifications/notification/git.py +11 -11
  233. mlrun/utils/notifications/notification/ipython.py +10 -9
  234. mlrun/utils/notifications/notification/mail.py +176 -0
  235. mlrun/utils/notifications/notification/slack.py +6 -6
  236. mlrun/utils/notifications/notification/webhook.py +6 -6
  237. mlrun/utils/notifications/notification_pusher.py +86 -44
  238. mlrun/utils/regex.py +3 -1
  239. mlrun/utils/version/version.json +2 -2
  240. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/METADATA +21 -16
  241. mlrun-1.8.0rc8.dist-info/RECORD +347 -0
  242. mlrun/model_monitoring/db/stores/__init__.py +0 -136
  243. mlrun/model_monitoring/db/stores/base/store.py +0 -213
  244. mlrun/model_monitoring/db/stores/sqldb/__init__.py +0 -13
  245. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -71
  246. mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -190
  247. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +0 -103
  248. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -40
  249. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +0 -659
  250. mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +0 -13
  251. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +0 -726
  252. mlrun/model_monitoring/model_endpoint.py +0 -118
  253. mlrun-1.7.1rc10.dist-info/RECORD +0 -351
  254. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/LICENSE +0 -0
  255. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/WHEEL +0 -0
  256. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/entry_points.txt +0 -0
  257. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc8.dist-info}/top_level.txt +0 -0
mlrun/db/base.py CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  import datetime
16
16
  from abc import ABC, abstractmethod
17
- from typing import Optional, Union
17
+ from typing import Literal, Optional, Union
18
18
 
19
19
  from deprecated import deprecated
20
20
 
@@ -23,6 +23,7 @@ import mlrun.common
23
23
  import mlrun.common.formatters
24
24
  import mlrun.common.runtimes.constants
25
25
  import mlrun.common.schemas
26
+ import mlrun.common.schemas.model_monitoring.model_endpoints as mm_endpoints
26
27
  import mlrun.model_monitoring
27
28
 
28
29
 
@@ -73,7 +74,7 @@ class RunDBInterface(ABC):
73
74
  name: Optional[str] = None,
74
75
  uid: Optional[Union[str, list[str]]] = None,
75
76
  project: Optional[str] = None,
76
- labels: Optional[Union[str, list[str]]] = None,
77
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
77
78
  state: Optional[
78
79
  mlrun.common.runtimes.constants.RunStates
79
80
  ] = None, # Backward compatibility
@@ -81,10 +82,10 @@ class RunDBInterface(ABC):
81
82
  sort: bool = True,
82
83
  last: int = 0,
83
84
  iter: bool = False,
84
- start_time_from: datetime.datetime = None,
85
- start_time_to: datetime.datetime = None,
86
- last_update_time_from: datetime.datetime = None,
87
- last_update_time_to: datetime.datetime = None,
85
+ start_time_from: Optional[datetime.datetime] = None,
86
+ start_time_to: Optional[datetime.datetime] = None,
87
+ last_update_time_from: Optional[datetime.datetime] = None,
88
+ last_update_time_to: Optional[datetime.datetime] = None,
88
89
  partition_by: Union[mlrun.common.schemas.RunPartitionByField, str] = None,
89
90
  rows_per_partition: int = 1,
90
91
  partition_sort_by: Union[mlrun.common.schemas.SortField, str] = None,
@@ -96,12 +97,30 @@ class RunDBInterface(ABC):
96
97
  ):
97
98
  pass
98
99
 
100
+ @abstractmethod
101
+ def paginated_list_runs(
102
+ self,
103
+ *args,
104
+ page: Optional[int] = None,
105
+ page_size: Optional[int] = None,
106
+ page_token: Optional[str] = None,
107
+ **kwargs,
108
+ ):
109
+ pass
110
+
99
111
  @abstractmethod
100
112
  def del_run(self, uid, project="", iter=0):
101
113
  pass
102
114
 
103
115
  @abstractmethod
104
- def del_runs(self, name="", project="", labels=None, state="", days_ago=0):
116
+ def del_runs(
117
+ self,
118
+ name: str = "",
119
+ project: str = "",
120
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
121
+ state: Optional[mlrun.common.runtimes.constants.RunStates] = None,
122
+ days_ago: int = 0,
123
+ ):
105
124
  pass
106
125
 
107
126
  @abstractmethod
@@ -126,19 +145,40 @@ class RunDBInterface(ABC):
126
145
  @abstractmethod
127
146
  def list_artifacts(
128
147
  self,
129
- name="",
130
- project="",
131
- tag="",
132
- labels=None,
148
+ name: Optional[str] = "",
149
+ project: Optional[str] = "",
150
+ tag: Optional[str] = "",
151
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
133
152
  since=None,
134
153
  until=None,
135
- iter: int = None,
154
+ iter: Optional[int] = None,
136
155
  best_iteration: bool = False,
137
- kind: str = None,
156
+ kind: Optional[str] = None,
138
157
  category: Union[str, mlrun.common.schemas.ArtifactCategories] = None,
139
- tree: str = None,
158
+ tree: Optional[str] = None,
140
159
  format_: mlrun.common.formatters.ArtifactFormat = mlrun.common.formatters.ArtifactFormat.full,
141
- limit: int = None,
160
+ limit: Optional[int] = None,
161
+ partition_by: Optional[
162
+ Union[mlrun.common.schemas.ArtifactPartitionByField, str]
163
+ ] = None,
164
+ rows_per_partition: int = 1,
165
+ partition_sort_by: Optional[
166
+ Union[mlrun.common.schemas.SortField, str]
167
+ ] = mlrun.common.schemas.SortField.updated,
168
+ partition_order: Union[
169
+ mlrun.common.schemas.OrderType, str
170
+ ] = mlrun.common.schemas.OrderType.desc,
171
+ ):
172
+ pass
173
+
174
+ @abstractmethod
175
+ def paginated_list_artifacts(
176
+ self,
177
+ *args,
178
+ page: Optional[int] = None,
179
+ page_size: Optional[int] = None,
180
+ page_token: Optional[str] = None,
181
+ **kwargs,
142
182
  ):
143
183
  pass
144
184
 
@@ -153,13 +193,19 @@ class RunDBInterface(ABC):
153
193
  deletion_strategy: mlrun.common.schemas.artifact.ArtifactsDeletionStrategies = (
154
194
  mlrun.common.schemas.artifact.ArtifactsDeletionStrategies.metadata_only
155
195
  ),
156
- secrets: dict = None,
196
+ secrets: Optional[dict] = None,
157
197
  iter=None,
158
198
  ):
159
199
  pass
160
200
 
161
201
  @abstractmethod
162
- def del_artifacts(self, name="", project="", tag="", labels=None):
202
+ def del_artifacts(
203
+ self,
204
+ name: Optional[str] = "",
205
+ project: Optional[str] = "",
206
+ tag: Optional[str] = "",
207
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
208
+ ):
163
209
  pass
164
210
 
165
211
  @abstractmethod
@@ -176,7 +222,26 @@ class RunDBInterface(ABC):
176
222
 
177
223
  @abstractmethod
178
224
  def list_functions(
179
- self, name=None, project="", tag="", labels=None, since=None, until=None
225
+ self,
226
+ name: Optional[str] = None,
227
+ project: Optional[str] = None,
228
+ tag: Optional[str] = None,
229
+ kind: Optional[str] = None,
230
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
231
+ format_: mlrun.common.formatters.FunctionFormat = mlrun.common.formatters.FunctionFormat.full,
232
+ since: Optional[datetime.datetime] = None,
233
+ until: Optional[datetime.datetime] = None,
234
+ ):
235
+ pass
236
+
237
+ @abstractmethod
238
+ def paginated_list_functions(
239
+ self,
240
+ *args,
241
+ page: Optional[int] = None,
242
+ page_size: Optional[int] = None,
243
+ page_token: Optional[str] = None,
244
+ **kwargs,
180
245
  ):
181
246
  pass
182
247
 
@@ -254,6 +319,14 @@ class RunDBInterface(ABC):
254
319
  kind="artifact", identifiers=artifact_identifiers
255
320
  )
256
321
 
322
+ def get_model_endpoint_monitoring_metrics(
323
+ self,
324
+ project: str,
325
+ endpoint_id: str,
326
+ type: Literal["results", "metrics", "all"] = "all",
327
+ ) -> list[mm_endpoints.ModelEndpointMonitoringMetric]:
328
+ pass
329
+
257
330
  @abstractmethod
258
331
  def delete_project(
259
332
  self,
@@ -289,15 +362,17 @@ class RunDBInterface(ABC):
289
362
  @abstractmethod
290
363
  def list_projects(
291
364
  self,
292
- owner: str = None,
365
+ owner: Optional[str] = None,
293
366
  format_: mlrun.common.formatters.ProjectFormat = mlrun.common.formatters.ProjectFormat.name_only,
294
- labels: list[str] = None,
367
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
295
368
  state: mlrun.common.schemas.ProjectState = None,
296
369
  ) -> mlrun.common.schemas.ProjectsOutput:
297
370
  pass
298
371
 
299
372
  @abstractmethod
300
- def get_project(self, name: str) -> mlrun.common.schemas.Project:
373
+ def get_project(
374
+ self, name: str
375
+ ) -> Union[mlrun.common.schemas.Project, "mlrun.MlrunProject"]:
301
376
  pass
302
377
 
303
378
  @abstractmethod
@@ -319,7 +394,11 @@ class RunDBInterface(ABC):
319
394
 
320
395
  @abstractmethod
321
396
  def get_feature_set(
322
- self, name: str, project: str = "", tag: str = None, uid: str = None
397
+ self,
398
+ name: str,
399
+ project: str = "",
400
+ tag: Optional[str] = None,
401
+ uid: Optional[str] = None,
323
402
  ) -> dict:
324
403
  pass
325
404
 
@@ -333,10 +412,10 @@ class RunDBInterface(ABC):
333
412
  def list_features(
334
413
  self,
335
414
  project: str,
336
- name: str = None,
337
- tag: str = None,
338
- entities: list[str] = None,
339
- labels: list[str] = None,
415
+ name: Optional[str] = None,
416
+ tag: Optional[str] = None,
417
+ entities: Optional[list[str]] = None,
418
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
340
419
  ) -> mlrun.common.schemas.FeaturesOutput:
341
420
  pass
342
421
 
@@ -344,10 +423,10 @@ class RunDBInterface(ABC):
344
423
  def list_features_v2(
345
424
  self,
346
425
  project: str,
347
- name: str = None,
348
- tag: str = None,
349
- entities: list[str] = None,
350
- labels: list[str] = None,
426
+ name: Optional[str] = None,
427
+ tag: Optional[str] = None,
428
+ entities: Optional[list[str]] = None,
429
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
351
430
  ) -> mlrun.common.schemas.FeaturesOutputV2:
352
431
  pass
353
432
 
@@ -361,9 +440,9 @@ class RunDBInterface(ABC):
361
440
  def list_entities(
362
441
  self,
363
442
  project: str,
364
- name: str = None,
365
- tag: str = None,
366
- labels: list[str] = None,
443
+ name: Optional[str] = None,
444
+ tag: Optional[str] = None,
445
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
367
446
  ) -> mlrun.common.schemas.EntitiesOutput:
368
447
  pass
369
448
 
@@ -371,9 +450,9 @@ class RunDBInterface(ABC):
371
450
  def list_entities_v2(
372
451
  self,
373
452
  project: str,
374
- name: str = None,
375
- tag: str = None,
376
- labels: list[str] = None,
453
+ name: Optional[str] = None,
454
+ tag: Optional[str] = None,
455
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
377
456
  ) -> mlrun.common.schemas.EntitiesOutputV2:
378
457
  pass
379
458
 
@@ -381,12 +460,12 @@ class RunDBInterface(ABC):
381
460
  def list_feature_sets(
382
461
  self,
383
462
  project: str = "",
384
- name: str = None,
385
- tag: str = None,
386
- state: str = None,
387
- entities: list[str] = None,
388
- features: list[str] = None,
389
- labels: list[str] = None,
463
+ name: Optional[str] = None,
464
+ tag: Optional[str] = None,
465
+ state: Optional[str] = None,
466
+ entities: Optional[list[str]] = None,
467
+ features: Optional[list[str]] = None,
468
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
390
469
  partition_by: Union[
391
470
  mlrun.common.schemas.FeatureStorePartitionByField, str
392
471
  ] = None,
@@ -442,7 +521,11 @@ class RunDBInterface(ABC):
442
521
 
443
522
  @abstractmethod
444
523
  def get_feature_vector(
445
- self, name: str, project: str = "", tag: str = None, uid: str = None
524
+ self,
525
+ name: str,
526
+ project: str = "",
527
+ tag: Optional[str] = None,
528
+ uid: Optional[str] = None,
446
529
  ) -> dict:
447
530
  pass
448
531
 
@@ -450,10 +533,10 @@ class RunDBInterface(ABC):
450
533
  def list_feature_vectors(
451
534
  self,
452
535
  project: str = "",
453
- name: str = None,
454
- tag: str = None,
455
- state: str = None,
456
- labels: list[str] = None,
536
+ name: Optional[str] = None,
537
+ tag: Optional[str] = None,
538
+ state: Optional[str] = None,
539
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
457
540
  partition_by: Union[
458
541
  mlrun.common.schemas.FeatureStorePartitionByField, str
459
542
  ] = None,
@@ -499,12 +582,12 @@ class RunDBInterface(ABC):
499
582
  def get_pipeline(
500
583
  self,
501
584
  run_id: str,
502
- namespace: str = None,
585
+ namespace: Optional[str] = None,
503
586
  timeout: int = 30,
504
587
  format_: Union[
505
588
  str, mlrun.common.formatters.PipelineFormat
506
589
  ] = mlrun.common.formatters.PipelineFormat.summary,
507
- project: str = None,
590
+ project: Optional[str] = None,
508
591
  ):
509
592
  pass
510
593
 
@@ -512,14 +595,14 @@ class RunDBInterface(ABC):
512
595
  def list_pipelines(
513
596
  self,
514
597
  project: str,
515
- namespace: str = None,
598
+ namespace: Optional[str] = None,
516
599
  sort_by: str = "",
517
600
  page_token: str = "",
518
601
  filter_: str = "",
519
602
  format_: Union[
520
603
  str, mlrun.common.formatters.PipelineFormat
521
604
  ] = mlrun.common.formatters.PipelineFormat.metadata_only,
522
- page_size: int = None,
605
+ page_size: Optional[int] = None,
523
606
  ) -> mlrun.common.schemas.PipelinesOutput:
524
607
  pass
525
608
 
@@ -530,7 +613,7 @@ class RunDBInterface(ABC):
530
613
  provider: Union[
531
614
  str, mlrun.common.schemas.SecretProviderName
532
615
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
533
- secrets: dict = None,
616
+ secrets: Optional[dict] = None,
534
617
  ):
535
618
  pass
536
619
 
@@ -542,7 +625,7 @@ class RunDBInterface(ABC):
542
625
  provider: Union[
543
626
  str, mlrun.common.schemas.SecretProviderName
544
627
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
545
- secrets: list[str] = None,
628
+ secrets: Optional[list[str]] = None,
546
629
  ) -> mlrun.common.schemas.SecretsData:
547
630
  pass
548
631
 
@@ -553,7 +636,7 @@ class RunDBInterface(ABC):
553
636
  provider: Union[
554
637
  str, mlrun.common.schemas.SecretProviderName
555
638
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
556
- token: str = None,
639
+ token: Optional[str] = None,
557
640
  ) -> mlrun.common.schemas.SecretKeysData:
558
641
  pass
559
642
 
@@ -564,7 +647,7 @@ class RunDBInterface(ABC):
564
647
  provider: Union[
565
648
  str, mlrun.common.schemas.SecretProviderName
566
649
  ] = mlrun.common.schemas.SecretProviderName.kubernetes,
567
- secrets: list[str] = None,
650
+ secrets: Optional[list[str]] = None,
568
651
  ):
569
652
  pass
570
653
 
@@ -575,23 +658,23 @@ class RunDBInterface(ABC):
575
658
  provider: Union[
576
659
  str, mlrun.common.schemas.SecretProviderName
577
660
  ] = mlrun.common.schemas.SecretProviderName.vault,
578
- secrets: dict = None,
661
+ secrets: Optional[dict] = None,
579
662
  ):
580
663
  pass
581
664
 
582
665
  @abstractmethod
583
666
  def create_model_endpoint(
584
667
  self,
585
- project: str,
586
- endpoint_id: str,
587
- model_endpoint: Union[mlrun.model_monitoring.ModelEndpoint, dict],
588
- ):
668
+ model_endpoint: mlrun.common.schemas.ModelEndpoint,
669
+ ) -> mlrun.common.schemas.ModelEndpoint:
589
670
  pass
590
671
 
591
672
  @abstractmethod
592
673
  def delete_model_endpoint(
593
674
  self,
675
+ name: str,
594
676
  project: str,
677
+ function_name: str,
595
678
  endpoint_id: str,
596
679
  ):
597
680
  pass
@@ -600,34 +683,40 @@ class RunDBInterface(ABC):
600
683
  def list_model_endpoints(
601
684
  self,
602
685
  project: str,
603
- model: Optional[str] = None,
604
- function: Optional[str] = None,
605
- labels: list[str] = None,
606
- start: str = "now-1h",
607
- end: str = "now",
608
- metrics: Optional[list[str]] = None,
609
- ):
686
+ name: Optional[str] = None,
687
+ function_name: Optional[str] = None,
688
+ model_name: Optional[str] = None,
689
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
690
+ start: Optional[datetime.datetime] = None,
691
+ end: Optional[datetime.datetime] = None,
692
+ tsdb_metrics: bool = True,
693
+ top_level: bool = False,
694
+ uids: Optional[list[str]] = None,
695
+ latest_only: bool = False,
696
+ ) -> mlrun.common.schemas.ModelEndpointList:
610
697
  pass
611
698
 
612
699
  @abstractmethod
613
700
  def get_model_endpoint(
614
701
  self,
702
+ name: str,
615
703
  project: str,
616
- endpoint_id: str,
617
- start: Optional[str] = None,
618
- end: Optional[str] = None,
619
- metrics: Optional[list[str]] = None,
620
- features: bool = False,
621
- ) -> mlrun.model_monitoring.ModelEndpoint:
704
+ function_name: Optional[str] = None,
705
+ endpoint_id: Optional[str] = None,
706
+ tsdb_metrics: bool = True,
707
+ feature_analysis: bool = False,
708
+ ) -> mlrun.common.schemas.ModelEndpoint:
622
709
  pass
623
710
 
624
711
  @abstractmethod
625
712
  def patch_model_endpoint(
626
713
  self,
714
+ name: str,
627
715
  project: str,
628
- endpoint_id: str,
629
716
  attributes: dict,
630
- ):
717
+ function_name: Optional[str] = None,
718
+ endpoint_id: Optional[str] = None,
719
+ ) -> mlrun.common.schemas.ModelEndpoint:
631
720
  pass
632
721
 
633
722
  @abstractmethod
@@ -665,8 +754,8 @@ class RunDBInterface(ABC):
665
754
  def get_hub_catalog(
666
755
  self,
667
756
  source_name: str,
668
- version: str = None,
669
- tag: str = None,
757
+ version: Optional[str] = None,
758
+ tag: Optional[str] = None,
670
759
  force_refresh: bool = False,
671
760
  ):
672
761
  pass
@@ -676,7 +765,7 @@ class RunDBInterface(ABC):
676
765
  self,
677
766
  source_name: str,
678
767
  item_name: str,
679
- version: str = None,
768
+ version: Optional[str] = None,
680
769
  tag: str = "latest",
681
770
  force_refresh: bool = False,
682
771
  ):
@@ -744,6 +833,7 @@ class RunDBInterface(ABC):
744
833
  alert_name: str,
745
834
  alert_data: Union[dict, mlrun.alerts.alert.AlertConfig],
746
835
  project="",
836
+ force_reset: bool = False,
747
837
  ):
748
838
  pass
749
839
 
@@ -771,6 +861,35 @@ class RunDBInterface(ABC):
771
861
  def list_alert_templates(self):
772
862
  pass
773
863
 
864
+ @abstractmethod
865
+ def list_alert_activations(
866
+ self,
867
+ project: Optional[str] = None,
868
+ name: Optional[str] = None,
869
+ since: Optional[datetime.datetime] = None,
870
+ until: Optional[datetime.datetime] = None,
871
+ entity: Optional[str] = None,
872
+ severity: Optional[
873
+ list[Union[mlrun.common.schemas.alert.AlertSeverity, str]]
874
+ ] = None,
875
+ entity_kind: Optional[
876
+ Union[mlrun.common.schemas.alert.EventEntityKind, str]
877
+ ] = None,
878
+ event_kind: Optional[Union[mlrun.common.schemas.alert.EventKind, str]] = None,
879
+ ):
880
+ pass
881
+
882
+ @abstractmethod
883
+ def paginated_list_alert_activations(
884
+ self,
885
+ *args,
886
+ page: Optional[int] = None,
887
+ page_size: Optional[int] = None,
888
+ page_token: Optional[str] = None,
889
+ **kwargs,
890
+ ):
891
+ pass
892
+
774
893
  @abstractmethod
775
894
  def get_builder_status(
776
895
  self,
@@ -779,6 +898,7 @@ class RunDBInterface(ABC):
779
898
  logs: bool = True,
780
899
  last_log_timestamp: float = 0.0,
781
900
  verbose: bool = False,
901
+ events_offset: int = 0,
782
902
  ):
783
903
  pass
784
904
 
@@ -805,7 +925,7 @@ class RunDBInterface(ABC):
805
925
  self,
806
926
  notification_objects: list[mlrun.model.Notification],
807
927
  run_uid: str,
808
- project: str = None,
928
+ project: Optional[str] = None,
809
929
  mask_params: bool = True,
810
930
  ):
811
931
  pass
@@ -859,7 +979,9 @@ class RunDBInterface(ABC):
859
979
 
860
980
  @abstractmethod
861
981
  def start_function(
862
- self, func_url: str = None, function: "mlrun.runtimes.BaseRuntime" = None
982
+ self,
983
+ func_url: Optional[str] = None,
984
+ function: "mlrun.runtimes.BaseRuntime" = None,
863
985
  ):
864
986
  pass
865
987
 
@@ -878,7 +1000,7 @@ class RunDBInterface(ABC):
878
1000
  source: Optional[str] = None,
879
1001
  run_name: Optional[str] = None,
880
1002
  namespace: Optional[str] = None,
881
- notifications: list["mlrun.model.Notification"] = None,
1003
+ notifications: Optional[list["mlrun.model.Notification"]] = None,
882
1004
  ) -> "mlrun.common.schemas.WorkflowResponse":
883
1005
  pass
884
1006
 
@@ -911,7 +1033,7 @@ class RunDBInterface(ABC):
911
1033
  delete_stream_function: bool = False,
912
1034
  delete_histogram_data_drift_app: bool = True,
913
1035
  delete_user_applications: bool = False,
914
- user_application_list: list[str] = None,
1036
+ user_application_list: Optional[list[str]] = None,
915
1037
  ) -> bool:
916
1038
  pass
917
1039
 
@@ -935,3 +1057,7 @@ class RunDBInterface(ABC):
935
1057
  replace_creds: bool,
936
1058
  ) -> None:
937
1059
  pass
1060
+
1061
+ @abstractmethod
1062
+ def get_project_summary(self, project: str) -> mlrun.common.schemas.ProjectSummary:
1063
+ pass
mlrun/db/factory.py CHANGED
@@ -54,9 +54,6 @@ class RunDBFactory(
54
54
  self._run_db = self._rundb_container.nop(url)
55
55
 
56
56
  else:
57
- # TODO: this practically makes the SQLRunDB a singleton, which mean that its session is shared, needs
58
- # to be refreshed frequently and cannot be used concurrently.
59
- # The SQLRunDB should always get its session from the FastAPI dependency injection.
60
57
  self._run_db = self._rundb_container.run_db(url)
61
58
 
62
59
  self._run_db.connect(secrets=secrets)