Skip to content

Commit

Permalink
upgrading to pydantic v2
Browse files Browse the repository at this point in the history
  • Loading branch information
bcdurak committed May 7, 2024
1 parent e557097 commit 05c1ede
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ exclude = [
# pydantic = {version = "2.0.2"}
# compatible with Core ZenML
python = ">=3.8,<3.12"
pydantic = { version = "<1.11,>=1.9.0" }
pydantic = { version = "~2.7" }
pyyaml = { version = ">=6.0.1" }
click = { version = "^8.0.1,<8.1.4" }
python-terraform = { version = "^0.10.1" }
Expand Down
5 changes: 3 additions & 2 deletions src/mlstacks/models/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from typing import Dict, Optional

from pydantic import BaseModel, validator
from pydantic import field_validator, BaseModel

from mlstacks.constants import INVALID_NAME_ERROR_MESSAGE
from mlstacks.enums import (
Expand Down Expand Up @@ -57,7 +57,8 @@ class Component(BaseModel):
provider: ProviderEnum
metadata: Optional[ComponentMetadata] = None

@validator("name")
@field_validator("name")
@classmethod
def validate_name(cls, name: str) -> str: # noqa: N805
"""Validate the name.
Expand Down
7 changes: 4 additions & 3 deletions src/mlstacks/models/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"""Stack model."""
from typing import Dict, List, Optional

from pydantic import BaseModel, validator
from pydantic import field_validator, BaseModel

from mlstacks.constants import INVALID_NAME_ERROR_MESSAGE
from mlstacks.enums import (
Expand Down Expand Up @@ -42,14 +42,15 @@ class Stack(BaseModel):
spec_type: str = "stack"
name: str
provider: ProviderEnum
default_region: Optional[str]
default_region: Optional[str] = None
default_tags: Optional[Dict[str, str]] = None
deployment_method: Optional[
DeploymentMethodEnum
] = DeploymentMethodEnum.KUBERNETES
components: List[Component] = []

@validator("name")
@field_validator("name")
@classmethod
def validate_name(cls, name: str) -> str: # noqa: N805
"""Validate the name.
Expand Down

0 comments on commit 05c1ede

Please sign in to comment.