Skip to content

Commit e1fa14d

Browse files
lbergelsonjonn-smith
authored andcommitted
checking existence of files (#76)
* checking existence of files for `submit
1 parent 81b4a21 commit e1fa14d

File tree

1 file changed

+49
-3
lines changed

1 file changed

+49
-3
lines changed

cromshell

+49-3
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,36 @@ function checkPrerequisites
282282
return 0
283283
}
284284

285-
function checkForComplexHelpArgument()
285+
function assertRequiredFileIsNonEmpty()
286+
{
287+
local fileName=$1
288+
local fileDescription=$2
289+
if [[ -z ${fileName} ]]; then
290+
error "ERROR: ${fileDescription} must be specified."
291+
exit 6
292+
else
293+
if [[ -f ${fileName} ]]; then
294+
if [[ ! -s ${fileName} ]]; then
295+
error "ERROR: ${fileDescription} is empty: ${fileName}"
296+
exit 6
297+
fi
298+
else
299+
error "ERROR: ${fileDescription} does not exist: ${fileName}"
300+
exit 6;
301+
fi
302+
fi
303+
}
304+
305+
function assertOptionalFileIsNonEmpty()
306+
{
307+
local fileName=$1
308+
local fileDescription=$2
309+
if [[ ! -z ${fileName} ]] ; then
310+
assertRequiredFileIsNonEmpty "${fileName}" "${fileDescription}"
311+
fi
312+
}
313+
314+
function checkForComplexHelpArgument()
286315
{
287316
for arg in $@ ; do
288317
case $arg in
@@ -617,11 +646,28 @@ function submit()
617646
done
618647
shift $((OPTIND-1))
619648

620-
# ----------------------------------------
649+
# ----------------------------------------
650+
651+
if [[ $# -lt 2 ]] ; then
652+
error "ERROR: submit requires at least a WDL and JSON file."
653+
error ""
654+
simpleUsage submit
655+
exit 21
656+
fi
657+
658+
local wdl=${1}
659+
local json=${2}
660+
local optionsJson=${3}
661+
local dependenciesZip=${4}
662+
663+
assertRequiredFileIsNonEmpty "${wdl}" "WDL"
664+
assertRequiredFileIsNonEmpty "${json}" "Input JSON"
665+
assertOptionalFileIsNonEmpty "${optionsJson}" "Options JSON"
666+
assertOptionalFileIsNonEmpty "${dependenciesZip}" "Dependencies Zip"
621667

622668
assertCanCommunicateWithServer $CROMWELL_URL
623669

624-
local response=$(curl --connect-timeout $CURL_CONNECT_TIMEOUT --max-time $CURL_MAX_TIMEOUT -s -F workflowSource=@${1} ${2:+ -F workflowInputs=@${2}} ${3:+ -F workflowOptions=@${3}} ${4:+ -F workflowDependencies=@${4}} ${CROMWELL_URL}/api/workflows/v1)
670+
local response=$(curl --connect-timeout $CURL_CONNECT_TIMEOUT --max-time $CURL_MAX_TIMEOUT -s -F workflowSource=@${wdl} ${2:+ -F workflowInputs=@${json}} ${3:+ -F workflowOptions=@${optionsJson}} ${4:+ -F workflowDependencies=@${depdenciesZip}} ${CROMWELL_URL}/api/workflows/v1)
625671
local r=$?
626672

627673
# Check to make sure that we actually submitted the job correctly

0 commit comments

Comments
 (0)