@@ -761,10 +761,15 @@ function status()
761
761
762
762
# Get execution status count and filter the metadata down:
763
763
curl --compressed -s " ${2} /api/workflows/v1/${1} /metadata?${CROMWELL_SLIM_METADATA_PARAMETERS} " > ${tmpMetadata}
764
- cat ${tmpMetadata} | jq ' .calls | map_values(group_by(.executionStatus) | map({(.[0].executionStatus): . | length}) | add)' > ${tmpExecutionStatusCount}
764
+
765
+ # Commented out due to limitations of jq 1.3 on some machines.
766
+ # The following two lines are functionally equivalent:
767
+ # jq '.calls | map_values(group_by(.executionStatus) | map({(.[0].executionStatus): . | length}) | add)' ${tmpMetadata} > ${tmpExecutionStatusCount}
768
+ # jq '(.calls | to_entries[] | .key as $task_name | .value | group_by(.executionStatus) | map({(.[0].executionStatus): . | length}) | add | to_entries[] | { ($task_name): {(.key): .value} })' ${tmpMetadata} | jq -s '. | add' > ${tmpExecutionStatusCount}
769
+ jq -s ' map(.calls | to_entries[] | {(.key): .value | map(.executionStatus) | group_by(.) | map({(.[0]): length}) | add} ) | add' ${tmpMetadata} > ${tmpExecutionStatusCount}
765
770
766
771
# Check for failure states:
767
- cat ${tmpMetadata} | jq --exit-status ' [ ..|.executionStatus? | values | . == " Failed" ] | any ' > /dev/null
772
+ cat ${tmpMetadata} | grep -q ' Failed'
768
773
r=$?
769
774
770
775
# Check for failures:
@@ -774,6 +779,9 @@ function status()
774
779
else
775
780
turtleDead
776
781
workflowStatus=" WILL_FAIL"
782
+ local newTempFile=$( makeTemp)
783
+ jq " .status=\" ${workflowStatus} \" | .ID=\" ${1} \" " ${tmpExecutionStatusCount} > ${newTempFile}
784
+ cp ${newTempFile} ${tmpExecutionStatusCount}
777
785
f=${tmpExecutionStatusCount}
778
786
fi
779
787
else
@@ -1402,12 +1410,17 @@ function _notifyHelper()
1402
1410
1403
1411
assertCanCommunicateWithServer ${cromwellServer}
1404
1412
local separator=" =================================================="
1413
+ local statusFile=$( makeTemp )
1405
1414
1406
1415
while true ; do
1407
- completionStatus=$( status ${id} ${cromwellServer} 2> /dev/null | grep " status" | sed -e ' s#.*status":##g' | tr -d ' ",' )
1408
- echo ${completionStatus} | grep -qE " Succeeded|Failed|Aborted"
1409
- r=${PIPESTATUS[1]}
1410
- if [[ ${r} -eq 0 ]] ; then
1416
+
1417
+ status ${id} ${cromwellServer} 2> /dev/null > ${statusFile}
1418
+ completionStatus=$( jq -r ' .status' ${statusFile} )
1419
+
1420
+ if [[ " ${completionStatus} " == " Succeeded" ]] || \
1421
+ [[ " ${completionStatus} " == " Failed" ]] || \
1422
+ [[ " ${completionStatus} " == " Aborted" ]] || \
1423
+ [[ " ${completionStatus} " == " WILL_FAIL" ]] ; then
1411
1424
workflowFile=$( grep ' $id' ${CROMWELL_SUBMISSIONS_FILE} | head -n1 | awk ' {print $4}' )
1412
1425
metaData=$( metadata ${id} ${cromwellServer} )
1413
1426
echo -e " CROMWELL Task ${completionStatus} :\n\n${id} \n\non\n\n${cromwellServer} \n\n${separator} \n\nStatus:\n$( cat ${statusFile} ) \n\n${separator} \nMetadata:\n${metaData} \n\n${separator} \nSent by $( whoami ) @$( hostname ) on $( date ) \n\n\n" | mail -n -s " Cromwell Task ${completionStatus} [${cromwellServer} ] ${workflowFile} " ${email}
0 commit comments