Skip to content

Commit f2d394c

Browse files
authored
Added womtool validation for WDL/JSON if it's in your path. (#87)
* Added womtool validation for WDL/JSON if it's in your path. Fixes #18
1 parent 1282fe0 commit f2d394c

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

README.md

+13-12
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ requires `column`, `curl`, `mail`, and [jq](https://stedolan.github.io/jq/)
3232

3333
### Supported Flags:
3434
* `-t` `TIMEOUT`
35-
* Set the curl connect timeout to `TIMEOUT` seconds.
35+
* Set the curl connect timeout to `TIMEOUT` seconds.
3636
* Also sets the curl max timeout to `2*TIMEOUT` seconds.
3737
* `TIMEOUT` must be an integer.
3838

@@ -41,37 +41,38 @@ requires `column`, `curl`, `mail`, and [jq](https://stedolan.github.io/jq/)
4141

4242
#### Start/Stop workflows
4343
* `submit` `[-w]` *`<wdl>`* *`<inputs_json>`* `[options_json]` `[included_wdl_zip_file]`
44-
* Submit a new workflow
44+
* Submit a new workflow.
45+
* Will automatically validate the WDL and JSON file if `womtool` is in your path.
4546
* *`-w`* Wait for workflow to transition from 'Submitted' to some other status
4647
before ${SCRIPTNAME} exits
4748
* *`included_wdl_zip_file`* Zip file containing any WDL files included in the input WDL
4849
* `abort` *`[workflow-id] [[workflow-id]...]`*
49-
* Abort a running workflow
50+
* Abort a running workflow.
5051
#### Query workflow status:
5152
* `status` *`[workflow-id] [[workflow-id]...]`*
52-
* Check the status of a workflow
53+
* Check the status of a workflow.
5354
* `metadata` *`[workflow-id] [[workflow-id]...]`*
54-
* Get the full metadata of a workflow
55+
* Get the full metadata of a workflow.
5556
* `slim-metadata` *`[workflow-id] [[workflow-id]...]`*
56-
* Get a subset of the metadata from a workflow
57+
* Get a subset of the metadata from a workflow.
5758
* `execution-status-count` *`[-p] [-x] [workflow-id] [[workflow-id]...]`*
58-
* Get the summarized status of all jobs in the workflow
59+
* Get the summarized status of all jobs in the workflow.
5960
* `-p` prints a pretty summary of the execution status instead of JSON
6061
* `-x` expands sub-workflows for more detailed summarization
6162
* `timing` *`[workflow-id] [[workflow-id]...]`*
62-
* Open the timing diagram in a browser
63+
* Open the timing diagram in a browser.
6364

6465
#### Logs
6566
* `logs` *`[workflow-id] [[workflow-id]...]`*
66-
* List the log files produced by a workflow
67+
* List the log files produced by a workflow.
6768
* `fetch-logs` *`[workflow-id] [[workflow-id]...]`*
68-
* Download all logs produced by a workflow
69+
* Download all logs produced by a workflow.
6970

7071
#### Job Outputs
7172
* `list-outputs` *`[workflow-id] [[workflow-id]...]`*
72-
* List all output files produced by a workflow
73+
* List all output files produced by a workflow.
7374
* `fetch-all` *`[workflow-id] [[workflow-id]...]`*
74-
* Download all output files produced by a workflow
75+
* Download all output files produced by a workflow.
7576

7677
#### Get email notification on job completion
7778
* `notify` *`[workflow-id]` `[daemon-server]` `email` `[cromwell-server]`*

cromshell

+24-10
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,11 @@ fi
5353
export CROMWELL_URL=${CROMWELL_URL:-"${CROMWELL_SERVER_FROM_FILE}"}
5454
FOLDER_URL=$( echo ${CROMWELL_URL} | sed -e 's#ht.*://##g' )
5555
CROMWELL_METADATA_PARAMETERS="excludeKey=submittedFiles&expandSubWorkflows=true"
56-
CROMWELL_SLIM_METADATA_PARAMETERS="includeKey=executionStatus&includeKey=backendStatus&includeKey=status&includeKey=callRoot&expandSubWorkflows=true"
56+
CROMWELL_SLIM_METADATA_PARAMETERS="includeKey=executionStatus&includeKey=backendStatus&includeKey=status&includeKey=callRoot&expandSubWorkflows=true"
5757

5858
CURL_CONNECT_TIMEOUT=5
5959
let CURL_MAX_TIMEOUT=2*${CURL_CONNECT_TIMEOUT}
6060

61-
PING_CMD='ping -c1 -W1 -w10'
62-
if [[ $( uname ) == "Darwin" ]] ; then
63-
PING_CMD='ping -c1 -W1000 -t10'
64-
fi
65-
6661
alias curl='curl --connect-timeout ${CURL_CONNECT_TIMEOUT} --max-time ${CURL_MAX_TIMEOUT}'
6762

6863
################################################################################
@@ -405,9 +400,9 @@ function getAnswerFromUser()
405400
function assertCanCommunicateWithServer
406401
{
407402
# Make sure we can talk to the cromwell server:
408-
local f=$(makeTemp)
409-
curl -s ${1}/api/workflows/v1/backends > ${f}
410-
grep -q 'supportedBackends' ${f}
403+
local f=$(makeTemp)
404+
curl -s ${1}/api/workflows/v1/backends > ${f}
405+
grep -q 'supportedBackends' ${f}
411406
r=$?
412407
if [[ ${r} -ne 0 ]] ; then
413408
turtleDead
@@ -664,13 +659,32 @@ function submit()
664659

665660
assertRequiredFileIsNonEmpty "${wdl}" "WDL"
666661
assertRequiredFileIsNonEmpty "${json}" "Input JSON"
662+
663+
# At this point, we should validate our inputs if we can:
664+
which womtool &> /dev/null
665+
local r=$?
666+
if [[ ${r} -eq 0 ]] ; then
667+
echo -ne "Validating WDL and JSON before submission..."
668+
local tmpValidationOutput=$( makeTemp )
669+
womtool validate ${wdl} -i ${json} &> ${tmpValidationOutput}
670+
if [[ $? -eq 0 ]] ; then
671+
echo -e '\tWDL and JSON are valid.'
672+
else
673+
echo
674+
echo
675+
error "ERROR: WDL and JSON files do not validate:"
676+
cat ${tmpValidationOutput} 1>&2
677+
exit 8
678+
fi
679+
fi
680+
667681
assertOptionalFileIsNonEmpty "${optionsJson}" "Options JSON"
668682
assertOptionalFileIsNonEmpty "${dependenciesZip}" "Dependencies Zip"
669683

670684
assertCanCommunicateWithServer ${CROMWELL_URL}
671685

672686
local response=$(curl -s -F workflowSource=@${wdl} ${2:+ -F workflowInputs=@${json}} ${3:+ -F workflowOptions=@${optionsJson}} ${4:+ -F workflowDependencies=@${dependenciesZip}} ${CROMWELL_URL}/api/workflows/v1)
673-
local r=$?
687+
r=$?
674688

675689
# Check to make sure that we actually submitted the job correctly
676690
# and the server ate it well:

0 commit comments

Comments
 (0)