mlrun 1.7.1rc10__py3-none-any.whl → 1.8.0rc11__py3-none-any.whl

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

Potentially problematic release.


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

Files changed (259) hide show
  1. mlrun/__init__.py +23 -21
  2. mlrun/__main__.py +3 -3
  3. mlrun/alerts/alert.py +148 -14
  4. mlrun/artifacts/__init__.py +2 -3
  5. mlrun/artifacts/base.py +55 -12
  6. mlrun/artifacts/dataset.py +16 -16
  7. mlrun/artifacts/document.py +378 -0
  8. mlrun/artifacts/manager.py +26 -17
  9. mlrun/artifacts/model.py +66 -53
  10. mlrun/common/constants.py +8 -0
  11. mlrun/common/formatters/__init__.py +1 -0
  12. mlrun/common/formatters/feature_set.py +1 -0
  13. mlrun/common/formatters/function.py +1 -0
  14. mlrun/{model_monitoring/db/stores/base/__init__.py → common/formatters/model_endpoint.py} +16 -1
  15. mlrun/common/formatters/pipeline.py +1 -2
  16. mlrun/common/formatters/project.py +9 -0
  17. mlrun/common/model_monitoring/__init__.py +0 -5
  18. mlrun/common/model_monitoring/helpers.py +1 -29
  19. mlrun/common/runtimes/constants.py +1 -2
  20. mlrun/common/schemas/__init__.py +6 -2
  21. mlrun/common/schemas/alert.py +111 -19
  22. mlrun/common/schemas/api_gateway.py +3 -3
  23. mlrun/common/schemas/artifact.py +11 -7
  24. mlrun/common/schemas/auth.py +6 -4
  25. mlrun/common/schemas/background_task.py +7 -7
  26. mlrun/common/schemas/client_spec.py +2 -3
  27. mlrun/common/schemas/clusterization_spec.py +2 -2
  28. mlrun/common/schemas/common.py +53 -3
  29. mlrun/common/schemas/constants.py +15 -0
  30. mlrun/common/schemas/datastore_profile.py +1 -1
  31. mlrun/common/schemas/feature_store.py +9 -9
  32. mlrun/common/schemas/frontend_spec.py +4 -4
  33. mlrun/common/schemas/function.py +10 -10
  34. mlrun/common/schemas/hub.py +1 -1
  35. mlrun/common/schemas/k8s.py +3 -3
  36. mlrun/common/schemas/memory_reports.py +3 -3
  37. mlrun/common/schemas/model_monitoring/__init__.py +2 -1
  38. mlrun/common/schemas/model_monitoring/constants.py +67 -14
  39. mlrun/common/schemas/model_monitoring/grafana.py +1 -1
  40. mlrun/common/schemas/model_monitoring/model_endpoints.py +92 -147
  41. mlrun/common/schemas/notification.py +24 -3
  42. mlrun/common/schemas/object.py +1 -1
  43. mlrun/common/schemas/pagination.py +4 -4
  44. mlrun/common/schemas/partition.py +137 -0
  45. mlrun/common/schemas/pipeline.py +2 -2
  46. mlrun/common/schemas/project.py +25 -17
  47. mlrun/common/schemas/runs.py +2 -2
  48. mlrun/common/schemas/runtime_resource.py +5 -5
  49. mlrun/common/schemas/schedule.py +1 -1
  50. mlrun/common/schemas/secret.py +1 -1
  51. mlrun/common/schemas/tag.py +3 -3
  52. mlrun/common/schemas/workflow.py +5 -5
  53. mlrun/config.py +68 -10
  54. mlrun/data_types/__init__.py +0 -2
  55. mlrun/data_types/data_types.py +1 -0
  56. mlrun/data_types/infer.py +3 -1
  57. mlrun/data_types/spark.py +5 -3
  58. mlrun/data_types/to_pandas.py +11 -2
  59. mlrun/datastore/__init__.py +2 -2
  60. mlrun/datastore/alibaba_oss.py +4 -1
  61. mlrun/datastore/azure_blob.py +4 -1
  62. mlrun/datastore/base.py +12 -4
  63. mlrun/datastore/datastore.py +9 -3
  64. mlrun/datastore/datastore_profile.py +79 -20
  65. mlrun/datastore/dbfs_store.py +4 -1
  66. mlrun/datastore/filestore.py +4 -1
  67. mlrun/datastore/google_cloud_storage.py +4 -1
  68. mlrun/datastore/hdfs.py +4 -1
  69. mlrun/datastore/inmem.py +4 -1
  70. mlrun/datastore/redis.py +4 -1
  71. mlrun/datastore/s3.py +4 -1
  72. mlrun/datastore/sources.py +52 -51
  73. mlrun/datastore/store_resources.py +7 -4
  74. mlrun/datastore/targets.py +23 -22
  75. mlrun/datastore/utils.py +2 -2
  76. mlrun/datastore/v3io.py +4 -1
  77. mlrun/datastore/vectorstore.py +229 -0
  78. mlrun/datastore/wasbfs/fs.py +13 -12
  79. mlrun/db/base.py +213 -83
  80. mlrun/db/factory.py +0 -3
  81. mlrun/db/httpdb.py +1265 -387
  82. mlrun/db/nopdb.py +205 -74
  83. mlrun/errors.py +2 -2
  84. mlrun/execution.py +136 -50
  85. mlrun/feature_store/__init__.py +0 -2
  86. mlrun/feature_store/api.py +41 -40
  87. mlrun/feature_store/common.py +9 -9
  88. mlrun/feature_store/feature_set.py +20 -18
  89. mlrun/feature_store/feature_vector.py +27 -24
  90. mlrun/feature_store/retrieval/base.py +14 -9
  91. mlrun/feature_store/retrieval/job.py +2 -1
  92. mlrun/feature_store/steps.py +2 -2
  93. mlrun/features.py +30 -13
  94. mlrun/frameworks/__init__.py +1 -2
  95. mlrun/frameworks/_common/__init__.py +1 -2
  96. mlrun/frameworks/_common/artifacts_library.py +2 -2
  97. mlrun/frameworks/_common/mlrun_interface.py +10 -6
  98. mlrun/frameworks/_common/model_handler.py +29 -27
  99. mlrun/frameworks/_common/producer.py +3 -1
  100. mlrun/frameworks/_dl_common/__init__.py +1 -2
  101. mlrun/frameworks/_dl_common/loggers/__init__.py +1 -2
  102. mlrun/frameworks/_dl_common/loggers/mlrun_logger.py +4 -4
  103. mlrun/frameworks/_dl_common/loggers/tensorboard_logger.py +3 -3
  104. mlrun/frameworks/_ml_common/__init__.py +1 -2
  105. mlrun/frameworks/_ml_common/loggers/__init__.py +1 -2
  106. mlrun/frameworks/_ml_common/model_handler.py +21 -21
  107. mlrun/frameworks/_ml_common/plans/__init__.py +1 -2
  108. mlrun/frameworks/_ml_common/plans/confusion_matrix_plan.py +3 -1
  109. mlrun/frameworks/_ml_common/plans/dataset_plan.py +3 -3
  110. mlrun/frameworks/_ml_common/plans/roc_curve_plan.py +4 -4
  111. mlrun/frameworks/auto_mlrun/__init__.py +1 -2
  112. mlrun/frameworks/auto_mlrun/auto_mlrun.py +22 -15
  113. mlrun/frameworks/huggingface/__init__.py +1 -2
  114. mlrun/frameworks/huggingface/model_server.py +9 -9
  115. mlrun/frameworks/lgbm/__init__.py +47 -44
  116. mlrun/frameworks/lgbm/callbacks/__init__.py +1 -2
  117. mlrun/frameworks/lgbm/callbacks/logging_callback.py +4 -2
  118. mlrun/frameworks/lgbm/callbacks/mlrun_logging_callback.py +4 -2
  119. mlrun/frameworks/lgbm/mlrun_interfaces/__init__.py +1 -2
  120. mlrun/frameworks/lgbm/mlrun_interfaces/mlrun_interface.py +5 -5
  121. mlrun/frameworks/lgbm/model_handler.py +15 -11
  122. mlrun/frameworks/lgbm/model_server.py +11 -7
  123. mlrun/frameworks/lgbm/utils.py +2 -2
  124. mlrun/frameworks/onnx/__init__.py +1 -2
  125. mlrun/frameworks/onnx/dataset.py +3 -3
  126. mlrun/frameworks/onnx/mlrun_interface.py +2 -2
  127. mlrun/frameworks/onnx/model_handler.py +7 -5
  128. mlrun/frameworks/onnx/model_server.py +8 -6
  129. mlrun/frameworks/parallel_coordinates.py +11 -11
  130. mlrun/frameworks/pytorch/__init__.py +22 -23
  131. mlrun/frameworks/pytorch/callbacks/__init__.py +1 -2
  132. mlrun/frameworks/pytorch/callbacks/callback.py +2 -1
  133. mlrun/frameworks/pytorch/callbacks/logging_callback.py +15 -8
  134. mlrun/frameworks/pytorch/callbacks/mlrun_logging_callback.py +19 -12
  135. mlrun/frameworks/pytorch/callbacks/tensorboard_logging_callback.py +22 -15
  136. mlrun/frameworks/pytorch/callbacks_handler.py +36 -30
  137. mlrun/frameworks/pytorch/mlrun_interface.py +17 -17
  138. mlrun/frameworks/pytorch/model_handler.py +21 -17
  139. mlrun/frameworks/pytorch/model_server.py +13 -9
  140. mlrun/frameworks/sklearn/__init__.py +19 -18
  141. mlrun/frameworks/sklearn/estimator.py +2 -2
  142. mlrun/frameworks/sklearn/metric.py +3 -3
  143. mlrun/frameworks/sklearn/metrics_library.py +8 -6
  144. mlrun/frameworks/sklearn/mlrun_interface.py +3 -2
  145. mlrun/frameworks/sklearn/model_handler.py +4 -3
  146. mlrun/frameworks/tf_keras/__init__.py +11 -12
  147. mlrun/frameworks/tf_keras/callbacks/__init__.py +1 -2
  148. mlrun/frameworks/tf_keras/callbacks/logging_callback.py +17 -14
  149. mlrun/frameworks/tf_keras/callbacks/mlrun_logging_callback.py +15 -12
  150. mlrun/frameworks/tf_keras/callbacks/tensorboard_logging_callback.py +21 -18
  151. mlrun/frameworks/tf_keras/model_handler.py +17 -13
  152. mlrun/frameworks/tf_keras/model_server.py +12 -8
  153. mlrun/frameworks/xgboost/__init__.py +19 -18
  154. mlrun/frameworks/xgboost/model_handler.py +13 -9
  155. mlrun/launcher/base.py +3 -4
  156. mlrun/launcher/local.py +1 -1
  157. mlrun/launcher/remote.py +1 -1
  158. mlrun/lists.py +4 -3
  159. mlrun/model.py +117 -46
  160. mlrun/model_monitoring/__init__.py +4 -4
  161. mlrun/model_monitoring/api.py +72 -59
  162. mlrun/model_monitoring/applications/_application_steps.py +17 -17
  163. mlrun/model_monitoring/applications/base.py +165 -6
  164. mlrun/model_monitoring/applications/context.py +88 -37
  165. mlrun/model_monitoring/applications/evidently_base.py +0 -1
  166. mlrun/model_monitoring/applications/histogram_data_drift.py +43 -21
  167. mlrun/model_monitoring/applications/results.py +55 -3
  168. mlrun/model_monitoring/controller.py +207 -239
  169. mlrun/model_monitoring/db/__init__.py +0 -2
  170. mlrun/model_monitoring/db/_schedules.py +156 -0
  171. mlrun/model_monitoring/db/_stats.py +189 -0
  172. mlrun/model_monitoring/db/tsdb/base.py +78 -25
  173. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +61 -6
  174. mlrun/model_monitoring/db/tsdb/tdengine/stream_graph_steps.py +33 -0
  175. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +255 -29
  176. mlrun/model_monitoring/db/tsdb/v3io/stream_graph_steps.py +1 -0
  177. mlrun/model_monitoring/db/tsdb/v3io/v3io_connector.py +78 -17
  178. mlrun/model_monitoring/helpers.py +151 -49
  179. mlrun/model_monitoring/stream_processing.py +99 -283
  180. mlrun/model_monitoring/tracking_policy.py +10 -3
  181. mlrun/model_monitoring/writer.py +48 -36
  182. mlrun/package/__init__.py +3 -6
  183. mlrun/package/context_handler.py +1 -1
  184. mlrun/package/packager.py +12 -9
  185. mlrun/package/packagers/__init__.py +0 -2
  186. mlrun/package/packagers/default_packager.py +14 -11
  187. mlrun/package/packagers/numpy_packagers.py +16 -7
  188. mlrun/package/packagers/pandas_packagers.py +18 -18
  189. mlrun/package/packagers/python_standard_library_packagers.py +25 -11
  190. mlrun/package/packagers_manager.py +31 -14
  191. mlrun/package/utils/__init__.py +0 -3
  192. mlrun/package/utils/_pickler.py +6 -6
  193. mlrun/platforms/__init__.py +47 -16
  194. mlrun/platforms/iguazio.py +4 -1
  195. mlrun/projects/operations.py +27 -27
  196. mlrun/projects/pipelines.py +71 -36
  197. mlrun/projects/project.py +890 -220
  198. mlrun/run.py +53 -10
  199. mlrun/runtimes/__init__.py +1 -3
  200. mlrun/runtimes/base.py +15 -11
  201. mlrun/runtimes/daskjob.py +9 -9
  202. mlrun/runtimes/generators.py +2 -1
  203. mlrun/runtimes/kubejob.py +4 -5
  204. mlrun/runtimes/mounts.py +572 -0
  205. mlrun/runtimes/mpijob/__init__.py +0 -2
  206. mlrun/runtimes/mpijob/abstract.py +7 -6
  207. mlrun/runtimes/nuclio/api_gateway.py +7 -7
  208. mlrun/runtimes/nuclio/application/application.py +11 -11
  209. mlrun/runtimes/nuclio/function.py +19 -17
  210. mlrun/runtimes/nuclio/serving.py +18 -13
  211. mlrun/runtimes/pod.py +154 -45
  212. mlrun/runtimes/remotesparkjob.py +3 -2
  213. mlrun/runtimes/sparkjob/__init__.py +0 -2
  214. mlrun/runtimes/sparkjob/spark3job.py +21 -11
  215. mlrun/runtimes/utils.py +6 -5
  216. mlrun/serving/merger.py +6 -4
  217. mlrun/serving/remote.py +18 -17
  218. mlrun/serving/routers.py +185 -172
  219. mlrun/serving/server.py +7 -1
  220. mlrun/serving/states.py +97 -78
  221. mlrun/serving/utils.py +13 -2
  222. mlrun/serving/v1_serving.py +3 -2
  223. mlrun/serving/v2_serving.py +105 -72
  224. mlrun/track/__init__.py +1 -1
  225. mlrun/track/tracker.py +2 -2
  226. mlrun/track/trackers/mlflow_tracker.py +6 -5
  227. mlrun/utils/async_http.py +1 -1
  228. mlrun/utils/clones.py +1 -1
  229. mlrun/utils/helpers.py +63 -19
  230. mlrun/utils/logger.py +106 -4
  231. mlrun/utils/notifications/notification/__init__.py +22 -19
  232. mlrun/utils/notifications/notification/base.py +33 -14
  233. mlrun/utils/notifications/notification/console.py +6 -6
  234. mlrun/utils/notifications/notification/git.py +11 -11
  235. mlrun/utils/notifications/notification/ipython.py +10 -9
  236. mlrun/utils/notifications/notification/mail.py +176 -0
  237. mlrun/utils/notifications/notification/slack.py +6 -6
  238. mlrun/utils/notifications/notification/webhook.py +6 -6
  239. mlrun/utils/notifications/notification_pusher.py +86 -44
  240. mlrun/utils/regex.py +11 -2
  241. mlrun/utils/version/version.json +2 -2
  242. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/METADATA +29 -24
  243. mlrun-1.8.0rc11.dist-info/RECORD +347 -0
  244. mlrun/model_monitoring/db/stores/__init__.py +0 -136
  245. mlrun/model_monitoring/db/stores/base/store.py +0 -213
  246. mlrun/model_monitoring/db/stores/sqldb/__init__.py +0 -13
  247. mlrun/model_monitoring/db/stores/sqldb/models/__init__.py +0 -71
  248. mlrun/model_monitoring/db/stores/sqldb/models/base.py +0 -190
  249. mlrun/model_monitoring/db/stores/sqldb/models/mysql.py +0 -103
  250. mlrun/model_monitoring/db/stores/sqldb/models/sqlite.py +0 -40
  251. mlrun/model_monitoring/db/stores/sqldb/sql_store.py +0 -659
  252. mlrun/model_monitoring/db/stores/v3io_kv/__init__.py +0 -13
  253. mlrun/model_monitoring/db/stores/v3io_kv/kv_store.py +0 -726
  254. mlrun/model_monitoring/model_endpoint.py +0 -118
  255. mlrun-1.7.1rc10.dist-info/RECORD +0 -351
  256. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/LICENSE +0 -0
  257. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/WHEEL +0 -0
  258. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/entry_points.txt +0 -0
  259. {mlrun-1.7.1rc10.dist-info → mlrun-1.8.0rc11.dist-info}/top_level.txt +0 -0
mlrun/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,24 +658,25 @@ 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,
595
- endpoint_id: str,
677
+ function_name: Optional[str] = None,
678
+ function_tag: Optional[str] = None,
679
+ endpoint_id: Optional[str] = None,
596
680
  ):
597
681
  pass
598
682
 
@@ -600,34 +684,43 @@ class RunDBInterface(ABC):
600
684
  def list_model_endpoints(
601
685
  self,
602
686
  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
- ):
687
+ name: Optional[str] = None,
688
+ function_name: Optional[str] = None,
689
+ function_tag: Optional[str] = None,
690
+ model_name: Optional[str] = None,
691
+ labels: Optional[Union[str, dict[str, Optional[str]], list[str]]] = None,
692
+ start: Optional[datetime.datetime] = None,
693
+ end: Optional[datetime.datetime] = None,
694
+ tsdb_metrics: bool = True,
695
+ top_level: bool = False,
696
+ uids: Optional[list[str]] = None,
697
+ latest_only: bool = False,
698
+ ) -> mlrun.common.schemas.ModelEndpointList:
610
699
  pass
611
700
 
612
701
  @abstractmethod
613
702
  def get_model_endpoint(
614
703
  self,
704
+ name: str,
615
705
  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:
706
+ function_name: Optional[str] = None,
707
+ function_tag: Optional[str] = None,
708
+ endpoint_id: Optional[str] = None,
709
+ tsdb_metrics: bool = True,
710
+ feature_analysis: bool = False,
711
+ ) -> mlrun.common.schemas.ModelEndpoint:
622
712
  pass
623
713
 
624
714
  @abstractmethod
625
715
  def patch_model_endpoint(
626
716
  self,
717
+ name: str,
627
718
  project: str,
628
- endpoint_id: str,
629
719
  attributes: dict,
630
- ):
720
+ function_name: Optional[str] = None,
721
+ function_tag: Optional[str] = None,
722
+ endpoint_id: Optional[str] = None,
723
+ ) -> mlrun.common.schemas.ModelEndpoint:
631
724
  pass
632
725
 
633
726
  @abstractmethod
@@ -665,8 +758,8 @@ class RunDBInterface(ABC):
665
758
  def get_hub_catalog(
666
759
  self,
667
760
  source_name: str,
668
- version: str = None,
669
- tag: str = None,
761
+ version: Optional[str] = None,
762
+ tag: Optional[str] = None,
670
763
  force_refresh: bool = False,
671
764
  ):
672
765
  pass
@@ -676,7 +769,7 @@ class RunDBInterface(ABC):
676
769
  self,
677
770
  source_name: str,
678
771
  item_name: str,
679
- version: str = None,
772
+ version: Optional[str] = None,
680
773
  tag: str = "latest",
681
774
  force_refresh: bool = False,
682
775
  ):
@@ -744,6 +837,7 @@ class RunDBInterface(ABC):
744
837
  alert_name: str,
745
838
  alert_data: Union[dict, mlrun.alerts.alert.AlertConfig],
746
839
  project="",
840
+ force_reset: bool = False,
747
841
  ):
748
842
  pass
749
843
 
@@ -771,6 +865,35 @@ class RunDBInterface(ABC):
771
865
  def list_alert_templates(self):
772
866
  pass
773
867
 
868
+ @abstractmethod
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
+ @abstractmethod
887
+ def paginated_list_alert_activations(
888
+ self,
889
+ *args,
890
+ page: Optional[int] = None,
891
+ page_size: Optional[int] = None,
892
+ page_token: Optional[str] = None,
893
+ **kwargs,
894
+ ):
895
+ pass
896
+
774
897
  @abstractmethod
775
898
  def get_builder_status(
776
899
  self,
@@ -779,6 +902,7 @@ class RunDBInterface(ABC):
779
902
  logs: bool = True,
780
903
  last_log_timestamp: float = 0.0,
781
904
  verbose: bool = False,
905
+ events_offset: int = 0,
782
906
  ):
783
907
  pass
784
908
 
@@ -805,7 +929,7 @@ class RunDBInterface(ABC):
805
929
  self,
806
930
  notification_objects: list[mlrun.model.Notification],
807
931
  run_uid: str,
808
- project: str = None,
932
+ project: Optional[str] = None,
809
933
  mask_params: bool = True,
810
934
  ):
811
935
  pass
@@ -859,7 +983,9 @@ class RunDBInterface(ABC):
859
983
 
860
984
  @abstractmethod
861
985
  def start_function(
862
- self, func_url: str = None, function: "mlrun.runtimes.BaseRuntime" = None
986
+ self,
987
+ func_url: Optional[str] = None,
988
+ function: "mlrun.runtimes.BaseRuntime" = None,
863
989
  ):
864
990
  pass
865
991
 
@@ -878,7 +1004,7 @@ class RunDBInterface(ABC):
878
1004
  source: Optional[str] = None,
879
1005
  run_name: Optional[str] = None,
880
1006
  namespace: Optional[str] = None,
881
- notifications: list["mlrun.model.Notification"] = None,
1007
+ notifications: Optional[list["mlrun.model.Notification"]] = None,
882
1008
  ) -> "mlrun.common.schemas.WorkflowResponse":
883
1009
  pass
884
1010
 
@@ -911,7 +1037,7 @@ class RunDBInterface(ABC):
911
1037
  delete_stream_function: bool = False,
912
1038
  delete_histogram_data_drift_app: bool = True,
913
1039
  delete_user_applications: bool = False,
914
- user_application_list: list[str] = None,
1040
+ user_application_list: Optional[list[str]] = None,
915
1041
  ) -> bool:
916
1042
  pass
917
1043
 
@@ -935,3 +1061,7 @@ class RunDBInterface(ABC):
935
1061
  replace_creds: bool,
936
1062
  ) -> None:
937
1063
  pass
1064
+
1065
+ @abstractmethod
1066
+ def get_project_summary(self, project: str) -> mlrun.common.schemas.ProjectSummary:
1067
+ 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)