Skip to content

Commit 4dc6ac9

Browse files
authored
Allow Modal secret name to be specified in config (#793)
1 parent e1886f6 commit 4dc6ac9

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

cubed/runtime/executors/modal.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,15 @@
8080
else:
8181
raise ValueError(f"Unrecognized cloud: {cloud}")
8282

83-
if cloud == "aws":
84-
secrets = [modal.Secret.from_name("my-aws-secret")]
85-
elif cloud == "gcp":
86-
secrets = [modal.Secret.from_name("my-googlecloud-secret")]
87-
else:
88-
raise ValueError(f"Unrecognized cloud: {cloud}")
83+
secret_name = executor_options.get("secret", None)
84+
if secret_name is None:
85+
if cloud == "aws":
86+
secret_name = "my-aws-secret"
87+
elif secret_name == "gcp":
88+
secrets_name = "my-googlecloud-secret"
89+
else:
90+
raise ValueError(f"Unrecognized cloud: {cloud}")
91+
secrets = [modal.Secret.from_name(secret_name)]
8992

9093

9194
def check_runtime_memory(spec):
@@ -155,7 +158,15 @@ def execute_dag(
155158
) -> None:
156159
merged_kwargs = {**self.kwargs, **kwargs}
157160
# remove executor options as they should already have been used in defining the remote functions
158-
for executor_option in ("memory", "retries", "timeout", "cloud", "region"):
161+
for executor_option in (
162+
"memory",
163+
"retries",
164+
"timeout",
165+
"cloud",
166+
"region",
167+
"requirements_file",
168+
"secret",
169+
):
159170
merged_kwargs.pop(executor_option, None)
160171
asyncio_run(
161172
self._async_execute_dag(

docs/configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Note that `batch_size` is not currently supported for Lithops.
212212
|------------------------------|---------|-------------------------------------------------------------------------------------|
213213
| `cloud` | `"aws"` | The cloud to run on. One of `"aws"` or `"gcp"`. |
214214
| `region` | N/A | The cloud region to run in. This must be set to match the region of your cloud store to avoid data transfer fees. See Modal's [Region selection](https://modal.com/docs/guide/region-selection) page for possible values. |
215+
| `secret` | `"my-aws-secret"` for AWS, `"my-googlecloud-secret"` for Google Cloud | The name of the [Modal secret](https://modal.com/docs/guide/secrets) to use. |
215216
| `retries` | 2 | The number of times to retry a task if it fails. |
216217
| `timeout` | 180 | Tasks that take longer than the timeout will be automatically killed and retried. |
217218
| `enable_output` | False | Print Modal output to stdout and stderr things for debugging. |

0 commit comments

Comments
 (0)