Created
July 11, 2019 16:13
-
-
Save jtratner/e8981225721995a21031031daf388203 to your computer and use it in GitHub Desktop.
Follow DNAnexus workflow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o pipefail | |
ANALYSIS_ID=$1 | |
dx describe $ANALYSIS_ID | |
project=$(dx describe $ANALYSIS_ID --json | jq -r .project) | |
function get_jobs_for_state { | |
dx find jobs --root $ANALYSIS_ID --state $1 --brief --project ${project} --all-jobs | |
} | |
until ! (cat <(get_jobs_for_state runnable) <(get_jobs_for_state running) <(get_jobs_for_state waiting_on_input) <(get_jobs_for_state idle) | grep job | head -n 1); do | |
FIRST_JOB=$(get_jobs_for_state running | head -n 1 | grep job) | |
if [ $? -eq 0 ]; then | |
echo "$(date) Following $FIRST_JOB" | |
dx describe $FIRST_JOB | |
dx watch $FIRST_JOB | |
else | |
echo "$(date) No jobs currently running..." | |
sleep 10 | |
fi | |
done | |
function describe_state_and_failures() { | |
set +x | |
WFLOW_ID=$1 | |
WORKFLOW_DESCRIBE=$(dx describe $WFLOW_ID --json) | |
STATE=$(echo $WORKFLOW_DESCRIBE | jq -r .state) | |
FAILURE_REASON="" | |
if [[ $STATE != "done" ]]; then | |
echo $WORKFLOW_DESCRIBE | jq -c '.stages[].execution' | jq -r '"'$1' ('$STATE') \(.failureReason): \"\(.failureMessage)\" \(.failureFrom.id) - \(.failureFrom.executableName) - \(.failureFrom.name)"' | grep -v "null" || echo "$1 ($STATE) Error getting failures" | |
else | |
echo "$1 ($STATE)" | |
fi | |
} | |
describe_state_and_failures $ANALYSIS_ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment