Skip to content

Commit

Permalink
Remove .config references on the Toil object and isolate options tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnovak committed Feb 5, 2025
1 parent 9824495 commit 0905e03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
13 changes: 9 additions & 4 deletions src/toil/test/options/options.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from configargparse import ArgParser

from toil.common import Toil, addOptions
Expand All @@ -14,29 +16,32 @@ def test_default_caching_slurm(self):
Test to ensure that caching will be set to false when running on Slurm
:return:
"""
job_store = os.path.join(self._createTempDir(), "tree")
parser = ArgParser()
addOptions(parser, jobstore_as_flag=True, wdl=False, cwl=False)
test_args = ["--jobstore=example-jobstore", "--batchSystem=slurm"]
test_args = ["--jobstore", job_store, "--batchSystem=slurm"]
options = parser.parse_args(test_args)
with Toil(options) as toil:
caching_value = toil.config.caching
caching_value = toil._config.caching
self.assertEqual(caching_value, False)

def test_caching_option_priority(self):
"""
Test to ensure that the --caching option takes priority over the default_caching() return value
:return:
"""
job_store = os.path.join(self._createTempDir(), "tree")
parser = ArgParser()
addOptions(parser, jobstore_as_flag=True, wdl=False, cwl=False)
# the kubernetes batchsystem (and I think all batchsystems including singlemachine) return False
# for default_caching
test_args = [
"--jobstore=example-jobstore",
"--jobstore",
job_store,
"--batchSystem=kubernetes",
"--caching=True",
]
options = parser.parse_args(test_args)
with Toil(options) as toil:
caching_value = toil.config.caching
caching_value = toil._config.caching
self.assertEqual(caching_value, True)
2 changes: 1 addition & 1 deletion src/toil/test/provisioners/aws/awsProvisionerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ def job(job, disk="10M", cores=1, memory="10M", preemptible=True):
if __name__ == "__main__":
options = Job.Runner.getDefaultArgumentParser().parse_args()
with Toil(options) as toil:
if toil.config.restart:
if options.restart:
toil.restart()
else:
toil.start(Job.wrapJobFn(job))
Expand Down
4 changes: 2 additions & 2 deletions src/toil/test/src/autoDeploymentTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def job(job, disk="10M", cores=1, memory="10M"):
if __name__ == "__main__":
options = Job.Runner.getDefaultArgumentParser().parse_args()
with Toil(options) as toil:
if toil.config.restart:
if options.restart:
toil.restart()
else:
toil.start(Job.wrapJobFn(job))
Expand Down Expand Up @@ -139,7 +139,7 @@ def job(job, disk="10M", cores=1, memory="10M"):
if __name__ == "__main__":
options = Job.Runner.getDefaultArgumentParser().parse_args()
with Toil(options) as toil:
if toil.config.restart:
if options.restart:
toil.restart()
else:
toil.start(Job.wrapJobFn(job))
Expand Down

0 comments on commit 0905e03

Please sign in to comment.