Skip to content

Commit

Permalink
fix: add str in enum for deployment schema (#4549)
Browse files Browse the repository at this point in the history
* fix: add str in enum for deployment schema

Signed-off-by: FogDong <fog@bentoml.com>

* ci: auto fixes from pre-commit.ci

For more information, see https://pre-commit.ci

* fix test

Signed-off-by: FogDong <fog@bentoml.com>

---------

Signed-off-by: FogDong <fog@bentoml.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
FogDong and pre-commit-ci[bot] committed Mar 5, 2024
1 parent 5b3e752 commit 0597dfe
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/bentoml/_internal/cloud/deployment.py
Expand Up @@ -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,
)
Expand Down
9 changes: 1 addition & 8 deletions src/bentoml/_internal/cloud/schemas/schemasv1.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -254,20 +250,18 @@ 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
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(
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions src/bentoml/_internal/cloud/schemas/schemasv2.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/_internal/cloud/test_deployment.py
Expand Up @@ -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
Expand All @@ -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 (
Expand Down

0 comments on commit 0597dfe

Please sign in to comment.