Skip to content

Commit

Permalink
Support More Modern GCS Storage Block (#36)
Browse files Browse the repository at this point in the history
* Support More Modern GCS Storage Block

* add allow_resuse kwarg, hopefully it exists on all pydantic versons

* patch

* support python 312 with pydantic validator
  • Loading branch information
jhamet93 authored Jul 18, 2024
1 parent 7d90d07 commit f8c849a
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 52 deletions.
9 changes: 8 additions & 1 deletion block_cascade/executors/vertex/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,14 @@ def create_job(self) -> VertexJob:
module_name = deployment.entrypoint

module_name = module_name.lstrip("/")
bucket = storage.data["bucket_path"]
#
# This is hardcoded to only support
# prefect.filesystems.GCS or prefect_gcp.cloud_storage.GCSBucket
# storage blocks.
#
# TODO: This should be generalized to accept any storage block.
#
bucket = storage.data.get("bucket_path", "bucket")
deployment_path = deployment.path.rstrip("/")

package_path = f"{bucket}/{deployment_path}/{module_name}"
Expand Down
11 changes: 9 additions & 2 deletions 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")
@pydantic_validator("image")
def image_setter(cls, v, values): # noqa: N805
image = v
# No image specified
Expand Down Expand Up @@ -144,7 +151,7 @@ class GcpResource:
"""

chief: GcpMachineConfig = field(default_factory=GcpMachineConfig)
workers: GcpMachineConfig = None
workers: Optional[GcpMachineConfig] = None
environment: Optional[GcpEnvironmentConfig] = None
distributed_job: Optional[DistributedJobBase] = None
persistent_resource_id: Optional[str] = None
96 changes: 48 additions & 48 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "block-cascade"
packages = [
{include = "block_cascade"}
]
version = "2.5.5"
version = "2.5.6"
description = "Library for model training in multi-cloud environment."
readme = "README.md"
authors = ["Block"]
Expand Down

0 comments on commit f8c849a

Please sign in to comment.