From 2f94443157b140a49f87a103cdb1d3880302dcfb Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Thu, 14 Jan 2021 17:05:08 -0500 Subject: [PATCH] Create repository template Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- .gitignore | 2 ++ .vscode/tasks.json | 47 +++++++++++++++++++++++++++++++++++++++++ README.md | 2 ++ scripts/configure-arv | 4 ++++ scripts/run-workflow | 9 ++++++++ scripts/set-project | 2 ++ scripts/setup-env | 7 ++++++ scripts/upload-workflow | 13 ++++++++++++ 8 files changed, 86 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/tasks.json create mode 100644 README.md create mode 100755 scripts/configure-arv create mode 100755 scripts/run-workflow create mode 100755 scripts/set-project create mode 100644 scripts/setup-env create mode 100755 scripts/upload-workflow diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bc2c06b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +API_HOST +API_TOKEN \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..cde038f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,47 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Run CWL workflow on Arvados", + "type": "shell", + "command": "scripts/run-workflow ${file}", + "problemMatcher": [] + }, + { + "label": "Register or update CWL workflow on Arvados Workbench", + "type": "shell", + "command": "scripts/upload-workflow ${file}", + "problemMatcher": [] + }, + { + "label": "Configure Arvados", + "type": "shell", + "command": "scripts/configure-arv ${input:api_host} ${input:api_token}", + "problemMatcher": [] + }, + { + "label": "Set project UUID", + "type": "shell", + "command": "scripts/set-project ${fileDirname} ${input:project_uuid}", + "problemMatcher": [] + } + ], + "inputs": [ + { + "id": "api_host", + "type": "promptString", + "description": "Value for ARVADOS_API_HOST" + }, + { + "id": "api_token", + "type": "promptString", + "description": "Value for ARVADOS_API_TOKEN", + "password": true + }, + { + "id": "project_uuid", + "type": "promptString", + "description": "The project UUID" + } + ] +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..1955a2b --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +This is a template repository that contains helpful scripts and vscode +tasks for development CWL workflows with Arvados. diff --git a/scripts/configure-arv b/scripts/configure-arv new file mode 100755 index 0000000..6bd865c --- /dev/null +++ b/scripts/configure-arv @@ -0,0 +1,4 @@ +#!/bin/sh +echo $1 > API_HOST +echo $2 > API_TOKEN +chmod og-rw API_HOST API_TOKEN \ No newline at end of file diff --git a/scripts/run-workflow b/scripts/run-workflow new file mode 100755 index 0000000..3227606 --- /dev/null +++ b/scripts/run-workflow @@ -0,0 +1,9 @@ +#!/bin/sh +set -e +FILE=$1 +DIR=$(dirname $FILE) +. $(dirname $0)/setup-env +if test -s $DIR/input.yaml ; then + INPUT=$DIR/input.yaml +fi +arvados-cwl-runner $PROJECT_UUID $FILE $INPUT diff --git a/scripts/set-project b/scripts/set-project new file mode 100755 index 0000000..7e5f4ca --- /dev/null +++ b/scripts/set-project @@ -0,0 +1,2 @@ +#!/bin/sh +echo $2 > $1/PROJECT_UUID \ No newline at end of file diff --git a/scripts/setup-env b/scripts/setup-env new file mode 100644 index 0000000..6dfc8f9 --- /dev/null +++ b/scripts/setup-env @@ -0,0 +1,7 @@ +test -s API_HOST || (echo "missing API_HOST, run the 'Configure Arvados' task"; exit 1) +test -s API_TOKEN || (echo "missing API_TOKEN, run the 'Configure Arvados' task"; exit 1) +export ARVADOS_API_HOST=$(cat API_HOST) +export ARVADOS_API_TOKEN=$(cat API_TOKEN) +if test -s $DIR/PROJECT_UUID ; then + PROJECT_UUID="--project-uuid $(cat $DIR/PROJECT_UUID)" +fi \ No newline at end of file diff --git a/scripts/upload-workflow b/scripts/upload-workflow new file mode 100755 index 0000000..fc884f1 --- /dev/null +++ b/scripts/upload-workflow @@ -0,0 +1,13 @@ +#!/bin/sh +set -e +FILE=$1 +DIR=$(dirname $FILE) +. $(dirname $0)/setup-env +if test -s $DIR/defaults.yaml ; then + DEFAULTS=$DIR/defaults.yaml +fi +if test -s $DIR/WORKFLOW_UUID ; then + arvados-cwl-runner --update-workflow $(cat $DIR/WORKFLOW_UUID) $PROJECT_UUID $FILE $DEFAULTS +else + arvados-cwl-runner --create-workflow $PROJECT_UUID $FILE $DEFAULTS > $DIR/WORKFLOW_UUID +fi -- 2.30.2