Skip to content

Commit

Permalink
Deploy Nextflow and WDL workflows to Seven Bridges platforms
Browse files Browse the repository at this point in the history
Deploy Nextflow and WDL workflows to Seven Bridges platforms
  • Loading branch information
bogdang989 authored Mar 10, 2022
1 parent 6abf31c commit c322e5e
Show file tree
Hide file tree
Showing 11 changed files with 867 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
pip install -r test-requirements.txt
pip install pipx
pipx install cwltool>=3.0
pip uninstall -y pytest-workflow
pipx ensurepath
# Need a new shell so that ensurepath takes
- name: Test with pytest
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ruamel.yaml >= 0.16
sevenbridges-python >= 2.0
nf-core==2.1
cwlformat
packaging
110 changes: 110 additions & 0 deletions sbpack/noncwl/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# sbpack_wdl
Developed to support WDL workflows on Seven Bridges Platform.
This command enables users to create and upload WDL workflows
to the Platform.

### Usage
```
$ sbpack_wdl -h
usage: sbpack_wdl [-h] [--profile PROFILE] --appid APPID --entrypoint ENTRYPOINT --workflow-path WORKFLOW_PATH [--sb-package-id SB_PACKAGE_ID] [--womtool-input WOMTOOL_INPUT]
[--sb-inputs SB_INPUTS] [--sb-outputs SB_OUTPUTS] [--sb-doc SB_DOC] [--dump-sb-app] [--no-package] [--womtool-path WOMTOOL_PATH] [--json] [--sb-schema SB_SCHEMA]
optional arguments:
-h, --help show this help message and exit
--profile PROFILE SB platform profile as set in the SB API credentials file.
--appid APPID Takes the form {user or division}/{project}/{app_id}.
--entrypoint ENTRYPOINT
Relative path to the workflow from the main workflow directory
--workflow-path WORKFLOW_PATH
Path to the main workflow directory
--sb-package-id SB_PACKAGE_ID
Id of an already uploaded package
--womtool-input WOMTOOL_INPUT
Path to inputs .JSON generated by womtool
--sb-inputs SB_INPUTS
Path to pre built sb app inputs schema
--sb-outputs SB_OUTPUTS
Path to pre build sb app outputs schema
--sb-doc SB_DOC Path to a doc file for sb app. If not provided, README.md will be used if available
--dump-sb-app Dump created sb app to file if true and exit
--no-package Only provide a sb app schema and a git URL for entrypoint
--womtool-path WOMTOOL_PATH
Path to womtool-X.jar
--json Dump sb app schema in JSON format (YAML by default)
--sb-schema SB_SCHEMA
Do not create new schema, use this schema file. It is sb_wdl_schema in JSON or YAML format.
```

### Example

```
$ sbpack_wdl --profile default --workflow-path /path/to/workflow_dir
--appid user/project/app --entrypoint workflow.wdl
--womtool-path /path/to/womtool-X.jar
```

# sbpack_nf
Developed to support Nextflow workflows on Seven Bridges Platform.
This command enables users to create and upload Nextflow workflows
to the Platform.

### Usage
```
$ sbpack_nf -h
usage: sbpack_nf [-h] [--profile PROFILE] --appid APPID --entrypoint ENTRYPOINT --workflow-path WORKFLOW_PATH [--sb-package-id SB_PACKAGE_ID] [--sb-inputs SB_INPUTS] [--sb-outputs SB_OUTPUTS]
[--sb-doc SB_DOC] [--dump-sb-app] [--no-package] [--json] [--sb-schema SB_SCHEMA]
optional arguments:
-h, --help show this help message and exit
--profile PROFILE SB platform profile as set in the SB API credentials file.
--appid APPID Takes the form {user or division}/{project}/{app_id}.
--entrypoint ENTRYPOINT
Relative path to the workflow from the main workflow directory
--workflow-path WORKFLOW_PATH
Path to the main workflow directory
--sb-package-id SB_PACKAGE_ID
Id of an already uploaded package
--sb-inputs SB_INPUTS
Path to pre built sb app inputs schema
--sb-outputs SB_OUTPUTS
Path to pre build sb app outputs schema
--sb-doc SB_DOC Path to a doc file for sb app. If not provided, README.md will be used if available
--dump-sb-app Dump created sb app to file if true and exit
--no-package Only provide a sb app schema and a git URL for entrypoint
--json Dump sb app schema in JSON format (YAML by default)
--sb-schema SB_SCHEMA
Do not create new schema, use this schema file. It is sb_nextflow_schema in JSON or YAML format.
```
### Example

```
$ sbpack_nf --profile default --workflow-path /path/to/workflow_dir
--appid user/project/app --entrypoint main.nf
```

# sbcopy

Developed to enable deep copying of Nextflow and WDL apps on the SB platform between projects.
Note: The link between the original, and the new app will not be available.

### Usage

```
sbcopy -h
usage: sbcopy [-h] [--profile PROFILE] --appid APPID --projectid PROJECTID
optional arguments:
-h, --help show this help message and exit
--profile PROFILE SB platform profile as set in the SB API credentials file.
--appid APPID What to copy? Takes the form {user or division}/{project}/{app_id} or {user or division}/{project}/{app_id}/{revision_no}.
--projectid PROJECTID
Where to copy? Takes the form {user or division}/{project}
```

### Example

```
sbcopy --appid division-name/project-name/app-name --projectid division-name/destination-project-name
```
Empty file added sbpack/noncwl/__init__.py
Empty file.
45 changes: 45 additions & 0 deletions sbpack/noncwl/copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import argparse
import logging
import sbpack.lib as lib
from sevenbridges.errors import NotFound
from sbpack.noncwl.utils import install_or_upgrade_app

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


def main():
# CLI parameters
parser = argparse.ArgumentParser()
parser.add_argument("--profile", default="default",
help="SB platform profile as set in the SB API "
"credentials file.")
parser.add_argument("--appid", required=True,
help="What to copy? Takes the form {user or division}/{project}/{app_id} "
"or {user or division}/{project}/{app_id}/{revision_no}.")
parser.add_argument("--projectid", required=True,
help="Where to copy? Takes the form "
"{user or division}/{project}")
args = parser.parse_args()

# Preprocess CLI parameter values

# Init api
api = lib.get_profile(args.profile)

# Source and destination apps
source_app = api.apps.get(args.appid)
sb_app_raw = source_app.raw
destination_app_id = args.projectid + '/' + args.appid.split('/')[2]

# Copy the code package
source_package = source_app.raw.get('app_content', {}).get('code_package', '')
if source_package:
new_file = api.files.get(api.files.get(source_package).copy(project=args.projectid))
sb_app_raw['app_content']['code_package'] = new_file.id

install_or_upgrade_app(api,destination_app_id, sb_app_raw)


if __name__ == "__main__":
main()
Loading

0 comments on commit c322e5e

Please sign in to comment.