@@ -190,6 +190,16 @@ function checkPrerequisites
190
190
return 0
191
191
}
192
192
193
+
194
+ function assertCanCommunicateWithServer
195
+ {
196
+ # Make sure we can talk to the cromwell server:
197
+ serverName=$( echo ${1} | sed ' s#.*://##g' )
198
+ $PING_CMD $serverName & > /dev/null
199
+ r=$?
200
+ [[ $r -ne 0 ]] && error " Error: Cannot communicate with Cromwell server: $serverName " && exit 4
201
+ }
202
+
193
203
function assertHavePreviouslySubmittedAJob()
194
204
{
195
205
local nLines=$( wc -l ${CROMWELL_SUBMISSIONS_FILE} | awk ' {print $1}' )
@@ -241,8 +251,9 @@ function populateWorkflowIdAndServerUrl()
241
251
242
252
# Submit a workflow and arguments to the Cromwell Server
243
253
244
- function submit()
245
- {
254
+ function submit()
255
+ {
256
+ assertCanCommunicateWithServer $CROMWELL_URL
246
257
247
258
local response=$( curl --connect-timeout $CURL_CONNECT_TIMEOUT -s -F workflowSource=@${1} ${2: + -F workflowInputs=@ ${2} } ${3: + -F workflowOptions=@ ${3} } ${4: + -F workflowDependencies=@ ${4} } ${CROMWELL_URL} /api/workflows/v1)
248
259
local r=$?
@@ -267,6 +278,7 @@ function status()
267
278
{
268
279
local retVal=0
269
280
281
+ assertCanCommunicateWithServer $2
270
282
local f=$( makeTemp )
271
283
curl --connect-timeout $CURL_CONNECT_TIMEOUT -s ${2} /api/workflows/v1/${1} /status > $f
272
284
[[ $? -ne 0 ]] && error " Could not connect to Cromwell server." && return 2
@@ -286,32 +298,36 @@ function status()
286
298
}
287
299
288
300
# Get the logs of a Cromwell job UUID
289
- function logs()
301
+ function logs()
290
302
{
303
+ assertCanCommunicateWithServer $2
291
304
curl --connect-timeout $CURL_CONNECT_TIMEOUT -s ${2} /api/workflows/v1/${1} /logs | jq .
292
305
checkPipeStatus " Could not connect to Cromwell server." " Could not parse JSON output from cromwell server."
293
306
return $?
294
307
}
295
308
296
309
# Get the metadata for a Cromwell job UUID
297
- function metadata()
310
+ function metadata()
298
311
{
312
+ assertCanCommunicateWithServer $2
299
313
curl --connect-timeout $CURL_CONNECT_TIMEOUT --compressed -s ${2} /api/workflows/v1/${1} /metadata? ${CROMWELL_METADATA_PARAMETERS} | jq .
300
314
checkPipeStatus " Could not connect to Cromwell server." " Could not parse JSON output from cromwell server."
301
315
return $?
302
316
}
303
317
304
318
# Get the metadata in condensed form for a Cromwell job UUID
305
- function slim-metadata()
319
+ function slim-metadata()
306
320
{
321
+ assertCanCommunicateWithServer $2
307
322
curl --connect-timeout $CURL_CONNECT_TIMEOUT --compressed -s " ${2} /api/workflows/v1/$1 /metadata?includeKey=executionStatus&includeKey=backendStatus" | jq .
308
323
checkPipeStatus " Could not connect to Cromwell server." " Could not parse JSON output from cromwell server."
309
324
return $?
310
325
}
311
326
312
327
# Get the status of the given job and how many times it was run
313
- function execution-status-count()
328
+ function execution-status-count()
314
329
{
330
+ assertCanCommunicateWithServer $2
315
331
f=$( makeTemp )
316
332
curl --connect-timeout $CURL_CONNECT_TIMEOUT --compressed -s ${2} /api/workflows/v1/$1 /metadata? ${CROMWELL_METADATA_PARAMETERS} > $f
317
333
[[ $? -ne 0 ]] && error " Could not connect to Cromwell server." && return 9
@@ -330,16 +346,17 @@ function execution-status-count()
330
346
}
331
347
332
348
# Bring up a browser window to view timing information on the job.
333
- function timing()
349
+ function timing()
334
350
{
335
- echo " Opeining timing information in a web browser for job ID: ${1} "
351
+ echo " Opening timing information in a web browser for job ID: ${1} "
336
352
open ${2} /api/workflows/v1/${1} /timing
337
353
return $?
338
354
}
339
355
340
356
# Cancel a running job.
341
- function abort()
357
+ function abort()
342
358
{
359
+ assertCanCommunicateWithServer $2
343
360
response=$( curl --connect-timeout $CURL_CONNECT_TIMEOUT -X POST --header " Content-Type: application/json" --header " Accept: application/json" " ${2} /api/workflows/v1/${1} /abort" )
344
361
local r=$?
345
362
echo $response
@@ -430,8 +447,9 @@ function list()
430
447
# stderr
431
448
# script
432
449
# output
433
- function list-outputs()
450
+ function list-outputs()
434
451
{
452
+ assertCanCommunicateWithServer $2
435
453
local id=$1
436
454
local cromwellServer=$2
437
455
@@ -456,8 +474,9 @@ function list-outputs()
456
474
457
475
458
476
# Get the root log folder from the cloud and put it in the metadata folder for this run
459
- function fetch-logs()
477
+ function fetch-logs()
460
478
{
479
+ assertCanCommunicateWithServer $2
461
480
local id=$1
462
481
local cromwellServer=$2
463
482
@@ -490,8 +509,9 @@ function fetch-logs()
490
509
491
510
# Get the root log folder from the cloud and put it in the metadata folder for this run
492
511
# Includes all logs and output files
493
- function fetch-all()
512
+ function fetch-all()
494
513
{
514
+ assertCanCommunicateWithServer $2
495
515
local id=$1
496
516
local cromwellServer=$2
497
517
@@ -523,7 +543,8 @@ function notify()
523
543
local id=$1
524
544
local email=$2
525
545
local cromwellServer=$3
526
-
546
+
547
+ assertCanCommunicateWithServer ${cromwellServer}
527
548
local separator=" =================================================="
528
549
529
550
while true ; do
@@ -602,12 +623,6 @@ if ${ISCALLEDBYUSER} ; then
602
623
r=$?
603
624
[[ $r -ne 0 ]] && exit 6
604
625
605
- # Make sure we can talk to the cromwell server:
606
- serverName=$( echo ${CROMWELL_URL} | sed ' s#.*://##g' )
607
- $PING_CMD $serverName & > /dev/null
608
- r=$?
609
- [[ $r -ne 0 ]] && error " Error: Cannot communicate with Cromwell server: $serverName " && exit 4
610
-
611
626
# Special case: submitting a job:
612
627
if [[ " ${SUB_COMMAND} " == " submit" ]] ; then
613
628
${SUB_COMMAND} $1 $2 $3 $4
0 commit comments