From 0597dfe464c037964fdbd09a35226c9bc7035173 Mon Sep 17 00:00:00 2001 From: Tianxin Dong Date: Tue, 5 Mar 2024 16:42:46 +0800 Subject: [PATCH] fix: add str in enum for deployment schema (#4549) * fix: add str in enum for deployment schema Signed-off-by: FogDong * ci: auto fixes from pre-commit.ci For more information, see https://pre-commit.ci * fix test Signed-off-by: FogDong --------- Signed-off-by: FogDong Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/bentoml/_internal/cloud/deployment.py | 2 +- src/bentoml/_internal/cloud/schemas/schemasv1.py | 9 +-------- src/bentoml/_internal/cloud/schemas/schemasv2.py | 5 +---- tests/unit/_internal/cloud/test_deployment.py | 2 +- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/bentoml/_internal/cloud/deployment.py b/src/bentoml/_internal/cloud/deployment.py index 7b2bc30e9cd..3e5e5c5bd4f 100644 --- a/src/bentoml/_internal/cloud/deployment.py +++ b/src/bentoml/_internal/cloud/deployment.py @@ -426,7 +426,7 @@ def get_status(self, refetch: bool = True) -> DeploymentState: if self._schema.updated_at is not None: updated_at = self._schema.updated_at.strftime("%Y-%m-%d %H:%M:%S") return DeploymentState( - status=self._schema.status.value, + status=self._schema.status, created_at=self._schema.created_at.strftime("%Y-%m-%d %H:%M:%S"), updated_at=updated_at, ) diff --git a/src/bentoml/_internal/cloud/schemas/schemasv1.py b/src/bentoml/_internal/cloud/schemas/schemasv1.py index e96a99e2f60..297a3ef7ba0 100644 --- a/src/bentoml/_internal/cloud/schemas/schemasv1.py +++ b/src/bentoml/_internal/cloud/schemas/schemasv1.py @@ -8,12 +8,9 @@ from bentoml._internal.cloud.schemas.modelschemas import BentoImageBuildStatus from bentoml._internal.cloud.schemas.modelschemas import BentoManifestSchema from bentoml._internal.cloud.schemas.modelschemas import BentoUploadStatus -from bentoml._internal.cloud.schemas.modelschemas import DeploymentMode from bentoml._internal.cloud.schemas.modelschemas import DeploymentRevisionStatus -from bentoml._internal.cloud.schemas.modelschemas import DeploymentStatus from bentoml._internal.cloud.schemas.modelschemas import DeploymentTargetCanaryRule from bentoml._internal.cloud.schemas.modelschemas import DeploymentTargetConfig -from bentoml._internal.cloud.schemas.modelschemas import DeploymentTargetType from bentoml._internal.cloud.schemas.modelschemas import LabelItemSchema from bentoml._internal.cloud.schemas.modelschemas import ModelImageBuildStatus from bentoml._internal.cloud.schemas.modelschemas import ModelManifestSchema @@ -239,7 +236,6 @@ class BentoListSchema(BaseListSchema): class CreateDeploymentTargetSchema: __omit_if_default__ = True __forbid_extra_keys__ = True - type: DeploymentTargetType # stable by default bento_repository: str bento: str config: DeploymentTargetConfig @@ -254,12 +250,11 @@ class DeploymentSchema(ResourceSchema): __forbid_extra_keys__ = True creator: UserSchema cluster: ClusterSchema - status: DeploymentStatus + status: str kube_namespace: str latest_revision: t.Optional[DeploymentRevisionSchema] = attr.field( default=None ) # Delete returns no latest revision - mode: t.Optional[DeploymentMode] = attr.field(default=None) @attr.define @@ -267,7 +262,6 @@ class DeploymentTargetSchema(ResourceSchema): __omit_if_default__ = True __forbid_extra_keys__ = True creator: UserSchema - type: DeploymentTargetType bento: BentoFullSchema config: DeploymentTargetConfig canary_rules: t.Optional[t.List[DeploymentTargetCanaryRule]] = attr.field( @@ -314,7 +308,6 @@ class UpdateDeploymentSchema: __omit_if_default__ = True __forbid_extra_keys__ = True targets: t.List[CreateDeploymentTargetSchema] - mode: t.Optional[DeploymentMode] = attr.field(default=None) labels: t.Optional[t.List[LabelItemSchema]] = attr.field(default=None) description: t.Optional[str] = attr.field(default=None) do_not_deploy: t.Optional[bool] = attr.field(default=None) diff --git a/src/bentoml/_internal/cloud/schemas/schemasv2.py b/src/bentoml/_internal/cloud/schemas/schemasv2.py index 28f4bac191d..8bb9174bc2b 100644 --- a/src/bentoml/_internal/cloud/schemas/schemasv2.py +++ b/src/bentoml/_internal/cloud/schemas/schemasv2.py @@ -4,10 +4,8 @@ import attr -from bentoml._internal.cloud.schemas.modelschemas import DeploymentMode from bentoml._internal.cloud.schemas.modelschemas import DeploymentRevisionStatus from bentoml._internal.cloud.schemas.modelschemas import DeploymentServiceConfig -from bentoml._internal.cloud.schemas.modelschemas import DeploymentStatus from bentoml._internal.cloud.schemas.schemasv1 import BaseListSchema from bentoml._internal.cloud.schemas.schemasv1 import BentoWithRepositorySchema from bentoml._internal.cloud.schemas.schemasv1 import ClusterSchema @@ -70,12 +68,11 @@ class CreateDeploymentSchema(UpdateDeploymentSchema): class DeploymentSchema(ResourceSchema): __omit_if_default__ = True __forbid_extra_keys__ = True - status: DeploymentStatus + status: str kube_namespace: str creator: UserSchema cluster: ClusterSchema latest_revision: t.Optional[DeploymentRevisionSchema] - mode: t.Optional[DeploymentMode] = attr.field(default=None) @attr.define diff --git a/tests/unit/_internal/cloud/test_deployment.py b/tests/unit/_internal/cloud/test_deployment.py index b33e39e00b4..bf24bd4ff40 100644 --- a/tests/unit/_internal/cloud/test_deployment.py +++ b/tests/unit/_internal/cloud/test_deployment.py @@ -11,6 +11,7 @@ from bentoml._internal.cloud.deployment import Deployment from bentoml._internal.cloud.deployment import DeploymentConfigParameters from bentoml._internal.cloud.schemas.modelschemas import DeploymentServiceConfig +from bentoml._internal.cloud.schemas.modelschemas import DeploymentStatus from bentoml._internal.cloud.schemas.modelschemas import DeploymentStrategy from bentoml._internal.cloud.schemas.modelschemas import DeploymentTargetHPAConf from bentoml._internal.cloud.schemas.modelschemas import EnvItemSchema @@ -22,7 +23,6 @@ from bentoml._internal.cloud.schemas.schemasv1 import ClusterListSchema from bentoml._internal.cloud.schemas.schemasv1 import ClusterSchema from bentoml._internal.cloud.schemas.schemasv1 import DeploymentRevisionStatus -from bentoml._internal.cloud.schemas.schemasv1 import DeploymentStatus from bentoml._internal.cloud.schemas.schemasv1 import ResourceType from bentoml._internal.cloud.schemas.schemasv1 import UserSchema from bentoml._internal.cloud.schemas.schemasv2 import (