Skip to content

Commit

Permalink
support python 312 with pydantic validator
Browse files Browse the repository at this point in the history
  • Loading branch information
jhamet93 committed Jul 18, 2024
1 parent 70a30cb commit 9a8b8c5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion block_cascade/executors/vertex/resource.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from dataclasses import field
import sys
from typing import Iterable, Optional, Type, TypeVar

from pydantic import validator
Expand All @@ -11,6 +12,12 @@
T = TypeVar("T", bound="GcpEnvironmentConfig")


if sys.version_info.minor == 12:
pydantic_validator = lambda *args: validator(*args, allow_reuse=True)
else:
pydantic_validator = validator


@dataclass(frozen=True)
class GcpAcceleratorConfig:
"""
Expand Down Expand Up @@ -101,7 +108,7 @@ class GcpEnvironmentConfig:
network: Optional[str] = None
image: Optional[str] = None

@validator("image", allow_resuse=True)
@pydantic_validator("image")
def image_setter(cls, v, values): # noqa: N805
image = v
# No image specified
Expand Down

0 comments on commit 9a8b8c5

Please sign in to comment.