diff --git a/pyproject.toml b/pyproject.toml index 0576d1f1..3e8d321b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" } diff --git a/src/mlstacks/models/component.py b/src/mlstacks/models/component.py index 31a1db4a..df64c100 100644 --- a/src/mlstacks/models/component.py +++ b/src/mlstacks/models/component.py @@ -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 ( @@ -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. diff --git a/src/mlstacks/models/stack.py b/src/mlstacks/models/stack.py index 1afebce5..8334b671 100644 --- a/src/mlstacks/models/stack.py +++ b/src/mlstacks/models/stack.py @@ -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 ( @@ -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.