@@ -336,7 +336,7 @@ function extract_workflow_ids_from_args()
336
336
else
337
337
while [ $# -gt 0 ] ; do
338
338
populateWorkflowIdAndServerUrl ${1}
339
- WORKFLOW_ID_LIST=" ${WORKFLOW_ID_LIST} ${1 } "
339
+ WORKFLOW_ID_LIST=" ${WORKFLOW_ID_LIST} ${WORKFLOW_ID } "
340
340
341
341
# Get next argument in $1:
342
342
shift
@@ -434,8 +434,8 @@ function populateWorkflowIdAndServerUrl()
434
434
{
435
435
local userSpecifiedId=$1
436
436
437
- # If the user specified a negative number, get the nth last workflow:
438
- if [[ $userSpecifiedId =~ ^-[[:digit:]]+$ ]] ; then
437
+ # If the user specified relative workflow ID :
438
+ if [[ $( matchRelativeWorkflowId ${ userSpecifiedId} ) -eq 0 ]] ; then
439
439
local row=${userSpecifiedId# -}
440
440
assertHavePreviouslySubmittedAJob
441
441
WORKFLOW_ID=$( tail -n $row $CROMWELL_SUBMISSIONS_FILE | head -n 1 | awk ' {print $3}' )
@@ -781,50 +781,48 @@ function slim-metadata()
781
781
function execution-status-count()
782
782
{
783
783
# Handle Arguments:
784
- local OPTIND
785
784
local doPretty=false
786
785
local doExpandSubWorkflows=false
787
786
788
787
local workflowIDs=" "
789
788
790
- while getopts " :px" opt ; do
791
- case ${opt} in
792
- p)
789
+ # Handling args this way to properly be able to detect negative workflow IDs and
790
+ # workflow IDs themselves.
791
+ # (getopt gets confused when you mix positional and flag args)
792
+ for arg in ${@ } ; do
793
+ case ${arg} in
794
+ -p)
793
795
doPretty=true
794
796
;;
795
- x)
797
+ - x)
796
798
doExpandSubWorkflows=true
797
799
;;
798
- \? )
799
- # This is an unexpected argument.
800
- if [[ $( matchWorkflowId ${OPTARG} ) -eq 0 ]] ; then
800
+ -[0-9]* )
801
801
# This is a workflow ID!
802
802
# Add it to the list:
803
- workflowIDs=" ${workflowIDs} ${OPTARG} "
804
- elif [[ $( matchRelativeWorkflowId " -${OPTARG} " ) -eq 0 ]] ; then
803
+ workflowIDs=" ${workflowIDs} ${arg} "
804
+ ;;
805
+ * )
806
+ if [[ $( matchWorkflowId ${arg} ) -eq 0 ]] ; then
805
807
# This is a workflow ID!
806
808
# Add it to the list:
807
- # NOTE: for the relative match we need to add back in the leading `-`
808
- workflowIDs=" ${workflowIDs} -${OPTARG} "
809
+ workflowIDs=" ${workflowIDs} ${arg} "
809
810
else
810
- # This is not a workflow ID!
811
- # Throw an error!
812
- invalidSubCommand execution-status-count flag ${opt}
811
+ # This is a flag missing an argument!
812
+ invalidSubCommand execution-status-count " missing flag for argument" ${arg}
813
813
fi
814
814
;;
815
- :)
816
- # This is a flag missing an argument!
817
- invalidSubCommand execution-status-count " missing flag for argument" ${OPTARG}
818
- ;;
819
815
esac
820
816
done
821
817
shift $(( OPTIND- 1 ))
822
818
819
+
823
820
# Get our workflow IDs in shape:
824
821
extract_workflow_ids_from_args ${workflowIDs}
825
822
826
- # Go through each workflow ID and get the info we want:
827
- for wfid in ${WORKFLOW_ID_LIST} ; do
823
+ # Go through each workflow ID and get the info we want:
824
+ for wfid in $WORKFLOW_ID_LIST ; do
825
+
828
826
829
827
populateWorkflowIdAndServerUrl ${wfid}
830
828
error " Using workflow-id == $WORKFLOW_ID "
@@ -833,14 +831,13 @@ function execution-status-count()
833
831
assertCanCommunicateWithServer " ${WORKFLOW_SERVER_URL} "
834
832
local tempFile=$( makeTemp )
835
833
if ! curl --connect-timeout " $CURL_CONNECT_TIMEOUT " --max-time " $CURL_MAX_TIMEOUT " --compressed -s " ${WORKFLOW_SERVER_URL} /api/workflows/v1/${WORKFLOW_ID} /metadata?$CROMWELL_SLIM_METADATA_PARAMETERS " > " ${tempFile} " ; then
836
- error " Could not connect to Cromwell server." && return 9
834
+ error " Error: Could not connect to Cromwell server."
837
835
fi
838
836
839
837
# Make sure the query succeeded:
840
838
if [[ " $( < " ${tempFile} " jq ' .status' | sed -e ' s#^"##g' -e ' s#"$##g' ) " == ' fail' ]] ; then
841
839
reason=$( < " ${tempFile} " jq ' .message' | sed -e ' s#^"##g' -e ' s#"$##g' )
842
840
error " Error: Query to cromwell server failed: ${reason} "
843
- return 11
844
841
fi
845
842
846
843
if ${doPretty} ; then
@@ -851,7 +848,6 @@ function execution-status-count()
851
848
# {tasks:{status: count}}
852
849
jq ' .calls | map_values(group_by(.executionStatus) | map({(.[0].executionStatus): . | length}) | add)' " ${tempFile} "
853
850
checkPipeStatus " Could not read tmp file JSON data." " Could not parse JSON output from cromwell server."
854
- return $?
855
851
fi
856
852
done
857
853
}
0 commit comments