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
@@ -0,0 +1,30 @@
1
+ # Copyright 2024 Iguazio
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+
16
+ import typing
17
+
18
+ import mlrun.common.types
19
+
20
+ from .base import ObjectFormat
21
+
22
+
23
+ class ModelEndpointFormat(ObjectFormat, mlrun.common.types.StrEnum):
24
+ full = "full"
25
+
26
+ @staticmethod
27
+ def format_method(_format: str) -> typing.Optional[typing.Callable]:
28
+ return {
29
+ ModelEndpointFormat.full: None,
30
+ }[_format]
@@ -15,11 +15,10 @@
15
15
 
16
16
  import typing
17
17
 
18
+ import mlrun.common.types
18
19
  import mlrun_pipelines.common.ops
19
20
  import mlrun_pipelines.models
20
21
 
21
- import mlrun.common.types
22
-
23
22
  from .base import ObjectFormat
24
23
 
25
24
 
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
  #
15
15
 
16
+ import datetime
16
17
  import typing
17
18
 
18
19
  import mlrun.common.schemas
@@ -30,11 +31,18 @@ class ProjectFormat(ObjectFormat, mlrun.common.types.StrEnum):
30
31
  # internal - allowed only in follower mode, only for the leader for upgrade purposes
31
32
  leader = "leader"
32
33
 
34
+ name_and_creation_time = "name_and_creation_time"
35
+
33
36
  @staticmethod
34
37
  def format_method(_format: str) -> typing.Optional[typing.Callable]:
35
38
  def _name_only(project: mlrun.common.schemas.Project) -> str:
36
39
  return project.metadata.name
37
40
 
41
+ def _name_and_creation_time(
42
+ project: mlrun.common.schemas.Project,
43
+ ) -> tuple[str, datetime.datetime]:
44
+ return project.metadata.name, project.metadata.created
45
+
38
46
  def _minimal(
39
47
  project: mlrun.common.schemas.Project,
40
48
  ) -> mlrun.common.schemas.Project:
@@ -48,4 +56,5 @@ class ProjectFormat(ObjectFormat, mlrun.common.types.StrEnum):
48
56
  ProjectFormat.name_only: _name_only,
49
57
  ProjectFormat.minimal: _minimal,
50
58
  ProjectFormat.leader: None,
59
+ ProjectFormat.name_and_creation_time: _name_and_creation_time,
51
60
  }[_format]
@@ -11,8 +11,5 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- #
15
-
16
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
17
14
 
18
15
  from .helpers import create_model_endpoint_uid
@@ -65,7 +65,7 @@ def parse_model_endpoint_store_prefix(store_prefix: str):
65
65
 
66
66
 
67
67
  def parse_monitoring_stream_path(
68
- stream_uri: str, project: str, function_name: str = None
68
+ stream_uri: str, project: str, function_name: typing.Optional[str] = None
69
69
  ):
70
70
  if stream_uri.startswith("kafka://"):
71
71
  if "?topic" in stream_uri:
@@ -15,9 +15,8 @@
15
15
  import enum
16
16
  import typing
17
17
 
18
- import mlrun_pipelines.common.models
19
-
20
18
  import mlrun.common.constants as mlrun_constants
19
+ import mlrun_pipelines.common.models
21
20
 
22
21
 
23
22
  class PodPhases:
@@ -11,10 +11,9 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
- #
15
- # flake8: noqa - this is until we take care of the F401 violations with respect to __all__ & sphinx
16
14
 
17
15
  from .alert import (
16
+ AlertActivation,
18
17
  AlertActiveState,
19
18
  AlertConfig,
20
19
  AlertNotification,
@@ -149,6 +148,10 @@ from .model_monitoring import (
149
148
  ModelEndpointMetadata,
150
149
  ModelEndpointSpec,
151
150
  ModelEndpointStatus,
151
+ ModelEndpointV2,
152
+ ModelEndpointV2Metadata,
153
+ ModelEndpointV2Spec,
154
+ ModelEndpointV2Status,
152
155
  ModelMonitoringMode,
153
156
  ModelMonitoringStoreKinds,
154
157
  MonitoringFunctionNames,
@@ -159,11 +162,13 @@ from .notification import (
159
162
  Notification,
160
163
  NotificationKind,
161
164
  NotificationSeverity,
165
+ NotificationState,
162
166
  NotificationStatus,
163
167
  SetNotificationRequest,
164
168
  )
165
169
  from .object import ObjectKind, ObjectMetadata, ObjectSpec, ObjectStatus
166
170
  from .pagination import PaginationInfo
171
+ from .partition import PartitionInterval
167
172
  from .pipeline import PipelinesOutput, PipelinesPagination
168
173
  from .project import (
169
174
  IguazioProject,
@@ -15,9 +15,9 @@
15
15
  from datetime import datetime
16
16
  from typing import Annotated, Optional, Union
17
17
 
18
- import pydantic
18
+ import pydantic.v1
19
19
 
20
- from mlrun.common.schemas.notification import Notification
20
+ import mlrun.common.schemas.notification as notification_objects
21
21
  from mlrun.common.types import StrEnum
22
22
 
23
23
 
@@ -27,10 +27,10 @@ class EventEntityKind(StrEnum):
27
27
  JOB = "job"
28
28
 
29
29
 
30
- class EventEntities(pydantic.BaseModel):
30
+ class EventEntities(pydantic.v1.BaseModel):
31
31
  kind: EventEntityKind
32
32
  project: str
33
- ids: pydantic.conlist(str, min_items=1, max_items=1)
33
+ ids: pydantic.v1.conlist(str, min_items=1, max_items=1)
34
34
 
35
35
 
36
36
  class EventKind(StrEnum):
@@ -64,11 +64,11 @@ _event_kind_entity_map = {
64
64
  }
65
65
 
66
66
 
67
- class Event(pydantic.BaseModel):
67
+ class Event(pydantic.v1.BaseModel):
68
68
  kind: EventKind
69
69
  timestamp: Union[str, datetime] = None # occurrence time
70
70
  entity: EventEntities
71
- value_dict: Optional[dict] = pydantic.Field(default_factory=dict)
71
+ value_dict: Optional[dict] = pydantic.v1.Field(default_factory=dict)
72
72
 
73
73
  def is_valid(self):
74
74
  return self.entity.kind in _event_kind_entity_map[self.kind]
@@ -86,7 +86,7 @@ class AlertSeverity(StrEnum):
86
86
 
87
87
 
88
88
  # what should trigger the alert. must be either event (at least 1), or prometheus query
89
- class AlertTrigger(pydantic.BaseModel):
89
+ class AlertTrigger(pydantic.v1.BaseModel):
90
90
  events: list[EventKind] = []
91
91
  prometheus_alert: str = None
92
92
 
@@ -97,16 +97,16 @@ class AlertTrigger(pydantic.BaseModel):
97
97
  )
98
98
 
99
99
 
100
- class AlertCriteria(pydantic.BaseModel):
100
+ class AlertCriteria(pydantic.v1.BaseModel):
101
101
  count: Annotated[
102
102
  int,
103
- pydantic.Field(
103
+ pydantic.v1.Field(
104
104
  description="Number of events to wait until notification is sent"
105
105
  ),
106
106
  ] = 1
107
107
  period: Annotated[
108
108
  str,
109
- pydantic.Field(
109
+ pydantic.v1.Field(
110
110
  description="Time period during which event occurred. e.g. 1d, 3h, 5m, 15s"
111
111
  ),
112
112
  ] = None
@@ -120,11 +120,11 @@ class ResetPolicy(StrEnum):
120
120
  AUTO = "auto"
121
121
 
122
122
 
123
- class AlertNotification(pydantic.BaseModel):
124
- notification: Notification
123
+ class AlertNotification(pydantic.v1.BaseModel):
124
+ notification: notification_objects.Notification
125
125
  cooldown_period: Annotated[
126
126
  str,
127
- pydantic.Field(
127
+ pydantic.v1.Field(
128
128
  description="Period during which notifications "
129
129
  "will not be sent after initial send. The format of this would be in time."
130
130
  " e.g. 1d, 3h, 5m, 15s"
@@ -132,14 +132,14 @@ class AlertNotification(pydantic.BaseModel):
132
132
  ] = None
133
133
 
134
134
 
135
- class AlertConfig(pydantic.BaseModel):
135
+ class AlertConfig(pydantic.v1.BaseModel):
136
136
  project: str
137
137
  id: int = None
138
138
  name: str
139
139
  description: Optional[str] = ""
140
140
  summary: Annotated[
141
141
  str,
142
- pydantic.Field(
142
+ pydantic.v1.Field(
143
143
  description=(
144
144
  "String to be sent in the notifications generated."
145
145
  "e.g. 'Model {{project}}/{{entity}} is drifting.'"
@@ -153,11 +153,11 @@ class AlertConfig(pydantic.BaseModel):
153
153
  trigger: AlertTrigger
154
154
  criteria: Optional[AlertCriteria]
155
155
  reset_policy: ResetPolicy = ResetPolicy.AUTO
156
- notifications: pydantic.conlist(AlertNotification, min_items=1)
156
+ notifications: pydantic.v1.conlist(AlertNotification, min_items=1)
157
157
  state: AlertActiveState = AlertActiveState.INACTIVE
158
158
  count: Optional[int] = 0
159
159
 
160
- def get_raw_notifications(self) -> list[Notification]:
160
+ def get_raw_notifications(self) -> list[notification_objects.Notification]:
161
161
  return [
162
162
  alert_notification.notification for alert_notification in self.notifications
163
163
  ]
@@ -169,7 +169,7 @@ class AlertsModes(StrEnum):
169
169
 
170
170
 
171
171
  class AlertTemplate(
172
- pydantic.BaseModel
172
+ pydantic.v1.BaseModel
173
173
  ): # Template fields that are not shared with created configs
174
174
  template_id: int = None
175
175
  template_name: str
@@ -200,3 +200,16 @@ class AlertTemplate(
200
200
  or self.reset_policy != other.reset_policy
201
201
  or self.criteria != other.criteria
202
202
  )
203
+
204
+
205
+ class AlertActivation(pydantic.v1.BaseModel):
206
+ name: str
207
+ project: str
208
+ severity: AlertSeverity
209
+ activation_time: datetime
210
+ entity_id: str
211
+ entity_kind: EventEntityKind
212
+ criteria: AlertCriteria
213
+ event_kind: EventKind
214
+ number_of_events: int
215
+ notifications: list[notification_objects.NotificationState]
@@ -15,7 +15,7 @@
15
15
  import typing
16
16
  from typing import Optional
17
17
 
18
- import pydantic
18
+ import pydantic.v1
19
19
 
20
20
  import mlrun.common.constants as mlrun_constants
21
21
  import mlrun.common.types
@@ -49,9 +49,9 @@ class APIGatewayState(mlrun.common.types.StrEnum):
49
49
  waiting_for_provisioning = "waitingForProvisioning"
50
50
 
51
51
 
52
- class _APIGatewayBaseModel(pydantic.BaseModel):
52
+ class _APIGatewayBaseModel(pydantic.v1.BaseModel):
53
53
  class Config:
54
- extra = pydantic.Extra.allow
54
+ extra = pydantic.v1.Extra.allow
55
55
 
56
56
 
57
57
  class APIGatewayMetadata(_APIGatewayBaseModel):
@@ -14,7 +14,7 @@
14
14
  #
15
15
  import typing
16
16
 
17
- import pydantic
17
+ import pydantic.v1
18
18
  from deprecated import deprecated
19
19
 
20
20
  import mlrun.common.types
@@ -47,14 +47,8 @@ class ArtifactCategories(mlrun.common.types.StrEnum):
47
47
  True,
48
48
  )
49
49
 
50
- @classmethod
51
- def from_kind(cls, kind: str) -> "ArtifactCategories":
52
- if kind in [cls.model.value, cls.dataset.value]:
53
- return cls(kind)
54
- return cls.other
55
50
 
56
-
57
- class ArtifactIdentifier(pydantic.BaseModel):
51
+ class ArtifactIdentifier(pydantic.v1.BaseModel):
58
52
  # artifact kind
59
53
  kind: typing.Optional[str]
60
54
  key: typing.Optional[str]
@@ -75,7 +69,7 @@ class ArtifactsFormat(mlrun.common.types.StrEnum):
75
69
  full = "full"
76
70
 
77
71
 
78
- class ArtifactMetadata(pydantic.BaseModel):
72
+ class ArtifactMetadata(pydantic.v1.BaseModel):
79
73
  key: str
80
74
  project: str
81
75
  iter: typing.Optional[int]
@@ -83,10 +77,10 @@ class ArtifactMetadata(pydantic.BaseModel):
83
77
  tag: typing.Optional[str]
84
78
 
85
79
  class Config:
86
- extra = pydantic.Extra.allow
80
+ extra = pydantic.v1.Extra.allow
87
81
 
88
82
 
89
- class ArtifactSpec(pydantic.BaseModel):
83
+ class ArtifactSpec(pydantic.v1.BaseModel):
90
84
  src_path: typing.Optional[str]
91
85
  target_path: typing.Optional[str]
92
86
  viewer: typing.Optional[str]
@@ -97,10 +91,10 @@ class ArtifactSpec(pydantic.BaseModel):
97
91
  unpackaging_instructions: typing.Optional[dict[str, typing.Any]]
98
92
 
99
93
  class Config:
100
- extra = pydantic.Extra.allow
94
+ extra = pydantic.v1.Extra.allow
101
95
 
102
96
 
103
- class Artifact(pydantic.BaseModel):
97
+ class Artifact(pydantic.v1.BaseModel):
104
98
  kind: str
105
99
  metadata: ArtifactMetadata
106
100
  spec: ArtifactSpec
@@ -14,7 +14,7 @@
14
14
  #
15
15
  import typing
16
16
 
17
- import pydantic
17
+ import pydantic.v1
18
18
  from nuclio.auth import AuthInfo as NuclioAuthInfo
19
19
  from nuclio.auth import AuthKinds as NuclioAuthKinds
20
20
 
@@ -59,6 +59,7 @@ class AuthorizationResourceTypes(mlrun.common.types.StrEnum):
59
59
  hub_source = "hub-source"
60
60
  workflow = "workflow"
61
61
  alert = "alert"
62
+ alert_activations = "alert-activations"
62
63
  alert_templates = "alert-templates"
63
64
  event = "event"
64
65
  datastore_profile = "datastore-profile"
@@ -90,6 +91,7 @@ class AuthorizationResourceTypes(mlrun.common.types.StrEnum):
90
91
  AuthorizationResourceTypes.run: "/projects/{project_name}/runs/{resource_name}",
91
92
  AuthorizationResourceTypes.event: "/projects/{project_name}/events/{resource_name}",
92
93
  AuthorizationResourceTypes.alert: "/projects/{project_name}/alerts/{resource_name}",
94
+ AuthorizationResourceTypes.alert_activations: "/projects/{project_name}/alerts/{resource_name}/activations",
93
95
  AuthorizationResourceTypes.alert_templates: "/alert-templates/{resource_name}",
94
96
  # runtime resource doesn't have an identifier, we don't need any auth granularity behind project level
95
97
  AuthorizationResourceTypes.runtime_resource: "/projects/{project_name}/runtime-resources",
@@ -106,12 +108,12 @@ class AuthorizationResourceTypes(mlrun.common.types.StrEnum):
106
108
  }[self].format(project_name=project_name, resource_name=resource_name)
107
109
 
108
110
 
109
- class AuthorizationVerificationInput(pydantic.BaseModel):
111
+ class AuthorizationVerificationInput(pydantic.v1.BaseModel):
110
112
  resource: str
111
113
  action: AuthorizationAction
112
114
 
113
115
 
114
- class AuthInfo(pydantic.BaseModel):
116
+ class AuthInfo(pydantic.v1.BaseModel):
115
117
  # Basic + Iguazio auth
116
118
  username: typing.Optional[str] = None
117
119
  # Basic auth
@@ -145,5 +147,5 @@ class AuthInfo(pydantic.BaseModel):
145
147
  return self.data_session or self.session
146
148
 
147
149
 
148
- class Credentials(pydantic.BaseModel):
150
+ class Credentials(pydantic.v1.BaseModel):
149
151
  access_key: typing.Optional[str]
@@ -15,7 +15,7 @@
15
15
  import datetime
16
16
  import typing
17
17
 
18
- import pydantic
18
+ import pydantic.v1
19
19
 
20
20
  import mlrun.common.types
21
21
 
@@ -35,7 +35,7 @@ class BackgroundTaskState(mlrun.common.types.StrEnum):
35
35
  ]
36
36
 
37
37
 
38
- class BackgroundTaskMetadata(pydantic.BaseModel):
38
+ class BackgroundTaskMetadata(pydantic.v1.BaseModel):
39
39
  name: str
40
40
  kind: typing.Optional[str]
41
41
  project: typing.Optional[str]
@@ -44,21 +44,21 @@ class BackgroundTaskMetadata(pydantic.BaseModel):
44
44
  timeout: typing.Optional[int]
45
45
 
46
46
 
47
- class BackgroundTaskSpec(pydantic.BaseModel):
47
+ class BackgroundTaskSpec(pydantic.v1.BaseModel):
48
48
  pass
49
49
 
50
50
 
51
- class BackgroundTaskStatus(pydantic.BaseModel):
51
+ class BackgroundTaskStatus(pydantic.v1.BaseModel):
52
52
  state: BackgroundTaskState
53
53
  error: typing.Optional[str]
54
54
 
55
55
 
56
- class BackgroundTask(pydantic.BaseModel):
57
- kind: ObjectKind = pydantic.Field(ObjectKind.background_task, const=True)
56
+ class BackgroundTask(pydantic.v1.BaseModel):
57
+ kind: ObjectKind = pydantic.v1.Field(ObjectKind.background_task, const=True)
58
58
  metadata: BackgroundTaskMetadata
59
59
  spec: BackgroundTaskSpec
60
60
  status: BackgroundTaskStatus
61
61
 
62
62
 
63
- class BackgroundTaskList(pydantic.BaseModel):
63
+ class BackgroundTaskList(pydantic.v1.BaseModel):
64
64
  background_tasks: list[BackgroundTask]
@@ -14,13 +14,13 @@
14
14
  #
15
15
  import typing
16
16
 
17
- import pydantic
17
+ import pydantic.v1
18
18
 
19
19
  from .function import Function
20
20
  from .k8s import Resources
21
21
 
22
22
 
23
- class ClientSpec(pydantic.BaseModel):
23
+ class ClientSpec(pydantic.v1.BaseModel):
24
24
  version: typing.Optional[str]
25
25
  namespace: typing.Optional[str]
26
26
  docker_registry: typing.Optional[str]
@@ -14,12 +14,12 @@
14
14
  #
15
15
  import typing
16
16
 
17
- import pydantic
17
+ import pydantic.v1
18
18
 
19
19
  import mlrun.common.types
20
20
 
21
21
 
22
- class ClusterizationSpec(pydantic.BaseModel):
22
+ class ClusterizationSpec(pydantic.v1.BaseModel):
23
23
  chief_api_state: typing.Optional[str]
24
24
  chief_version: typing.Optional[str]
25
25
 
@@ -14,10 +14,12 @@
14
14
 
15
15
  import typing
16
16
 
17
- import pydantic
17
+ import pydantic.v1
18
18
 
19
+ import mlrun.errors
19
20
 
20
- class ImageBuilder(pydantic.BaseModel):
21
+
22
+ class ImageBuilder(pydantic.v1.BaseModel):
21
23
  functionSourceCode: typing.Optional[str] = None # noqa: N815
22
24
  codeEntryType: typing.Optional[str] = None # noqa: N815
23
25
  codeEntryAttributes: typing.Optional[str] = None # noqa: N815
@@ -40,4 +42,52 @@ class ImageBuilder(pydantic.BaseModel):
40
42
  source_code_target_dir: typing.Optional[str] = None
41
43
 
42
44
  class Config:
43
- extra = pydantic.Extra.allow
45
+ extra = pydantic.v1.Extra.allow
46
+
47
+
48
+ class LabelsModel(pydantic.v1.BaseModel):
49
+ """
50
+ This class accepts either a dictionary, a list, or a string for filtering by labels.
51
+
52
+ :param labels:
53
+ - If a dictionary is provided, it should be in the format {'label_name': 'value'}.
54
+ The values can also be `None`, which will result in the format 'label_name' (without a value).
55
+ This will be converted to a list of strings in the format 'label_name=value'.
56
+ - If a list is provided, all items must be strings. Each string can either
57
+ be a simple label name (e.g., 'label1') or a key-value pair in the format
58
+ 'label=value'.
59
+ - If a string is provided, it should be a comma-separated list of labels
60
+ (e.g., 'label1,label2').
61
+ - If no labels are specified, the default is an empty list.
62
+ """
63
+
64
+ labels: typing.Optional[
65
+ typing.Union[str, dict[str, typing.Optional[str]], list[str]]
66
+ ]
67
+
68
+ @pydantic.v1.validator("labels")
69
+ @classmethod
70
+ def validate(cls, labels) -> list[str]:
71
+ if labels is None:
72
+ return []
73
+
74
+ # If labels is a string, split it by commas
75
+ if isinstance(labels, str):
76
+ return [label.strip() for label in labels.split(",") if label.strip()]
77
+
78
+ if isinstance(labels, list):
79
+ if not all(isinstance(item, str) for item in labels):
80
+ raise mlrun.errors.MLRunValueError(
81
+ "All items in the list must be strings."
82
+ )
83
+ return labels
84
+
85
+ if isinstance(labels, dict):
86
+ return [
87
+ f"{key}={value}" if value is not None else key
88
+ for key, value in labels.items()
89
+ ]
90
+
91
+ raise mlrun.errors.MLRunValueError(
92
+ "Invalid labels format. Must be a string, dictionary of strings, or a list of strings."
93
+ )
@@ -15,7 +15,7 @@
15
15
 
16
16
  import typing
17
17
 
18
- from pydantic import BaseModel
18
+ from pydantic.v1 import BaseModel
19
19
 
20
20
 
21
21
  class DatastoreProfile(BaseModel):
@@ -14,7 +14,7 @@
14
14
  #
15
15
  from typing import Optional
16
16
 
17
- import pydantic
17
+ import pydantic.v1
18
18
 
19
19
  from .auth import AuthorizationResourceTypes, Credentials
20
20
  from .object import (
@@ -27,7 +27,7 @@ from .object import (
27
27
  )
28
28
 
29
29
 
30
- class FeatureStoreBaseModel(pydantic.BaseModel):
30
+ class FeatureStoreBaseModel(pydantic.v1.BaseModel):
31
31
  """
32
32
  Intermediate base class, in order to override pydantic's configuration, as per
33
33
  https://docs.pydantic.dev/1.10/usage/model_config/#change-behaviour-globally
@@ -43,7 +43,7 @@ class Feature(FeatureStoreBaseModel):
43
43
  labels: Optional[dict] = {}
44
44
 
45
45
  class Config:
46
- extra = pydantic.Extra.allow
46
+ extra = pydantic.v1.Extra.allow
47
47
 
48
48
 
49
49
  class Entity(FeatureStoreBaseModel):
@@ -52,17 +52,17 @@ class Entity(FeatureStoreBaseModel):
52
52
  labels: Optional[dict] = {}
53
53
 
54
54
  class Config:
55
- extra = pydantic.Extra.allow
55
+ extra = pydantic.v1.Extra.allow
56
56
 
57
57
 
58
58
  class FeatureSetSpec(ObjectSpec):
59
59
  entities: list[Entity] = []
60
60
  features: list[Feature] = []
61
- engine: Optional[str] = pydantic.Field(default="storey")
61
+ engine: Optional[str] = pydantic.v1.Field(default="storey")
62
62
 
63
63
 
64
64
  class FeatureSet(FeatureStoreBaseModel):
65
- kind: ObjectKind = pydantic.Field(ObjectKind.feature_set, const=True)
65
+ kind: ObjectKind = pydantic.v1.Field(ObjectKind.feature_set, const=True)
66
66
  metadata: ObjectMetadata
67
67
  spec: FeatureSetSpec
68
68
  status: ObjectStatus
@@ -155,7 +155,7 @@ class EntitiesOutput(FeatureStoreBaseModel):
155
155
 
156
156
 
157
157
  class FeatureVector(FeatureStoreBaseModel):
158
- kind: ObjectKind = pydantic.Field(ObjectKind.feature_vector, const=True)
158
+ kind: ObjectKind = pydantic.v1.Field(ObjectKind.feature_vector, const=True)
159
159
  metadata: ObjectMetadata
160
160
  spec: ObjectSpec
161
161
  status: ObjectStatus
@@ -183,7 +183,7 @@ class DataSource(FeatureStoreBaseModel):
183
183
  path: str
184
184
 
185
185
  class Config:
186
- extra = pydantic.Extra.allow
186
+ extra = pydantic.v1.Extra.allow
187
187
 
188
188
 
189
189
  class DataTarget(FeatureStoreBaseModel):
@@ -192,7 +192,7 @@ class DataTarget(FeatureStoreBaseModel):
192
192
  path: Optional[str]
193
193
 
194
194
  class Config:
195
- extra = pydantic.Extra.allow
195
+ extra = pydantic.v1.Extra.allow
196
196
 
197
197
 
198
198
  class FeatureSetIngestInput(FeatureStoreBaseModel):
@@ -14,7 +14,7 @@
14
14
  #
15
15
  import typing
16
16
 
17
- import pydantic
17
+ import pydantic.v1
18
18
 
19
19
  import mlrun.common.types
20
20
 
@@ -43,20 +43,20 @@ class NuclioStreamsFeatureFlag(mlrun.common.types.StrEnum):
43
43
  disabled = "disabled"
44
44
 
45
45
 
46
- class FeatureFlags(pydantic.BaseModel):
46
+ class FeatureFlags(pydantic.v1.BaseModel):
47
47
  project_membership: ProjectMembershipFeatureFlag
48
48
  authentication: AuthenticationFeatureFlag
49
49
  nuclio_streams: NuclioStreamsFeatureFlag
50
50
  preemption_nodes: PreemptionNodesFeatureFlag
51
51
 
52
52
 
53
- class ArtifactLimits(pydantic.BaseModel):
53
+ class ArtifactLimits(pydantic.v1.BaseModel):
54
54
  max_chunk_size: int
55
55
  max_preview_size: int
56
56
  max_download_size: int
57
57
 
58
58
 
59
- class FrontendSpec(pydantic.BaseModel):
59
+ class FrontendSpec(pydantic.v1.BaseModel):
60
60
  jobs_dashboard_url: typing.Optional[str]
61
61
  model_monitoring_dashboard_url: typing.Optional[str]
62
62
  abortable_function_kinds: list[str] = []