Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workspace field to credentials, used if not set on pool #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions prefect_coiled/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@

class CoiledCredentials(Block):
api_token: Optional[SecretStr] = Field(default=None, description="Coiled API token")
workspace: Optional[str] = Field(default=None, description="Coiled Workspace")
17 changes: 12 additions & 5 deletions prefect_coiled/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,24 @@ async def run(
else {}
)

workspace = configuration.workspace

# submit the job to run on Coiled
creds_config = {}
if configuration.credentials and configuration.credentials.api_token:
creds_config = {
"coiled.token": configuration.credentials.api_token.get_secret_value()
}
if configuration.credentials:
if configuration.credentials.api_token:
creds_config["coiled.token"] = configuration.credentials.api_token.get_secret_value()

# Workspace for the pool takes precedence (if set), then workspace for credentials.
# If neither is set, then Coiled will use the default workspace set for user in the Coiled web app.
if configuration.credentials.workspace and not configuration.workspace:
workspace = configuration.credentials.workspace
creds_config["coiled.workspace"] = workspace

with dask.config.set(creds_config):
run_info = run(
command=configuration.command,
workspace=configuration.workspace,
workspace=workspace,
container=configuration.image if not configuration.software else None,
software=configuration.software,
secret_env=configuration.env,
Expand Down