zenml-nightly 0.75.0.dev20250313__py3-none-any.whl → 0.75.0.dev20250315__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.
- zenml/VERSION +1 -1
- zenml/analytics/context.py +4 -4
- zenml/analytics/enums.py +2 -2
- zenml/artifacts/utils.py +2 -2
- zenml/cli/__init__.py +8 -9
- zenml/cli/base.py +2 -2
- zenml/cli/code_repository.py +1 -1
- zenml/cli/login.py +21 -18
- zenml/cli/pipeline.py +3 -3
- zenml/cli/project.py +172 -0
- zenml/cli/server.py +5 -5
- zenml/cli/service_accounts.py +0 -1
- zenml/cli/service_connectors.py +15 -16
- zenml/cli/stack.py +0 -2
- zenml/cli/stack_components.py +2 -2
- zenml/cli/utils.py +3 -3
- zenml/client.py +352 -341
- zenml/config/global_config.py +41 -43
- zenml/config/server_config.py +9 -9
- zenml/constants.py +5 -3
- zenml/event_hub/event_hub.py +1 -1
- zenml/integrations/gcp/__init__.py +1 -0
- zenml/integrations/gcp/flavors/vertex_orchestrator_flavor.py +5 -0
- zenml/integrations/gcp/flavors/vertex_step_operator_flavor.py +5 -28
- zenml/integrations/gcp/orchestrators/vertex_orchestrator.py +125 -78
- zenml/integrations/gcp/service_connectors/gcp_service_connector.py +7 -6
- zenml/integrations/gcp/vertex_custom_job_parameters.py +50 -0
- zenml/integrations/mlflow/steps/mlflow_registry.py +3 -3
- zenml/integrations/wandb/__init__.py +1 -1
- zenml/integrations/wandb/experiment_trackers/wandb_experiment_tracker.py +29 -9
- zenml/integrations/wandb/flavors/wandb_experiment_tracker_flavor.py +2 -0
- zenml/login/credentials.py +26 -27
- zenml/login/credentials_store.py +5 -5
- zenml/login/pro/client.py +9 -9
- zenml/login/pro/utils.py +8 -8
- zenml/login/pro/{tenant → workspace}/__init__.py +1 -1
- zenml/login/pro/{tenant → workspace}/client.py +25 -25
- zenml/login/pro/{tenant → workspace}/models.py +27 -28
- zenml/model/model.py +2 -2
- zenml/model_registries/base_model_registry.py +1 -1
- zenml/models/__init__.py +29 -29
- zenml/models/v2/base/filter.py +1 -1
- zenml/models/v2/base/scoped.py +49 -53
- zenml/models/v2/core/action.py +12 -12
- zenml/models/v2/core/artifact.py +15 -15
- zenml/models/v2/core/artifact_version.py +15 -15
- zenml/models/v2/core/code_repository.py +12 -12
- zenml/models/v2/core/event_source.py +12 -12
- zenml/models/v2/core/model.py +26 -18
- zenml/models/v2/core/model_version.py +15 -15
- zenml/models/v2/core/pipeline.py +15 -15
- zenml/models/v2/core/pipeline_build.py +14 -14
- zenml/models/v2/core/pipeline_deployment.py +12 -14
- zenml/models/v2/core/pipeline_run.py +16 -16
- zenml/models/v2/core/project.py +203 -0
- zenml/models/v2/core/run_metadata.py +2 -2
- zenml/models/v2/core/run_template.py +15 -15
- zenml/models/v2/core/schedule.py +12 -12
- zenml/models/v2/core/secret.py +1 -1
- zenml/models/v2/core/service.py +14 -14
- zenml/models/v2/core/step_run.py +13 -13
- zenml/models/v2/core/tag.py +96 -3
- zenml/models/v2/core/trigger.py +13 -13
- zenml/models/v2/core/trigger_execution.py +2 -2
- zenml/models/v2/core/user.py +0 -17
- zenml/models/v2/misc/server_models.py +6 -6
- zenml/models/v2/misc/statistics.py +4 -4
- zenml/orchestrators/cache_utils.py +7 -7
- zenml/orchestrators/input_utils.py +1 -1
- zenml/orchestrators/step_launcher.py +1 -1
- zenml/orchestrators/step_run_utils.py +3 -3
- zenml/orchestrators/utils.py +4 -4
- zenml/pipelines/build_utils.py +2 -2
- zenml/pipelines/pipeline_definition.py +5 -5
- zenml/pipelines/run_utils.py +1 -1
- zenml/service_connectors/service_connector.py +0 -3
- zenml/service_connectors/service_connector_utils.py +0 -1
- zenml/stack/stack.py +0 -1
- zenml/steps/base_step.py +10 -2
- zenml/utils/dashboard_utils.py +1 -1
- zenml/utils/tag_utils.py +0 -12
- zenml/zen_server/cloud_utils.py +3 -3
- zenml/zen_server/feature_gate/endpoint_utils.py +1 -1
- zenml/zen_server/feature_gate/zenml_cloud_feature_gate.py +1 -1
- zenml/zen_server/rbac/endpoint_utils.py +17 -17
- zenml/zen_server/rbac/models.py +47 -22
- zenml/zen_server/rbac/rbac_sql_zen_store.py +3 -3
- zenml/zen_server/rbac/utils.py +23 -25
- zenml/zen_server/rbac/zenml_cloud_rbac.py +7 -74
- zenml/zen_server/routers/artifact_version_endpoints.py +10 -10
- zenml/zen_server/routers/auth_endpoints.py +6 -6
- zenml/zen_server/routers/code_repositories_endpoints.py +12 -14
- zenml/zen_server/routers/model_versions_endpoints.py +13 -15
- zenml/zen_server/routers/models_endpoints.py +7 -9
- zenml/zen_server/routers/pipeline_builds_endpoints.py +14 -16
- zenml/zen_server/routers/pipeline_deployments_endpoints.py +13 -15
- zenml/zen_server/routers/pipelines_endpoints.py +16 -18
- zenml/zen_server/routers/{workspaces_endpoints.py → projects_endpoints.py} +111 -68
- zenml/zen_server/routers/run_metadata_endpoints.py +7 -9
- zenml/zen_server/routers/run_templates_endpoints.py +15 -17
- zenml/zen_server/routers/runs_endpoints.py +12 -14
- zenml/zen_server/routers/schedule_endpoints.py +12 -14
- zenml/zen_server/routers/secrets_endpoints.py +1 -3
- zenml/zen_server/routers/server_endpoints.py +7 -7
- zenml/zen_server/routers/service_connectors_endpoints.py +11 -13
- zenml/zen_server/routers/service_endpoints.py +7 -9
- zenml/zen_server/routers/stack_components_endpoints.py +9 -11
- zenml/zen_server/routers/stacks_endpoints.py +9 -11
- zenml/zen_server/routers/steps_endpoints.py +6 -6
- zenml/zen_server/routers/users_endpoints.py +5 -43
- zenml/zen_server/template_execution/utils.py +4 -4
- zenml/zen_server/utils.py +10 -10
- zenml/zen_server/zen_server_api.py +6 -5
- zenml/zen_stores/base_zen_store.py +38 -42
- zenml/zen_stores/migrations/versions/12eff0206201_rename_workspace_to_project.py +768 -0
- zenml/zen_stores/migrations/versions/41b28cae31ce_make_artifacts_workspace_scoped.py +3 -3
- zenml/zen_stores/migrations/versions/cbc6acd71f92_add_workspace_display_name.py +58 -0
- zenml/zen_stores/rest_zen_store.py +55 -63
- zenml/zen_stores/schemas/__init__.py +2 -2
- zenml/zen_stores/schemas/action_schemas.py +9 -9
- zenml/zen_stores/schemas/artifact_schemas.py +15 -17
- zenml/zen_stores/schemas/code_repository_schemas.py +16 -18
- zenml/zen_stores/schemas/event_source_schemas.py +9 -9
- zenml/zen_stores/schemas/model_schemas.py +15 -17
- zenml/zen_stores/schemas/pipeline_build_schemas.py +7 -7
- zenml/zen_stores/schemas/pipeline_deployment_schemas.py +7 -7
- zenml/zen_stores/schemas/pipeline_run_schemas.py +9 -9
- zenml/zen_stores/schemas/pipeline_schemas.py +9 -9
- zenml/zen_stores/schemas/{workspace_schemas.py → project_schemas.py} +47 -41
- zenml/zen_stores/schemas/run_metadata_schemas.py +5 -5
- zenml/zen_stores/schemas/run_template_schemas.py +9 -9
- zenml/zen_stores/schemas/schedule_schema.py +9 -9
- zenml/zen_stores/schemas/service_schemas.py +7 -7
- zenml/zen_stores/schemas/step_run_schemas.py +7 -7
- zenml/zen_stores/schemas/trigger_schemas.py +9 -9
- zenml/zen_stores/schemas/user_schemas.py +0 -12
- zenml/zen_stores/sql_zen_store.py +318 -275
- zenml/zen_stores/zen_store_interface.py +56 -70
- {zenml_nightly-0.75.0.dev20250313.dist-info → zenml_nightly-0.75.0.dev20250315.dist-info}/METADATA +1 -1
- {zenml_nightly-0.75.0.dev20250313.dist-info → zenml_nightly-0.75.0.dev20250315.dist-info}/RECORD +143 -140
- zenml/cli/workspace.py +0 -160
- zenml/models/v2/core/workspace.py +0 -131
- {zenml_nightly-0.75.0.dev20250313.dist-info → zenml_nightly-0.75.0.dev20250315.dist-info}/LICENSE +0 -0
- {zenml_nightly-0.75.0.dev20250313.dist-info → zenml_nightly-0.75.0.dev20250315.dist-info}/WHEEL +0 -0
- {zenml_nightly-0.75.0.dev20250313.dist-info → zenml_nightly-0.75.0.dev20250315.dist-info}/entry_points.txt +0 -0
@@ -11,7 +11,7 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
12
12
|
# or implied. See the License for the specific language governing
|
13
13
|
# permissions and limitations under the License.
|
14
|
-
"""ZenML Pro
|
14
|
+
"""ZenML Pro workspace models."""
|
15
15
|
|
16
16
|
from typing import Optional
|
17
17
|
from uuid import UUID
|
@@ -24,32 +24,32 @@ from zenml.login.pro.organization.models import OrganizationRead
|
|
24
24
|
from zenml.utils.enum_utils import StrEnum
|
25
25
|
|
26
26
|
|
27
|
-
class
|
28
|
-
"""Enum that represents the desired state or status of a
|
27
|
+
class WorkspaceStatus(StrEnum):
|
28
|
+
"""Enum that represents the desired state or status of a workspace.
|
29
29
|
|
30
30
|
These values can be used in two places:
|
31
31
|
|
32
|
-
* in the `desired_state` field of a
|
33
|
-
state of the
|
32
|
+
* in the `desired_state` field of a workspace object, to indicate the desired
|
33
|
+
state of the workspace (with the exception of `PENDING` and `FAILED` which
|
34
34
|
are not valid values for `desired_state`)
|
35
|
-
* in the `status` field of a
|
36
|
-
of the
|
35
|
+
* in the `status` field of a workspace object, to indicate the current state
|
36
|
+
of the workspace
|
37
37
|
"""
|
38
38
|
|
39
|
-
#
|
39
|
+
# Workspace hasn't been deployed yet (i.e. newly created) or has been fully
|
40
40
|
# deleted by the infrastructure provider
|
41
41
|
NOT_INITIALIZED = "not_initialized"
|
42
|
-
#
|
42
|
+
# Workspace is being processed by the infrastructure provider (is being
|
43
43
|
# deployed, updated, deactivated, re-activated or deleted/cleaned up).
|
44
44
|
PENDING = "pending"
|
45
|
-
#
|
45
|
+
# Workspace is up and running
|
46
46
|
AVAILABLE = "available"
|
47
|
-
#
|
47
|
+
# Workspace is in a failure state (i.e. deployment, update or deletion failed)
|
48
48
|
FAILED = "failed"
|
49
|
-
#
|
49
|
+
# Workspace is deactivated
|
50
50
|
DEACTIVATED = "deactivated"
|
51
|
-
#
|
52
|
-
# the
|
51
|
+
# Workspace resources have been deleted by the infrastructure provider but
|
52
|
+
# the workspace object still exists in the database
|
53
53
|
DELETED = "deleted"
|
54
54
|
|
55
55
|
|
@@ -87,24 +87,26 @@ class ZenMLServiceRead(BaseRestAPIModel):
|
|
87
87
|
)
|
88
88
|
|
89
89
|
|
90
|
-
class
|
91
|
-
"""Pydantic Model for viewing a
|
90
|
+
class WorkspaceRead(BaseRestAPIModel):
|
91
|
+
"""Pydantic Model for viewing a Workspace."""
|
92
92
|
|
93
93
|
id: UUID
|
94
94
|
|
95
95
|
name: str
|
96
96
|
description: Optional[str] = Field(
|
97
|
-
default=None, description="The description of the
|
97
|
+
default=None, description="The description of the workspace."
|
98
98
|
)
|
99
99
|
|
100
100
|
organization: OrganizationRead
|
101
101
|
|
102
|
-
desired_state: str = Field(
|
102
|
+
desired_state: str = Field(
|
103
|
+
description="The desired state of the workspace."
|
104
|
+
)
|
103
105
|
state_reason: str = Field(
|
104
|
-
description="The reason for the current
|
106
|
+
description="The reason for the current workspace state.",
|
105
107
|
)
|
106
108
|
status: str = Field(
|
107
|
-
description="The current operational state of the
|
109
|
+
description="The current operational state of the workspace."
|
108
110
|
)
|
109
111
|
zenml_service: ZenMLServiceRead = Field(description="The ZenML service.")
|
110
112
|
|
@@ -156,21 +158,18 @@ class TenantRead(BaseRestAPIModel):
|
|
156
158
|
|
157
159
|
@property
|
158
160
|
def dashboard_url(self) -> str:
|
159
|
-
"""Get the URL to the ZenML Pro dashboard for this
|
161
|
+
"""Get the URL to the ZenML Pro dashboard for this workspace.
|
160
162
|
|
161
163
|
Returns:
|
162
|
-
The URL to the ZenML Pro dashboard for this
|
164
|
+
The URL to the ZenML Pro dashboard for this workspace.
|
163
165
|
"""
|
164
|
-
return (
|
165
|
-
ZENML_PRO_URL
|
166
|
-
+ f"/organizations/{str(self.organization_id)}/tenants/{str(self.id)}"
|
167
|
-
)
|
166
|
+
return ZENML_PRO_URL + f"/workspaces/{str(self.name)}"
|
168
167
|
|
169
168
|
@property
|
170
169
|
def dashboard_organization_url(self) -> str:
|
171
|
-
"""Get the URL to the ZenML Pro dashboard for this
|
170
|
+
"""Get the URL to the ZenML Pro dashboard for this workspace's organization.
|
172
171
|
|
173
172
|
Returns:
|
174
|
-
The URL to the ZenML Pro dashboard for this
|
173
|
+
The URL to the ZenML Pro dashboard for this workspace's organization.
|
175
174
|
"""
|
176
175
|
return ZENML_PRO_URL + f"/organizations/{str(self.organization_id)}"
|
zenml/model/model.py
CHANGED
@@ -548,7 +548,7 @@ class Model(BaseModel):
|
|
548
548
|
limitations=self.limitations,
|
549
549
|
trade_offs=self.trade_offs,
|
550
550
|
ethics=self.ethics,
|
551
|
-
|
551
|
+
project=zenml_client.active_project.id,
|
552
552
|
save_models_to_registry=self.save_models_to_registry,
|
553
553
|
)
|
554
554
|
model_request = ModelRequest.model_validate(model_request)
|
@@ -702,7 +702,7 @@ class Model(BaseModel):
|
|
702
702
|
|
703
703
|
client = Client()
|
704
704
|
model_version_request = ModelVersionRequest(
|
705
|
-
|
705
|
+
project=client.active_project.id,
|
706
706
|
name=str(self.version) if self.version else None,
|
707
707
|
description=self.description,
|
708
708
|
model=model.id,
|
@@ -68,7 +68,7 @@ class ModelRegistryModelMetadata(BaseModel):
|
|
68
68
|
zenml_pipeline_uuid: Optional[str] = None
|
69
69
|
zenml_pipeline_run_uuid: Optional[str] = None
|
70
70
|
zenml_step_name: Optional[str] = None
|
71
|
-
|
71
|
+
zenml_project: Optional[str] = None
|
72
72
|
|
73
73
|
@property
|
74
74
|
def custom_attributes(self) -> Dict[str, str]:
|
zenml/models/__init__.py
CHANGED
@@ -34,13 +34,13 @@ from zenml.models.v2.base.scoped import (
|
|
34
34
|
UserScopedResponse,
|
35
35
|
UserScopedResponseBody,
|
36
36
|
UserScopedResponseMetadata,
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
ProjectScopedRequest,
|
38
|
+
ProjectScopedFilter,
|
39
|
+
ProjectScopedResponse,
|
40
|
+
ProjectScopedResponseBody,
|
41
|
+
ProjectScopedResponseMetadata,
|
42
|
+
ProjectScopedResponseResources,
|
43
|
+
ProjectScopedFilter,
|
44
44
|
)
|
45
45
|
from zenml.models.v2.base.filter import (
|
46
46
|
BaseFilter,
|
@@ -285,7 +285,7 @@ from zenml.models.v2.core.stack import (
|
|
285
285
|
StackResponseMetadata,
|
286
286
|
)
|
287
287
|
from zenml.models.v2.misc.statistics import (
|
288
|
-
|
288
|
+
ProjectStatistics,
|
289
289
|
ServerStatistics,
|
290
290
|
)
|
291
291
|
from zenml.models.v2.core.step_run import (
|
@@ -318,13 +318,13 @@ from zenml.models.v2.core.user import (
|
|
318
318
|
UserResponseBody,
|
319
319
|
UserResponseMetadata,
|
320
320
|
)
|
321
|
-
from zenml.models.v2.core.
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
321
|
+
from zenml.models.v2.core.project import (
|
322
|
+
ProjectRequest,
|
323
|
+
ProjectUpdate,
|
324
|
+
ProjectFilter,
|
325
|
+
ProjectResponse,
|
326
|
+
ProjectResponseBody,
|
327
|
+
ProjectResponseMetadata,
|
328
328
|
)
|
329
329
|
|
330
330
|
# V2 Misc
|
@@ -503,13 +503,13 @@ __all__ = [
|
|
503
503
|
"UserScopedResponse",
|
504
504
|
"UserScopedResponseBody",
|
505
505
|
"UserScopedResponseMetadata",
|
506
|
-
"
|
507
|
-
"
|
508
|
-
"
|
509
|
-
"
|
510
|
-
"
|
511
|
-
"
|
512
|
-
"
|
506
|
+
"ProjectScopedRequest",
|
507
|
+
"ProjectScopedFilter",
|
508
|
+
"ProjectScopedResponse",
|
509
|
+
"ProjectScopedResponseBody",
|
510
|
+
"ProjectScopedResponseMetadata",
|
511
|
+
"ProjectScopedResponseResources",
|
512
|
+
"ProjectScopedFilter",
|
513
513
|
"BaseFilter",
|
514
514
|
"StrFilter",
|
515
515
|
"BoolFilter",
|
@@ -737,12 +737,12 @@ __all__ = [
|
|
737
737
|
"UserResponse",
|
738
738
|
"UserResponseBody",
|
739
739
|
"UserResponseMetadata",
|
740
|
-
"
|
741
|
-
"
|
742
|
-
"
|
743
|
-
"
|
744
|
-
"
|
745
|
-
"
|
740
|
+
"ProjectRequest",
|
741
|
+
"ProjectUpdate",
|
742
|
+
"ProjectFilter",
|
743
|
+
"ProjectResponse",
|
744
|
+
"ProjectResponseBody",
|
745
|
+
"ProjectResponseMetadata",
|
746
746
|
# V2 Misc
|
747
747
|
"AuthenticationMethodModel",
|
748
748
|
"DeployedStack",
|
@@ -776,5 +776,5 @@ __all__ = [
|
|
776
776
|
"ResourcesInfo",
|
777
777
|
"RunMetadataEntry",
|
778
778
|
"RunMetadataResource",
|
779
|
-
"
|
779
|
+
"ProjectStatistics",
|
780
780
|
]
|
zenml/models/v2/base/filter.py
CHANGED
zenml/models/v2/base/scoped.py
CHANGED
@@ -42,8 +42,8 @@ from zenml.models.v2.base.filter import AnyQuery, BaseFilter
|
|
42
42
|
if TYPE_CHECKING:
|
43
43
|
from sqlalchemy.sql.elements import ColumnElement
|
44
44
|
|
45
|
+
from zenml.models.v2.core.project import ProjectResponse
|
45
46
|
from zenml.models.v2.core.user import UserResponse
|
46
|
-
from zenml.models.v2.core.workspace import WorkspaceResponse
|
47
47
|
from zenml.zen_stores.schemas import BaseSchema
|
48
48
|
|
49
49
|
AnySchema = TypeVar("AnySchema", bound=BaseSchema)
|
@@ -80,24 +80,22 @@ class UserScopedRequest(BaseRequest):
|
|
80
80
|
return metadata
|
81
81
|
|
82
82
|
|
83
|
-
class
|
84
|
-
"""Base
|
83
|
+
class ProjectScopedRequest(UserScopedRequest):
|
84
|
+
"""Base project-scoped request domain model.
|
85
85
|
|
86
|
-
Used as a base class for all domain models that are
|
86
|
+
Used as a base class for all domain models that are project-scoped.
|
87
87
|
"""
|
88
88
|
|
89
|
-
|
90
|
-
title="The workspace to which this resource belongs."
|
91
|
-
)
|
89
|
+
project: UUID = Field(title="The project to which this resource belongs.")
|
92
90
|
|
93
91
|
def get_analytics_metadata(self) -> Dict[str, Any]:
|
94
|
-
"""Fetches the analytics metadata for
|
92
|
+
"""Fetches the analytics metadata for project scoped models.
|
95
93
|
|
96
94
|
Returns:
|
97
95
|
The analytics metadata.
|
98
96
|
"""
|
99
97
|
metadata = super().get_analytics_metadata()
|
100
|
-
metadata["
|
98
|
+
metadata["project_id"] = self.project
|
101
99
|
return metadata
|
102
100
|
|
103
101
|
|
@@ -285,79 +283,77 @@ class UserScopedFilter(BaseFilter):
|
|
285
283
|
return query
|
286
284
|
|
287
285
|
|
288
|
-
#
|
286
|
+
# Project-scoped models
|
289
287
|
|
290
288
|
|
291
|
-
class
|
292
|
-
"""Base
|
289
|
+
class ProjectScopedResponseBody(UserScopedResponseBody):
|
290
|
+
"""Base project-scoped body."""
|
293
291
|
|
294
292
|
|
295
|
-
class
|
296
|
-
"""Base
|
293
|
+
class ProjectScopedResponseMetadata(UserScopedResponseMetadata):
|
294
|
+
"""Base project-scoped metadata."""
|
297
295
|
|
298
|
-
|
299
|
-
title="The workspace of this resource."
|
300
|
-
)
|
296
|
+
project: "ProjectResponse" = Field(title="The project of this resource.")
|
301
297
|
|
302
298
|
|
303
|
-
class
|
304
|
-
"""Base
|
299
|
+
class ProjectScopedResponseResources(UserScopedResponseResources):
|
300
|
+
"""Base project-scoped resources."""
|
305
301
|
|
306
302
|
|
307
|
-
|
308
|
-
|
309
|
-
"
|
303
|
+
ProjectBody = TypeVar("ProjectBody", bound=ProjectScopedResponseBody)
|
304
|
+
ProjectMetadata = TypeVar(
|
305
|
+
"ProjectMetadata", bound=ProjectScopedResponseMetadata
|
310
306
|
)
|
311
|
-
|
312
|
-
"
|
307
|
+
ProjectResources = TypeVar(
|
308
|
+
"ProjectResources", bound=ProjectScopedResponseResources
|
313
309
|
)
|
314
310
|
|
315
311
|
|
316
|
-
class
|
317
|
-
UserScopedResponse[
|
318
|
-
Generic[
|
312
|
+
class ProjectScopedResponse(
|
313
|
+
UserScopedResponse[ProjectBody, ProjectMetadata, ProjectResources],
|
314
|
+
Generic[ProjectBody, ProjectMetadata, ProjectResources],
|
319
315
|
):
|
320
|
-
"""Base
|
316
|
+
"""Base project-scoped domain model.
|
321
317
|
|
322
|
-
Used as a base class for all domain models that are
|
318
|
+
Used as a base class for all domain models that are project-scoped.
|
323
319
|
"""
|
324
320
|
|
325
321
|
# Analytics
|
326
322
|
def get_analytics_metadata(self) -> Dict[str, Any]:
|
327
|
-
"""Fetches the analytics metadata for
|
323
|
+
"""Fetches the analytics metadata for project scoped models.
|
328
324
|
|
329
325
|
Returns:
|
330
326
|
The analytics metadata.
|
331
327
|
"""
|
332
328
|
metadata = super().get_analytics_metadata()
|
333
|
-
if self.
|
334
|
-
metadata["
|
329
|
+
if self.project is not None:
|
330
|
+
metadata["project_id"] = self.project.id
|
335
331
|
return metadata
|
336
332
|
|
337
333
|
# Body and metadata properties
|
338
334
|
@property
|
339
|
-
def
|
340
|
-
"""The
|
335
|
+
def project(self) -> "ProjectResponse":
|
336
|
+
"""The project property.
|
341
337
|
|
342
338
|
Returns:
|
343
339
|
the value of the property.
|
344
340
|
"""
|
345
|
-
return self.get_metadata().
|
341
|
+
return self.get_metadata().project
|
346
342
|
|
347
343
|
|
348
344
|
# ---------------------- Filter Models ----------------------
|
349
345
|
|
350
346
|
|
351
|
-
class
|
352
|
-
"""Model to enable advanced scoping with
|
347
|
+
class ProjectScopedFilter(UserScopedFilter):
|
348
|
+
"""Model to enable advanced scoping with project."""
|
353
349
|
|
354
350
|
FILTER_EXCLUDE_FIELDS: ClassVar[List[str]] = [
|
355
351
|
*UserScopedFilter.FILTER_EXCLUDE_FIELDS,
|
356
|
-
"
|
352
|
+
"project",
|
357
353
|
]
|
358
|
-
|
354
|
+
project: Optional[Union[UUID, str]] = Field(
|
359
355
|
default=None,
|
360
|
-
description="Name/ID of the
|
356
|
+
description="Name/ID of the project which the search is scoped to. "
|
361
357
|
"This field must always be set and is always applied in addition to "
|
362
358
|
"the other filters, regardless of the value of the "
|
363
359
|
"logical_operator field.",
|
@@ -379,30 +375,30 @@ class WorkspaceScopedFilter(UserScopedFilter):
|
|
379
375
|
The query with filter applied.
|
380
376
|
|
381
377
|
Raises:
|
382
|
-
ValueError: If the
|
378
|
+
ValueError: If the project scope is missing from the filter.
|
383
379
|
"""
|
384
380
|
query = super().apply_filter(query=query, table=table)
|
385
381
|
|
386
|
-
# The
|
382
|
+
# The project scope must always be set and must be a UUID. If the
|
387
383
|
# client sets this to a string, the server will try to resolve it to a
|
388
|
-
#
|
384
|
+
# project ID.
|
389
385
|
#
|
390
386
|
# If not set by the client, the server will fall back to using the
|
391
|
-
# user's default
|
392
|
-
# they are configured. If this also fails to yield a
|
387
|
+
# user's default project or even the server's default project, if
|
388
|
+
# they are configured. If this also fails to yield a project, this
|
393
389
|
# method will raise a ValueError.
|
394
390
|
#
|
395
|
-
# See: SqlZenStore.
|
391
|
+
# See: SqlZenStore._set_filter_project_id
|
396
392
|
|
397
|
-
if not self.
|
398
|
-
raise ValueError("
|
393
|
+
if not self.project:
|
394
|
+
raise ValueError("Project scope missing from the filter.")
|
399
395
|
|
400
|
-
if not isinstance(self.
|
396
|
+
if not isinstance(self.project, UUID):
|
401
397
|
raise ValueError(
|
402
|
-
f"
|
398
|
+
f"Project scope must be a UUID, got {type(self.project)}."
|
403
399
|
)
|
404
400
|
|
405
|
-
scope_filter = getattr(table, "
|
401
|
+
scope_filter = getattr(table, "project_id") == self.project
|
406
402
|
query = query.where(scope_filter)
|
407
403
|
|
408
404
|
return query
|
@@ -470,7 +466,7 @@ class TaggableFilter(BaseFilter):
|
|
470
466
|
|
471
467
|
query = super().apply_filter(query=query, table=table)
|
472
468
|
|
473
|
-
if self.tags
|
469
|
+
if self.tags:
|
474
470
|
query = query.join(
|
475
471
|
TagResourceSchema,
|
476
472
|
TagResourceSchema.resource_id == getattr(table, "id"),
|
@@ -491,7 +487,7 @@ class TaggableFilter(BaseFilter):
|
|
491
487
|
"""
|
492
488
|
custom_filters = super().get_custom_filters(table)
|
493
489
|
|
494
|
-
if self.tags
|
490
|
+
if self.tags:
|
495
491
|
from sqlmodel import exists, select
|
496
492
|
|
497
493
|
from zenml.zen_stores.schemas import TagResourceSchema, TagSchema
|
zenml/models/v2/core/action.py
CHANGED
@@ -29,12 +29,12 @@ from zenml.constants import STR_FIELD_MAX_LENGTH
|
|
29
29
|
from zenml.enums import PluginSubType
|
30
30
|
from zenml.models.v2.base.base import BaseUpdate
|
31
31
|
from zenml.models.v2.base.scoped import (
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
ProjectScopedFilter,
|
33
|
+
ProjectScopedRequest,
|
34
|
+
ProjectScopedResponse,
|
35
|
+
ProjectScopedResponseBody,
|
36
|
+
ProjectScopedResponseMetadata,
|
37
|
+
ProjectScopedResponseResources,
|
38
38
|
)
|
39
39
|
from zenml.models.v2.core.user import UserResponse
|
40
40
|
|
@@ -47,7 +47,7 @@ if TYPE_CHECKING:
|
|
47
47
|
# ------------------ Request Model ------------------
|
48
48
|
|
49
49
|
|
50
|
-
class ActionRequest(
|
50
|
+
class ActionRequest(ProjectScopedRequest):
|
51
51
|
"""Model for creating a new action."""
|
52
52
|
|
53
53
|
name: str = Field(
|
@@ -131,7 +131,7 @@ class ActionUpdate(BaseUpdate):
|
|
131
131
|
# ------------------ Response Model ------------------
|
132
132
|
|
133
133
|
|
134
|
-
class ActionResponseBody(
|
134
|
+
class ActionResponseBody(ProjectScopedResponseBody):
|
135
135
|
"""Response body for actions."""
|
136
136
|
|
137
137
|
flavor: str = Field(
|
@@ -144,7 +144,7 @@ class ActionResponseBody(WorkspaceScopedResponseBody):
|
|
144
144
|
)
|
145
145
|
|
146
146
|
|
147
|
-
class ActionResponseMetadata(
|
147
|
+
class ActionResponseMetadata(ProjectScopedResponseMetadata):
|
148
148
|
"""Response metadata for actions."""
|
149
149
|
|
150
150
|
description: str = Field(
|
@@ -161,7 +161,7 @@ class ActionResponseMetadata(WorkspaceScopedResponseMetadata):
|
|
161
161
|
)
|
162
162
|
|
163
163
|
|
164
|
-
class ActionResponseResources(
|
164
|
+
class ActionResponseResources(ProjectScopedResponseResources):
|
165
165
|
"""Class for all resource models associated with the action entity."""
|
166
166
|
|
167
167
|
service_account: UserResponse = Field(
|
@@ -170,7 +170,7 @@ class ActionResponseResources(WorkspaceScopedResponseResources):
|
|
170
170
|
|
171
171
|
|
172
172
|
class ActionResponse(
|
173
|
-
|
173
|
+
ProjectScopedResponse[
|
174
174
|
ActionResponseBody, ActionResponseMetadata, ActionResponseResources
|
175
175
|
]
|
176
176
|
):
|
@@ -259,7 +259,7 @@ class ActionResponse(
|
|
259
259
|
# ------------------ Filter Model ------------------
|
260
260
|
|
261
261
|
|
262
|
-
class ActionFilter(
|
262
|
+
class ActionFilter(ProjectScopedFilter):
|
263
263
|
"""Model to enable advanced filtering of all actions."""
|
264
264
|
|
265
265
|
name: Optional[str] = Field(
|
zenml/models/v2/core/artifact.py
CHANGED
@@ -30,13 +30,13 @@ from pydantic import Field
|
|
30
30
|
from zenml.constants import SORT_BY_LATEST_VERSION_KEY, STR_FIELD_MAX_LENGTH
|
31
31
|
from zenml.models.v2.base.base import BaseUpdate
|
32
32
|
from zenml.models.v2.base.scoped import (
|
33
|
+
ProjectScopedFilter,
|
34
|
+
ProjectScopedRequest,
|
35
|
+
ProjectScopedResponse,
|
36
|
+
ProjectScopedResponseBody,
|
37
|
+
ProjectScopedResponseMetadata,
|
38
|
+
ProjectScopedResponseResources,
|
33
39
|
TaggableFilter,
|
34
|
-
WorkspaceScopedFilter,
|
35
|
-
WorkspaceScopedRequest,
|
36
|
-
WorkspaceScopedResponse,
|
37
|
-
WorkspaceScopedResponseBody,
|
38
|
-
WorkspaceScopedResponseMetadata,
|
39
|
-
WorkspaceScopedResponseResources,
|
40
40
|
)
|
41
41
|
from zenml.models.v2.core.tag import TagResponse
|
42
42
|
|
@@ -51,7 +51,7 @@ AnyQuery = TypeVar("AnyQuery", bound=Any)
|
|
51
51
|
# ------------------ Request Model ------------------
|
52
52
|
|
53
53
|
|
54
|
-
class ArtifactRequest(
|
54
|
+
class ArtifactRequest(ProjectScopedRequest):
|
55
55
|
"""Artifact request model."""
|
56
56
|
|
57
57
|
name: str = Field(
|
@@ -84,7 +84,7 @@ class ArtifactUpdate(BaseUpdate):
|
|
84
84
|
# ------------------ Response Model ------------------
|
85
85
|
|
86
86
|
|
87
|
-
class ArtifactResponseBody(
|
87
|
+
class ArtifactResponseBody(ProjectScopedResponseBody):
|
88
88
|
"""Response body for artifacts."""
|
89
89
|
|
90
90
|
tags: List[TagResponse] = Field(
|
@@ -94,7 +94,7 @@ class ArtifactResponseBody(WorkspaceScopedResponseBody):
|
|
94
94
|
latest_version_id: Optional[UUID] = None
|
95
95
|
|
96
96
|
|
97
|
-
class ArtifactResponseMetadata(
|
97
|
+
class ArtifactResponseMetadata(ProjectScopedResponseMetadata):
|
98
98
|
"""Response metadata for artifacts."""
|
99
99
|
|
100
100
|
has_custom_name: bool = Field(
|
@@ -103,12 +103,12 @@ class ArtifactResponseMetadata(WorkspaceScopedResponseMetadata):
|
|
103
103
|
)
|
104
104
|
|
105
105
|
|
106
|
-
class ArtifactResponseResources(
|
106
|
+
class ArtifactResponseResources(ProjectScopedResponseResources):
|
107
107
|
"""Class for all resource models associated with the Artifact Entity."""
|
108
108
|
|
109
109
|
|
110
110
|
class ArtifactResponse(
|
111
|
-
|
111
|
+
ProjectScopedResponse[
|
112
112
|
ArtifactResponseBody,
|
113
113
|
ArtifactResponseMetadata,
|
114
114
|
ArtifactResponseResources,
|
@@ -185,22 +185,22 @@ class ArtifactResponse(
|
|
185
185
|
# ------------------ Filter Model ------------------
|
186
186
|
|
187
187
|
|
188
|
-
class ArtifactFilter(
|
188
|
+
class ArtifactFilter(ProjectScopedFilter, TaggableFilter):
|
189
189
|
"""Model to enable advanced filtering of artifacts."""
|
190
190
|
|
191
191
|
FILTER_EXCLUDE_FIELDS: ClassVar[List[str]] = [
|
192
|
-
*
|
192
|
+
*ProjectScopedFilter.FILTER_EXCLUDE_FIELDS,
|
193
193
|
*TaggableFilter.FILTER_EXCLUDE_FIELDS,
|
194
194
|
]
|
195
195
|
|
196
196
|
CUSTOM_SORTING_OPTIONS: ClassVar[List[str]] = [
|
197
|
-
*
|
197
|
+
*ProjectScopedFilter.CUSTOM_SORTING_OPTIONS,
|
198
198
|
*TaggableFilter.CUSTOM_SORTING_OPTIONS,
|
199
199
|
SORT_BY_LATEST_VERSION_KEY,
|
200
200
|
]
|
201
201
|
|
202
202
|
CLI_EXCLUDE_FIELDS: ClassVar[List[str]] = [
|
203
|
-
*
|
203
|
+
*ProjectScopedFilter.CLI_EXCLUDE_FIELDS,
|
204
204
|
*TaggableFilter.CLI_EXCLUDE_FIELDS,
|
205
205
|
]
|
206
206
|
|