Skip to content

Commit

Permalink
Added Nextflow Tower CLI wait (#1)
Browse files Browse the repository at this point in the history
* added default wait
* removed weird spaces
* added run name as a parameter
* Remove colons from run name
* Apply suggestions from code review
* "wait" default should be false to ensure that longer-running runs don't hold up the CI/CD

---------

Co-authored-by: Kelsey Florek <kelseyflorek22@gmail.com>
Co-authored-by: Rob Syme <rob.syme@gmail.com>
Co-authored-by: Harshil Patel <drpatelh@users.noreply.github.com>
  • Loading branch information
4 people authored Mar 29, 2023
1 parent 716b834 commit dc41ddc
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
compute_env: ${{ secrets.TOWER_COMPUTE_ENV }}
pipeline: YOUR_USERNAME/REPO
revision: v1.2.1
run_name: ${{ github.job }}_${{ github.run_attempt }}
workdir: ${{ secrets.AWS_S3_BUCKET }}/work/${{ github.sha }}
# Set any custom pipeline params here - JSON object as a string
parameters: |
Expand Down Expand Up @@ -160,6 +161,12 @@ These should be supplied as a valid JSON object, quoted as a string in your GitH

Pipeline config profiles to use. Should be comma separated without spaces.

### `run_name`

**[Optional]** Nextflow Tower run name

Provide a name for the run in Nextflow Tower.

### `nextflow_config`

**[Optional]** Nextflow config options.
Expand Down Expand Up @@ -194,6 +201,22 @@ jobs:
# Truncated..
```

### `wait`

**[Optional]** Set GitHub action to wait for pipeline completion

The default setting is for GitHub actions to wait until a pipeline runs to completion. If you want GitHub actions to launch the workflow and then finish you can set the wait to false:

```yaml
jobs:
run-tower:
steps:
- uses: nf-core/tower-action@v2
with:
wait: false
# Truncated..
```

## Outputs

The action prints normal stdout info-level log messages to the actions console. However, it saves a verbose log file to `tower_action_*.log` (the `*` is a timestamp). We recommend using [`actions/upload-artifact`](https://github.com/actions/upload-artifact) in your GitHub Actions workflow as shown in the examples above, this will then expose this file as a download through the workflow summary page.
Expand Down
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ inputs:
profiles:
description: Nextflow config profiles
required: false
run_name:
description: Nextflow Tower Run Name
required: false
nextflow_config:
description: Nextflow config options
required: false
pre_run_script:
description: Pre-run script before launch
required: false
wait:
description: Set GitHub action to wait for pipeline completion
default: false
required: false

runs:
using: 'docker'
Expand All @@ -58,5 +65,7 @@ runs:
WORKDIR: ${{ inputs.workdir }}
PARAMETERS: ${{ toJson(fromJson(inputs.parameters)) }}
CONFIG_PROFILES: ${{ inputs.profiles }}
RUN_NAME: ${{ inputs.run_name }}
NEXTFLOW_CONFIG: ${{ inputs.nextflow_config }}
PRE_RUN_SCRIPT: ${{ inputs.pre_run_script }}
WAIT: ${{ inputs.wait }}
5 changes: 5 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ echo -e "$PRE_RUN_SCRIPT" > pre_run.sh
# Print the nextflow config to a file
echo -e "$NEXTFLOW_CONFIG" > nextflow.config

# If wait is set to false then unset wait to disable waiting
if [ "$WAIT" = false ]; then unset WAIT; fi

# Launch the pipeline
tw -v \
launch \
Expand All @@ -29,8 +32,10 @@ tw -v \
${TOWER_COMPUTE_ENV:+"--compute-env=$TOWER_COMPUTE_ENV"} \
${REVISION:+"--revision=$REVISION"} \
${CONFIG_PROFILES:+"--profile=$CONFIG_PROFILES"} \
${RUN_NAME:+"--name=${RUN_NAME/:/_}"} \
${PRE_RUN_SCRIPT:+"--pre-run=pre_run.sh"} \
${NEXTFLOW_CONFIG:+"--config=nextflow.config"} \
${WAIT:+"--wait=$WAIT"} \
2>> $LOG_FN | tee -a $LOG_FN

# Strip secrets from the log file
Expand Down

0 comments on commit dc41ddc

Please sign in to comment.