Create repository template
authorPeter Amstutz <peter.amstutz@curii.com>
Thu, 14 Jan 2021 22:05:08 +0000 (17:05 -0500)
committerPeter Amstutz <peter.amstutz@curii.com>
Thu, 14 Jan 2021 22:05:08 +0000 (17:05 -0500)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz@curii.com>

.gitignore [new file with mode: 0644]
.vscode/tasks.json [new file with mode: 0644]
README.md [new file with mode: 0644]
scripts/configure-arv [new file with mode: 0755]
scripts/run-workflow [new file with mode: 0755]
scripts/set-project [new file with mode: 0755]
scripts/setup-env [new file with mode: 0644]
scripts/upload-workflow [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..bc2c06b
--- /dev/null
@@ -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 (file)
index 0000000..cde038f
--- /dev/null
@@ -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 (file)
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 (executable)
index 0000000..6bd865c
--- /dev/null
@@ -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 (executable)
index 0000000..3227606
--- /dev/null
@@ -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 (executable)
index 0000000..7e5f4ca
--- /dev/null
@@ -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 (file)
index 0000000..6dfc8f9
--- /dev/null
@@ -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 (executable)
index 0000000..fc884f1
--- /dev/null
@@ -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