Skip to content

Commit

Permalink
Merge pull request #168 from CABLE-LSM/158-better-error-handling-in-p…
Browse files Browse the repository at this point in the history
…bs-job-script

Added set -ex to the jobscript rendering, removed if statements. Fixe…
  • Loading branch information
ccarouge authored Oct 5, 2023
2 parents 2b8a9c7 + c654219 commit 883e2a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
11 changes: 3 additions & 8 deletions benchcab/utils/pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ def render_job_script(
#PBS -m e
#PBS -l storage={'+'.join(storage_flags)}
set -ex
module purge
{module_load_lines}
{benchcab_path} fluxsite-run-tasks --config={config_path} {verbose_flag}
if [ $? -ne 0 ]; then
echo 'Error: benchcab fluxsite-run-tasks failed. Exiting...'
exit 1
fi
{'' if skip_bitwise_cmp else f'''
{benchcab_path} fluxsite-bitwise-cmp --config={config_path} {verbose_flag}
if [ $? -ne 0 ]; then
echo 'Error: benchcab fluxsite-bitwise-cmp failed. Exiting...'
exit 1
fi''' }
''' }
"""
40 changes: 12 additions & 28 deletions tests/test_pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,17 @@ def test_render_job_script():
#PBS -m e
#PBS -l storage=gdata/ks32+gdata/hh5
set -ex
module purge
module load foo
module load bar
module load baz
/absolute/path/to/benchcab fluxsite-run-tasks --config=/path/to/config.yaml
if [ $? -ne 0 ]; then
echo 'Error: benchcab fluxsite-run-tasks failed. Exiting...'
exit 1
fi
/absolute/path/to/benchcab fluxsite-bitwise-cmp --config=/path/to/config.yaml
if [ $? -ne 0 ]; then
echo 'Error: benchcab fluxsite-bitwise-cmp failed. Exiting...'
exit 1
fi
"""
)

Expand All @@ -63,22 +58,17 @@ def test_render_job_script():
#PBS -m e
#PBS -l storage=gdata/ks32+gdata/hh5
set -ex
module purge
module load foo
module load bar
module load baz
/absolute/path/to/benchcab fluxsite-run-tasks --config=/path/to/config.yaml -v
if [ $? -ne 0 ]; then
echo 'Error: benchcab fluxsite-run-tasks failed. Exiting...'
exit 1
fi
/absolute/path/to/benchcab fluxsite-bitwise-cmp --config=/path/to/config.yaml -v
if [ $? -ne 0 ]; then
echo 'Error: benchcab fluxsite-bitwise-cmp failed. Exiting...'
exit 1
fi
"""
)

Expand All @@ -101,16 +91,14 @@ def test_render_job_script():
#PBS -m e
#PBS -l storage=gdata/ks32+gdata/hh5
set -ex
module purge
module load foo
module load bar
module load baz
/absolute/path/to/benchcab fluxsite-run-tasks --config=/path/to/config.yaml
if [ $? -ne 0 ]; then
echo 'Error: benchcab fluxsite-run-tasks failed. Exiting...'
exit 1
fi
"""
)
Expand Down Expand Up @@ -140,16 +128,14 @@ def test_render_job_script():
#PBS -m e
#PBS -l storage=gdata/ks32+gdata/hh5+gdata/foo
set -ex
module purge
module load foo
module load bar
module load baz
/absolute/path/to/benchcab fluxsite-run-tasks --config=/path/to/config.yaml
if [ $? -ne 0 ]; then
echo 'Error: benchcab fluxsite-run-tasks failed. Exiting...'
exit 1
fi
"""
)
Expand All @@ -174,16 +160,14 @@ def test_render_job_script():
#PBS -m e
#PBS -l storage=gdata/ks32+gdata/hh5
set -ex
module purge
module load foo
module load bar
module load baz
/absolute/path/to/benchcab fluxsite-run-tasks --config=/path/to/config.yaml
if [ $? -ne 0 ]; then
echo 'Error: benchcab fluxsite-run-tasks failed. Exiting...'
exit 1
fi
"""
)

0 comments on commit 883e2a8

Please sign in to comment.