mlrun 1.8.0rc1__py3-none-any.whl → 1.8.0rc3__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 (83) hide show
  1. mlrun/__init__.py +5 -7
  2. mlrun/__main__.py +1 -1
  3. mlrun/artifacts/__init__.py +1 -0
  4. mlrun/artifacts/document.py +313 -0
  5. mlrun/artifacts/manager.py +2 -0
  6. mlrun/common/formatters/project.py +9 -0
  7. mlrun/common/schemas/__init__.py +4 -0
  8. mlrun/common/schemas/alert.py +31 -18
  9. mlrun/common/schemas/api_gateway.py +3 -3
  10. mlrun/common/schemas/artifact.py +7 -7
  11. mlrun/common/schemas/auth.py +6 -4
  12. mlrun/common/schemas/background_task.py +7 -7
  13. mlrun/common/schemas/client_spec.py +2 -2
  14. mlrun/common/schemas/clusterization_spec.py +2 -2
  15. mlrun/common/schemas/common.py +5 -5
  16. mlrun/common/schemas/constants.py +15 -0
  17. mlrun/common/schemas/datastore_profile.py +1 -1
  18. mlrun/common/schemas/feature_store.py +9 -9
  19. mlrun/common/schemas/frontend_spec.py +4 -4
  20. mlrun/common/schemas/function.py +10 -10
  21. mlrun/common/schemas/hub.py +1 -1
  22. mlrun/common/schemas/k8s.py +3 -3
  23. mlrun/common/schemas/memory_reports.py +3 -3
  24. mlrun/common/schemas/model_monitoring/grafana.py +1 -1
  25. mlrun/common/schemas/model_monitoring/model_endpoint_v2.py +1 -1
  26. mlrun/common/schemas/model_monitoring/model_endpoints.py +1 -1
  27. mlrun/common/schemas/notification.py +18 -3
  28. mlrun/common/schemas/object.py +1 -1
  29. mlrun/common/schemas/pagination.py +4 -4
  30. mlrun/common/schemas/partition.py +16 -1
  31. mlrun/common/schemas/pipeline.py +2 -2
  32. mlrun/common/schemas/project.py +22 -17
  33. mlrun/common/schemas/runs.py +2 -2
  34. mlrun/common/schemas/runtime_resource.py +5 -5
  35. mlrun/common/schemas/schedule.py +1 -1
  36. mlrun/common/schemas/secret.py +1 -1
  37. mlrun/common/schemas/tag.py +3 -3
  38. mlrun/common/schemas/workflow.py +5 -5
  39. mlrun/config.py +23 -1
  40. mlrun/datastore/datastore_profile.py +38 -19
  41. mlrun/datastore/vectorstore.py +186 -0
  42. mlrun/db/base.py +58 -6
  43. mlrun/db/httpdb.py +267 -15
  44. mlrun/db/nopdb.py +44 -5
  45. mlrun/execution.py +47 -1
  46. mlrun/model.py +2 -2
  47. mlrun/model_monitoring/applications/results.py +2 -2
  48. mlrun/model_monitoring/db/tsdb/base.py +2 -2
  49. mlrun/model_monitoring/db/tsdb/tdengine/schemas.py +37 -13
  50. mlrun/model_monitoring/db/tsdb/tdengine/tdengine_connector.py +32 -40
  51. mlrun/model_monitoring/helpers.py +4 -10
  52. mlrun/model_monitoring/stream_processing.py +14 -11
  53. mlrun/platforms/__init__.py +44 -13
  54. mlrun/projects/__init__.py +6 -1
  55. mlrun/projects/pipelines.py +184 -55
  56. mlrun/projects/project.py +309 -33
  57. mlrun/run.py +4 -1
  58. mlrun/runtimes/base.py +2 -1
  59. mlrun/runtimes/mounts.py +572 -0
  60. mlrun/runtimes/nuclio/function.py +1 -2
  61. mlrun/runtimes/pod.py +82 -18
  62. mlrun/runtimes/remotesparkjob.py +1 -1
  63. mlrun/runtimes/sparkjob/spark3job.py +1 -1
  64. mlrun/utils/clones.py +1 -1
  65. mlrun/utils/helpers.py +12 -2
  66. mlrun/utils/logger.py +2 -2
  67. mlrun/utils/notifications/notification/__init__.py +22 -19
  68. mlrun/utils/notifications/notification/base.py +12 -12
  69. mlrun/utils/notifications/notification/console.py +6 -6
  70. mlrun/utils/notifications/notification/git.py +6 -6
  71. mlrun/utils/notifications/notification/ipython.py +6 -6
  72. mlrun/utils/notifications/notification/mail.py +149 -0
  73. mlrun/utils/notifications/notification/slack.py +6 -6
  74. mlrun/utils/notifications/notification/webhook.py +6 -6
  75. mlrun/utils/notifications/notification_pusher.py +20 -12
  76. mlrun/utils/regex.py +2 -0
  77. mlrun/utils/version/version.json +2 -2
  78. {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/METADATA +190 -186
  79. {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/RECORD +83 -79
  80. {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/WHEEL +1 -1
  81. {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/LICENSE +0 -0
  82. {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/entry_points.txt +0 -0
  83. {mlrun-1.8.0rc1.dist-info → mlrun-1.8.0rc3.dist-info}/top_level.txt +0 -0
@@ -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,12 +14,12 @@
14
14
 
15
15
  import typing
16
16
 
17
- import pydantic
17
+ import pydantic.v1
18
18
 
19
19
  import mlrun.errors
20
20
 
21
21
 
22
- class ImageBuilder(pydantic.BaseModel):
22
+ class ImageBuilder(pydantic.v1.BaseModel):
23
23
  functionSourceCode: typing.Optional[str] = None # noqa: N815
24
24
  codeEntryType: typing.Optional[str] = None # noqa: N815
25
25
  codeEntryAttributes: typing.Optional[str] = None # noqa: N815
@@ -42,10 +42,10 @@ class ImageBuilder(pydantic.BaseModel):
42
42
  source_code_target_dir: typing.Optional[str] = None
43
43
 
44
44
  class Config:
45
- extra = pydantic.Extra.allow
45
+ extra = pydantic.v1.Extra.allow
46
46
 
47
47
 
48
- class LabelsModel(pydantic.BaseModel):
48
+ class LabelsModel(pydantic.v1.BaseModel):
49
49
  """
50
50
  This class accepts either a dictionary, a list, or a string for filtering by labels.
51
51
 
@@ -65,7 +65,7 @@ class LabelsModel(pydantic.BaseModel):
65
65
  typing.Union[str, dict[str, typing.Optional[str]], list[str]]
66
66
  ]
67
67
 
68
- @pydantic.validator("labels")
68
+ @pydantic.v1.validator("labels")
69
69
  @classmethod
70
70
  def validate(cls, labels) -> list[str]:
71
71
  if labels is None:
@@ -133,6 +133,21 @@ class RunPartitionByField(mlrun.common.types.StrEnum):
133
133
  )
134
134
 
135
135
 
136
+ class ArtifactPartitionByField(mlrun.common.types.StrEnum):
137
+ name = "name" # Supported for artifacts objects
138
+ project_and_name = "project_and_name" # Supported for artifacts objects
139
+
140
+ def to_partition_by_db_field(self, db_cls):
141
+ if self.value == ArtifactPartitionByField.name:
142
+ return db_cls.key
143
+ elif self.value == ArtifactPartitionByField.project_and_name:
144
+ return db_cls.project, db_cls.key
145
+ else:
146
+ raise mlrun.errors.MLRunInvalidArgumentError(
147
+ f"Unknown group by field: {self.value}"
148
+ )
149
+
150
+
136
151
  class SortField(mlrun.common.types.StrEnum):
137
152
  created = "created"
138
153
  updated = "updated"
@@ -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] = []
@@ -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
 
@@ -90,42 +90,42 @@ class SecurityContextEnrichmentModes(mlrun.common.types.StrEnum):
90
90
  disabled = "disabled"
91
91
 
92
92
 
93
- class ImagePullSecret(pydantic.BaseModel):
93
+ class ImagePullSecret(pydantic.v1.BaseModel):
94
94
  default: typing.Optional[str]
95
95
 
96
96
 
97
- class Pipelines(pydantic.BaseModel):
97
+ class Pipelines(pydantic.v1.BaseModel):
98
98
  kfp_pod_user_unix_id: typing.Optional[int]
99
99
 
100
100
 
101
- class SecurityContext(pydantic.BaseModel):
101
+ class SecurityContext(pydantic.v1.BaseModel):
102
102
  default: typing.Optional[str]
103
103
  enrichment_mode: typing.Optional[SecurityContextEnrichmentModes]
104
104
  enrichment_group_id: typing.Optional[int]
105
105
  pipelines: typing.Optional[Pipelines]
106
106
 
107
107
 
108
- class ServiceAccount(pydantic.BaseModel):
108
+ class ServiceAccount(pydantic.v1.BaseModel):
109
109
  default: typing.Optional[str]
110
110
 
111
111
 
112
- class StateThresholds(pydantic.BaseModel):
112
+ class StateThresholds(pydantic.v1.BaseModel):
113
113
  default: typing.Optional[dict[str, str]]
114
114
 
115
115
 
116
- class FunctionSpec(pydantic.BaseModel):
116
+ class FunctionSpec(pydantic.v1.BaseModel):
117
117
  image_pull_secret: typing.Optional[ImagePullSecret]
118
118
  security_context: typing.Optional[SecurityContext]
119
119
  service_account: typing.Optional[ServiceAccount]
120
120
  state_thresholds: typing.Optional[StateThresholds]
121
121
 
122
122
  class Config:
123
- extra = pydantic.Extra.allow
123
+ extra = pydantic.v1.Extra.allow
124
124
 
125
125
 
126
- class Function(pydantic.BaseModel):
126
+ class Function(pydantic.v1.BaseModel):
127
127
  spec: typing.Optional[FunctionSpec]
128
128
  application: typing.Optional[dict[str, typing.Any]]
129
129
 
130
130
  class Config:
131
- extra = pydantic.Extra.allow
131
+ extra = pydantic.v1.Extra.allow
@@ -15,7 +15,7 @@
15
15
  from datetime import datetime, timezone
16
16
  from typing import Optional
17
17
 
18
- from pydantic import BaseModel, Extra, Field
18
+ from pydantic.v1 import BaseModel, Extra, Field
19
19
 
20
20
  import mlrun.common.types
21
21
  import mlrun.config
@@ -14,18 +14,18 @@
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 ResourceSpec(pydantic.BaseModel):
22
+ class ResourceSpec(pydantic.v1.BaseModel):
23
23
  cpu: typing.Optional[str]
24
24
  memory: typing.Optional[str]
25
25
  gpu: typing.Optional[str]
26
26
 
27
27
 
28
- class Resources(pydantic.BaseModel):
28
+ class Resources(pydantic.v1.BaseModel):
29
29
  requests: ResourceSpec = ResourceSpec()
30
30
  limits: ResourceSpec = ResourceSpec()
31
31
 
@@ -15,14 +15,14 @@
15
15
 
16
16
  import typing
17
17
 
18
- import pydantic
18
+ import pydantic.v1
19
19
 
20
20
 
21
- class MostCommonObjectTypesReport(pydantic.BaseModel):
21
+ class MostCommonObjectTypesReport(pydantic.v1.BaseModel):
22
22
  object_types: list[tuple[str, int]]
23
23
 
24
24
 
25
- class ObjectTypeReport(pydantic.BaseModel):
25
+ class ObjectTypeReport(pydantic.v1.BaseModel):
26
26
  object_type: str
27
27
  sample_size: int
28
28
  start_index: typing.Optional[int]
@@ -14,7 +14,7 @@
14
14
 
15
15
  from typing import Optional, Union
16
16
 
17
- from pydantic import BaseModel
17
+ from pydantic.v1 import BaseModel
18
18
 
19
19
  import mlrun.common.types
20
20
 
@@ -15,7 +15,7 @@
15
15
  import abc
16
16
  from typing import Optional
17
17
 
18
- from pydantic import BaseModel, Field, constr
18
+ from pydantic.v1 import BaseModel, Field, constr
19
19
 
20
20
  from ..object import ObjectKind, ObjectMetadata, ObjectSpec, ObjectStatus
21
21
  from .constants import (
@@ -17,7 +17,7 @@ import json
17
17
  from datetime import datetime
18
18
  from typing import Any, NamedTuple, Optional, TypeVar
19
19
 
20
- from pydantic import BaseModel, Extra, Field, constr, validator
20
+ from pydantic.v1 import BaseModel, Extra, Field, constr, validator
21
21
 
22
22
  # TODO: remove the unused import below after `mlrun.datastore` and `mlrun.utils` usage is removed.
23
23
  # At the moment `make lint` fails if this is removed.
@@ -15,8 +15,9 @@
15
15
  import datetime
16
16
  import enum
17
17
  import typing
18
+ from typing import Optional
18
19
 
19
- import pydantic
20
+ import pydantic.v1
20
21
 
21
22
  import mlrun.common.types
22
23
 
@@ -45,6 +46,13 @@ class NotificationKind(mlrun.common.types.StrEnum):
45
46
  slack: str = "slack"
46
47
  """**webhook** - The slack webhook to which to send the notification."""
47
48
 
49
+ mail: str = "mail"
50
+ """
51
+ **email_addresses** - The target mails\n
52
+ **subject** - The subject of the mail\n
53
+ **body** - The body of the mail\n
54
+ """
55
+
48
56
  webhook: str = "webhook"
49
57
  """
50
58
  **url** - The webhook url to which to send the notification.\n
@@ -86,7 +94,7 @@ class NotificationLimits(enum.Enum):
86
94
  ) # 900KB (k8s secret size limit is 1MB minus buffer for metadata)
87
95
 
88
96
 
89
- class Notification(pydantic.BaseModel):
97
+ class Notification(pydantic.v1.BaseModel):
90
98
  """
91
99
  Notification object schema
92
100
 
@@ -120,5 +128,12 @@ class Notification(pydantic.BaseModel):
120
128
  reason: typing.Optional[str] = None
121
129
 
122
130
 
123
- class SetNotificationRequest(pydantic.BaseModel):
131
+ class SetNotificationRequest(pydantic.v1.BaseModel):
124
132
  notifications: list[Notification] = None
133
+
134
+
135
+ class NotificationState(pydantic.v1.BaseModel):
136
+ kind: str
137
+ err: Optional[
138
+ str
139
+ ] # empty error means that the notifications were sent successfully
@@ -15,7 +15,7 @@
15
15
  from datetime import datetime
16
16
  from typing import Optional
17
17
 
18
- from pydantic import BaseModel, Extra
18
+ from pydantic.v1 import BaseModel, Extra
19
19
 
20
20
  import mlrun.common.types
21
21
 
@@ -14,13 +14,13 @@
14
14
 
15
15
  import typing
16
16
 
17
- import pydantic
17
+ import pydantic.v1
18
18
 
19
19
 
20
- class PaginationInfo(pydantic.BaseModel):
20
+ class PaginationInfo(pydantic.v1.BaseModel):
21
21
  class Config:
22
22
  allow_population_by_field_name = True
23
23
 
24
24
  page: typing.Optional[int]
25
- page_size: typing.Optional[int] = pydantic.Field(alias="page-size")
26
- page_token: typing.Optional[str] = pydantic.Field(alias="page-token")
25
+ page_size: typing.Optional[int] = pydantic.v1.Field(alias="page-size")
26
+ page_token: typing.Optional[str] = pydantic.v1.Field(alias="page-token")
@@ -30,6 +30,21 @@ class PartitionInterval(StrEnum):
30
30
  def valid_intervals(cls) -> list:
31
31
  return list(cls._value2member_map_.keys())
32
32
 
33
+ def as_duration(self) -> timedelta:
34
+ """
35
+ Convert the partition interval to a duration-like timedelta.
36
+
37
+ Returns:
38
+ timedelta: A duration representing the partition interval.
39
+ """
40
+ if self == PartitionInterval.DAY:
41
+ return timedelta(days=1)
42
+ elif self == PartitionInterval.MONTH:
43
+ # Approximate a month as 30 days
44
+ return timedelta(days=30)
45
+ elif self == PartitionInterval.YEARWEEK:
46
+ return timedelta(weeks=1)
47
+
33
48
  @classmethod
34
49
  def from_function(cls, partition_function: str):
35
50
  """
@@ -48,7 +63,7 @@ class PartitionInterval(StrEnum):
48
63
  interval = partition_function_to_partitions_interval.get(partition_function)
49
64
  if interval and cls.is_valid(interval):
50
65
  return cls[interval]
51
- return None
66
+ raise KeyError(f"Partition function: {partition_function} isn't supported")
52
67
 
53
68
  def get_partition_info(
54
69
  self,
@@ -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
@@ -39,7 +39,7 @@ class PipelinesPagination(str):
39
39
  max_page_size = 200
40
40
 
41
41
 
42
- class PipelinesOutput(pydantic.BaseModel):
42
+ class PipelinesOutput(pydantic.v1.BaseModel):
43
43
  # use the format query param to control what is returned
44
44
  runs: list[typing.Union[dict, str]]
45
45
  total_size: int