Skip to content

Commit

Permalink
Creates custom Github Aciton for cloudos job run (#1)
Browse files Browse the repository at this point in the history
* Adds README.md

* Adds recommendation for github secrets
  • Loading branch information
cgpu authored Jul 24, 2022
1 parent e0cc258 commit 8122bcf
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 12 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/cloudos-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ on: [push]
jobs:
custom_test:
runs-on: ubuntu-latest
name: Local test with act
name: Dry run test for cloudos job run
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Echo cloudos command
- name: Print cloudos job run command (dry_run set to true)
uses: ./ # Uses an action in the root directory
id: cloudos_job_run
with:
Expand All @@ -17,4 +17,5 @@ jobs:
project_name: 'cloudos-cli-tests'
workflow_name: 'cgpu/rnatoy'
nextflow_profile: 'test'
cloudos_cli_flags: '--resumable --spot'
cloudos_cli_flags: '--resumable --spot'
dry_run: 'true'
122 changes: 121 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,121 @@
# action-custom-action
# GitHub Action: Run Lifebit CloudOS jobs with cloudos-cli

This github action uses the [`cloudos-cli`](https://github.com/lifebit-ai/cloudos-cli), the official Lifebit CloudOS API client, to launch jobs programmatically using the `cloudos job run` command.

## Example usage

```yaml
on: [push]

jobs:
cloudos_job_run:
runs-on: ubuntu-latest
name: Submit CloudOS job programmatically
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Echo cloudos command
uses: lifebit-ai/[email protected]
id: cloudos_job_run
with:
apikey: ${{ secrets.CLOUDOS_APIKEY }}
cloudos_url: 'https://cloudos.lifebit.ai'
workspace_id: ${{ secrets.CLOUDOS_WORKSPACE_ID }}
project_name: 'cloudos-cli-tests'
workflow_name: 'cgpu/rnatoy'
nextflow_profile: 'test'
cloudos_cli_flags: '--resumable --spot'
```
## Inputs
### `dry_run`

If set to `'true'` the action only prints the `cloudos job run` command instead of executing it. Secrets are stripped before printing. This mode can be used for testing.

### `apikey`

The Lifebit CloudOS user personal API token.

> :warning: It is highly recommended to use Github Actions Secrets to define this secret variable. Follow the [official Github Actions documentation for reporsitory secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) to set this up for your reporsitory.


### `cloudos_url`

The Lifebit CloudOS application hostname without a trailing backslash eg https://cloudos.lifebit.ai

### `workspace_id`

The Lifebit CloudOS workspace id. It Can be found under Settings in the web application. It is recommended to use Github Action repository secrets to set up this variable.

### `project_name`

The Lifebit CloudOS workspace id. It can be created and selected from the Lifebit CloudOS web application user interface under Projects.

### `workflow_name`

The Lifebit CloudOS workflow name. It can be created and selected from the Lifebit CloudOS web application user interface under Pipelines & Tools.


### `job_config`

A local file with suffix .config, that includes only a params scope enclosed in curly brackets. The file should contain parameter key:value pairs. For example see: [cloudos/examples/rnatoy.config'](https://github.com/lifebit-ai/cloudos-cli/blob/dev/cloudos/examples/rnatoy.config')


### `nextflow_profile`

One or many comma separated strings, indicating the nextflow profile/s to use with your job. Only applicable to Nextflow workflows.'

### `git_commit`

The exact whole 40 character commit hash to run for the selected pipeline. If not specified it defaults to the last commit of the default branch.

### `git_tag`

The version tag of the chosen workflow repository. It must exist in the repository


### `job_name`

A name to assign to the job run.

### `instance_type`

The type of AWS EC2 instance to use as master node for the job eg c5.xlarge

### `instance_disk`

Disk storage in GB to be used for the master node vm.


### `storage_mode`

The storage mode to use. Available options: [regular,lustre]. Regular is EBS.

### `lustre_size`

The lustre storage to be used when --storage-mode=lustre, in GB. It should be 1200 or a multiple of it.'

### `wait_time`

Max time to wait (in seconds) to job completion

### `wdl_mainfile`

For WDL workflows, which mainFile (.wdl) is configured to use (string). This is defined when the WDL repository is imported under Pipelines & Tools using the Lifebit CloudOS web application user interface.

### `wdl_importsfile`

For WDL workflows, which importsFile (.zip) is configured to use (string). This is defined when the WDL repository is imported under Pipelines & Tools using the Lifebit CloudOS web application user interface.

### `cromwell_token`

Specific Cromwell server authentication token. Only required for WDL jobs.

### `repository_platform`

Name of the repository platform of the workflow. Default=github.
### `cloudos_cli_flag`

Additional cloudos-cli flags, space separated eg `'--spot --resumable'`. Available options: `[--spot, --batch, --resumable, --verbose, --wait-completion]`
13 changes: 6 additions & 7 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ inputs:
nextflow_profile:
description: 'One or many comma separated strings, indicating the nextflow profile/s to use with your job. Only applicable to Nextflow workflows.'
required: false
default: 'standard'
git_commit:
description: 'The exact whole 40 character commit hash to run for the selected pipeline. If not specified it defaults to the last commit of the default branch.'
required: false
Expand All @@ -40,23 +39,18 @@ inputs:
instance_type:
description: 'The type of AWS EC2 instance to use as master node for the job eg c5.xlarge'
required: false
default: 'c5.xlarge'
instance_disk:
description: 'Disk storage in GB to be used for the master node vm.'
required: false
default: '500'
storage_mode:
description: 'The storage mode to use. Available options: [regular,lustre]. Regular is EBS.'
required: false
default: 'regular'
lustre_size:
description: 'The lustre storage to be used when --storage-mode=lustre, in GB. It should be 1200 or a multiple of it.'
required: false
default: '1200'
wait_time:
description: 'Max time to wait (in seconds) to job completion'
required: false
default: '3600'
wdl_mainfile:
description: 'For WDL workflows, which mainFile (.wdl) is configured to use (string). This is defined when the WDL repository is imported under Pipelines & Tools using the Lifebit CloudOS web application user interface.'
required: false
Expand All @@ -73,6 +67,10 @@ inputs:
description: 'Additional cloudos-cli flags, space separated eg "--spot --resumable". Available options: [--spot, --batch, --resumable, --verbose, --wait-completion]'
required: false
default: ''
dry_run:
description: 'Mode of execution for the action, by default the API call will be sent. Set to dry_run: true if you only want to print the command (strips secrets before printing).'
required: false
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
Expand All @@ -96,4 +94,5 @@ runs:
- ${{ inputs.wdl_importsfile }}
- ${{ inputs.cromwell_token }}
- ${{ inputs.repository_platform }}
- ${{ inputs.cloudos_cli_flags}}
- ${{ inputs.cloudos_cli_flags}}
- ${{ inputs.dry_run}}
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ if [[ ${INPUT_CROMWELL_TOKEN} ]]; then CLOUDOS_RUN_CMD+=" --cromwell-token
if [[ ${INPUT_REPOSITORY_PLATFORM} ]]; then CLOUDOS_RUN_CMD+=" --repository-platform ${INPUT_REPOSITORY_PLATFORM}" ; fi
if [[ ${INPUT_CLOUDOS_CLI_FLAGS} ]]; then CLOUDOS_RUN_CMD+=" ${INPUT_CLOUDOS_CLI_FLAGS}" ; fi

$CLOUDOS_RUN_CMD
if [[ ${INPUT_DRY_RUN} != 'true' ]]; then $CLOUDOS_RUN_CMD ; fi
printf '%s\n' "${CLOUDOS_RUN_CMD//$INPUT_APIKEY/}"

0 comments on commit 8122bcf

Please sign in to comment.