Skip to content

Commit f2515ba

Browse files
Adding --parsable option
1 parent a5a7ba2 commit f2515ba

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,16 @@ Script options:
3939
must be comma delimited float numbers between
4040
0 and 1; optional [defaults to every 5th quantile]
4141
-p, --prefix=STR Prefix prepended to the output files
42+
-b, --parsable Parsable SLURM message mainly used
43+
for chained job submissions
4244
-c, --cache=DIR Path of the cache directory; optional
4345
-E, --email=STR E-mail when job starts, ends, and
4446
fails; optional
4547
-V, --version Show version
4648
-h, --help Show this screen and exit
49+
50+
For bug reports, questions, and discussions open an issue
51+
at https://github.com/kasra-keshavarz/gistool/issues
4752
```
4853

4954

extract-gis.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ Script options:
7575
must be comma delimited float numbers between
7676
0 and 1; optional [defaults to every 5th quantile]
7777
-p, --prefix=STR Prefix prepended to the output files
78+
-b, --parsable Parsable SLURM message mainly used
79+
for chained job submissions
7880
-c, --cache=DIR Path of the cache directory; optional
7981
-E, --email=STR E-mail when job starts, ends, and
8082
fails; optional
@@ -114,7 +116,7 @@ shopt -s expand_aliases
114116
# ATTENTION: `getopt` is available by default on most GNU/Linux
115117
# distributions, however, it may not work out of the
116118
# box on MacOS or BSD
117-
parsedArguments=$(getopt -a -n extract-geotiff -o d:i:r:v:o:s:e:l:n:f:jt:a:uq:p:c:EVh --long dataset:,dataset-dir:,crs:,variable:,output-dir:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,submit-job,print-geotiff:,stat:,include-na,quantile:,prefix:,cache:,email:,version,help -- "$@")
119+
parsedArguments=$(getopt -a -n extract-geotiff -o d:i:r:v:o:s:e:l:n:f:jt:a:uq:p:c:E:Vhb --long dataset:,dataset-dir:,crs:,variable:,output-dir:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,submit-job,print-geotiff:,stat:,include-na,quantile:,prefix:,cache:,email:,version,help,parsable -- "$@")
118120
validArguments=$?
119121
# check if there is no valid options
120122
if [ "$validArguments" != "0" ]; then
@@ -149,6 +151,7 @@ do
149151
-u | --include-na) includeNA=true ; shift ;; # optional
150152
-q | --quantile) quantiles="$2" ; shift 2 ;; # optional
151153
-p | --prefix) prefixStr="$2" ; shift 2 ;; # required
154+
-b | --parsable) parsable=true ; shift ;; # optional
152155
-c | --cache) cache="$2" ; shift 2 ;; # optional
153156
-E | --email) email="$2" ; shift 2 ;; # optional
154157
-V | --version) version ; shift ;; # optional
@@ -216,6 +219,20 @@ if [[ -n $email ]] && [[ -z $jobSubmission ]]; then
216219
echo "$(basename $0): Continuing without email notification..."
217220
fi
218221

222+
# parsable without job submission not allowed
223+
if [[ -n $parsable ]] && [[ -z $jobSubmission ]]; then
224+
echo "$(basename $0): ERROR! --parsable argument cannot be used" \
225+
"without job submission"
226+
exit 1;
227+
fi
228+
229+
# if parsable argument is provided
230+
if [[ -n $parsable ]]; then
231+
parsable="--parsable"
232+
else
233+
parsable=""
234+
fi
235+
219236
# either shapefile or spatial extents arguments are allowed
220237
if [[ -n $shapefile ]] && [[ -n $latLims ]]; then
221238
echo "$(basename $0): ERROR! Either shapefile or spatial extents should be entered"
@@ -302,17 +319,20 @@ call_processing_func () {
302319
#SBATCH --nodes=1
303320
#SBATCH --account=rpp-kshook
304321
#SBATCH --time=04:00:00
305-
#SBATCH --mem=16GB
322+
#SBATCH --mem=16000MB
306323
#SBATCH --job-name=GIS_${scriptName}
307324
#SBATCH --error=$logDir/GIS_%j_err.txt
308325
#SBATCH --output=$logDir/GIS_%j.txt
309326
#SBATCH --mail-user=$email
310327
#SBATCH --mail-type=BEGIN,END,FAIL
328+
#SBATCH ${parsable}
311329
312330
srun ${scriptRun} --cache="${cache}-\${SLURM_JOB_ID}"
313331
EOF
314332
# echo message
315-
echo "$(basename $0): job submission details are printed under ${logDir}"
333+
if [[ -z parsable ]]; then
334+
echo "$(basename $0): job submission details are printed under ${logDir}"
335+
fi
316336

317337
else
318338
eval "$scriptRun"

0 commit comments

Comments
 (0)