From af6c0eb9860f7d873e53d40b3695c4169e495512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=20van=20Merri=C3=ABnboer?= Date: Tue, 7 Feb 2017 14:08:47 -0500 Subject: [PATCH 1/2] Fix #157. Currently the user's entire environment is exported. This is bad practice because it makes jobs hard to reproduce and debug, and in some cases it can even cause errors. The only variable that needs to be exported is `PBS_FILENAME`, which is used by the auto-resume script. --- smartdispatch/pbs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smartdispatch/pbs.py b/smartdispatch/pbs.py index f8d7982..dd7bf2b 100644 --- a/smartdispatch/pbs.py +++ b/smartdispatch/pbs.py @@ -36,7 +36,7 @@ def __init__(self, queue_name, walltime): self.add_options(q=queue_name) # Declares that all environment variables in the qsub command's environment are to be exported to the batch job. - self.add_options(V="") + self.add_options(v="PBS_FILENAME") def add_options(self, **options): """ Adds options to this PBS file. From 2042df349319eb0ebff3ba8e3dda0e5a35d4723b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=20van=20Merri=C3=ABnboer?= Date: Fri, 10 Feb 2017 15:01:16 -0500 Subject: [PATCH 2/2] Fix tests --- smartdispatch/tests/test_pbs.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/smartdispatch/tests/test_pbs.py b/smartdispatch/tests/test_pbs.py index 6088052..146b845 100644 --- a/smartdispatch/tests/test_pbs.py +++ b/smartdispatch/tests/test_pbs.py @@ -29,7 +29,7 @@ def test_constructor(self): def test_add_options(self): # Default options assert_equal(len(self.pbs.options), 2) - assert_true('-V' in self.pbs.options.keys()) + assert_equal(self.pbs.options['-v'], 'PBS_FILENAME') assert_equal(self.pbs.options['-q'], self.queue_name) self.pbs.add_options(A="option1") @@ -73,7 +73,7 @@ def test_str(self): # Create simple PBS file expected = """#!/bin/bash #PBS -q qtest@mp2 -#PBS -V +#PBS -v PBS_FILENAME #PBS -l walltime=01:00:00 # Modules # @@ -98,7 +98,7 @@ def test_str(self): expected = """\ #!/bin/bash #PBS -q qtest@mp2 -#PBS -V +#PBS -v PBS_FILENAME #PBS -A xyz-123-ab #PBS -l walltime=01:00:00 #PBS -l nodes=2:ppn=3:gpus=1