This repository has been archived by the owner on Jun 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Sage-Bionetworks-Workflows/bgrande/ORCA-7…
…3/sagetasks-cli [ORCA-73] Add a sagetasks CLI for launching Tower workflows
- Loading branch information
Showing
11 changed files
with
780 additions
and
603 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from sagetasks.main import main_app | ||
|
||
main_app(prog_name="sagetasks") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from typer import Typer | ||
|
||
import sagetasks.nextflowtower.typer | ||
|
||
main_app = Typer(rich_markup_mode="markdown") | ||
main_app.add_typer(sagetasks.nextflowtower.typer.app, name="nextflowtower") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
from typing import List, Optional | ||
|
||
from sagetasks.nextflowtower.utils import TowerUtils | ||
|
||
# TODO: Re-enable this function once we've figured out how to best handle | ||
# `kwargs` in Typer. The following links might be useful for this: | ||
# https://typer.tiangolo.com/tutorial/commands/context/#configuring-the-context | ||
# https://peps.python.org/pep-0692/ | ||
# def bundle_client_args(auth_token, platform="sage", endpoint=None, **kwargs): | ||
# """Nextflow Tower - Bundle client arguments.""" | ||
# return TowerUtils.bundle_client_args(auth_token, platform, endpoint, **kwargs) | ||
|
||
|
||
def launch_workflow( | ||
compute_env_id: str, | ||
pipeline: str, | ||
workspace_id=None, | ||
revision: Optional[str] = None, | ||
params_yaml: Optional[str] = None, | ||
params_json: Optional[str] = None, | ||
nextflow_config: Optional[str] = None, | ||
run_name: Optional[str] = None, | ||
work_dir: Optional[str] = None, | ||
profiles: Optional[List[str]] = None, | ||
user_secrets: Optional[List[str]] = None, | ||
workspace_secrets: Optional[List[str]] = None, | ||
pre_run_script: Optional[str] = None, | ||
# TODO: Re-enable once we find a way to get Typer to support Mappings | ||
# init_data: Optional[Mapping] = None, | ||
client_args=None, | ||
): | ||
"""Launch a workflow run on Nextflow Tower. | ||
You can provide your Tower credentials with the following | ||
environment variables: | ||
- NXF_TOWER_TOKEN='<tower-access-token>' | ||
- NXF_TOWER_API_URL='<tower-api-url>' | ||
You can optionally enable debug mode (HTTP request logs) | ||
with the following environment variable: | ||
- NXF_TOWER_DEBUG=1 | ||
""" | ||
# More specific default values than None | ||
client_args = client_args or dict() | ||
profiles = profiles or () | ||
user_secrets = user_secrets or () | ||
workspace_secrets = workspace_secrets or () | ||
# Prepare and execute the workflow launch | ||
utils = TowerUtils(client_args) | ||
utils.open_workspace(workspace_id) | ||
workflow = utils.launch_workflow( | ||
compute_env_id, | ||
pipeline, | ||
revision=revision, | ||
params_yaml=params_yaml, | ||
params_json=params_json, | ||
nextflow_config=nextflow_config, | ||
run_name=run_name, | ||
work_dir=work_dir, | ||
profiles=profiles, | ||
user_secrets=user_secrets, | ||
workspace_secrets=workspace_secrets, | ||
pre_run_script=pre_run_script, | ||
) | ||
return workflow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import sagetasks.nextflowtower.general | ||
from sagetasks.utils import to_typer_commands | ||
|
||
# Auto-generate Typer commands from general functions | ||
app = to_typer_commands(sagetasks.nextflowtower.general) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import sagetasks.sevenbridges.general as general | ||
import sagetasks.sevenbridges.general | ||
from sagetasks.utils import to_prefect_tasks | ||
|
||
# Auto-generate Prefect tasks from general functions | ||
to_prefect_tasks(__name__, general) | ||
to_prefect_tasks(__name__, sagetasks.sevenbridges.general) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import sagetasks.synapse.general as general | ||
import sagetasks.synapse.general | ||
from sagetasks.utils import to_prefect_tasks | ||
|
||
# Auto-generate Prefect tasks from general functions | ||
to_prefect_tasks(__name__, general) | ||
to_prefect_tasks(__name__, sagetasks.synapse.general) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters