From 5f5e12e0aa3f9e8b8a05800dd48a136eb7760b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20R=2E=20H=C3=B6lzlwimmer?= Date: Mon, 20 Jun 2022 17:21:03 +0200 Subject: [PATCH 1/2] Fix None type error when invoking Workflow object manually --- snakemake/workflow.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/snakemake/workflow.py b/snakemake/workflow.py index f32892b29..e2ea198e5 100644 --- a/snakemake/workflow.py +++ b/snakemake/workflow.py @@ -163,7 +163,9 @@ def __init__( self.global_resources["_cores"] = cores self.global_resources["_nodes"] = nodes - self.rerun_triggers = frozenset(rerun_triggers) + self.rerun_triggers = ( + frozenset(rerun_triggers) if rerun_triggers is not None else frozenset() + ) self._rules = OrderedDict() self.default_target = None self._workdir = None From 2165e6a8136ea6cb81cf2dfb806c53ae9db2ebea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20R=2E=20H=C3=B6lzlwimmer?= Date: Mon, 20 Jun 2022 17:28:33 +0200 Subject: [PATCH 2/2] add test for calling Workflow() api --- tests/testapi.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/testapi.py b/tests/testapi.py index f2e608ff3..ef6e2d13a 100644 --- a/tests/testapi.py +++ b/tests/testapi.py @@ -17,6 +17,28 @@ def test_keep_logger(): snakemake(path, workdir=tmpdir, keep_logger=True) +def test_workflow_calling(): + with tempfile.TemporaryDirectory() as tmpdir: + path = os.path.join(tmpdir, "Snakefile") + with open(path, "w") as f: + print( + dedent( + """ + rule: + output: 'result.txt' + run: + with open(output[0], 'w') as f: + print("hello", file=f) + """ + ), + file=f, + ) + workflow = Workflow( + snakefile=snakefile, + overwrite_workdir=tmpdir, + ) + + def test_run_script_directive(): with tempfile.TemporaryDirectory() as tmpdir: path = os.path.join(tmpdir, "Snakefile") @@ -81,6 +103,7 @@ def test_dicts_in_config(): }, ) + def test_lockexception(): from snakemake.persistence import Persistence from snakemake.exceptions import LockException