Skip to content

Commit

Permalink
Fix Modal deprecations (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwhite authored Mar 8, 2024
1 parent 2023fbd commit e3e91e6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 4 additions & 3 deletions cubed/runtime/executors/modal.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def check_runtime_memory(spec):

@stub.function(
image=aws_image,
secret=modal.Secret.from_name("my-aws-secret"),
secrets=[modal.Secret.from_name("my-aws-secret")],
memory=RUNTIME_MEMORY_MIB,
retries=2,
cloud="aws",
Expand All @@ -85,13 +85,14 @@ def run_remotely(input, func=None, config=None, name=None, compute_id=None):
# For GCP we need to use a class so we can set up credentials by hooking into the container lifecycle
@stub.cls(
image=gcp_image,
secret=modal.Secret.from_name("my-googlecloud-secret"),
secrets=[modal.Secret.from_name("my-googlecloud-secret")],
memory=RUNTIME_MEMORY_MIB,
retries=2,
cloud="gcp",
)
class Container:
def __enter__(self):
@modal.enter()
def set_up_credentials(self):
json = os.environ["SERVICE_ACCOUNT_JSON"]
path = os.path.abspath("application_credentials.json")
with open(path, "w") as f:
Expand Down
14 changes: 11 additions & 3 deletions cubed/tests/runtime/test_modal_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,27 @@


@stub.function(
image=image, secret=modal.Secret.from_name("my-aws-secret"), retries=2, timeout=10
image=image,
secrets=[modal.Secret.from_name("my-aws-secret")],
retries=2,
timeout=10,
)
def deterministic_failure_modal(i, path=None, timing_map=None, *, name=None):
return deterministic_failure(path, timing_map, i, name=name)


@stub.function(image=image, secret=modal.Secret.from_name("my-aws-secret"), timeout=10)
@stub.function(
image=image, secrets=[modal.Secret.from_name("my-aws-secret")], timeout=10
)
def deterministic_failure_modal_no_retries(i, path=None, timing_map=None, *, name=None):
return deterministic_failure(path, timing_map, i, name=name)


@stub.function(
image=image, secret=modal.Secret.from_name("my-aws-secret"), retries=2, timeout=300
image=image,
secrets=[modal.Secret.from_name("my-aws-secret")],
retries=2,
timeout=300,
)
def deterministic_failure_modal_long_timeout(
i, path=None, timing_map=None, *, name=None
Expand Down

0 comments on commit e3e91e6

Please sign in to comment.