Skip to content

Commit

Permalink
fix: None type error when invoking Workflow object manually (#1731)
Browse files Browse the repository at this point in the history
* Fix None type error when invoking Workflow object manually

* add test for calling Workflow() api
  • Loading branch information
Hoeze committed Sep 16, 2022
1 parent a1e49b6 commit dc45ccb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion snakemake/workflow.py
Expand Up @@ -165,7 +165,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
Expand Down
22 changes: 22 additions & 0 deletions tests/testapi.py
Expand Up @@ -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")
Expand Down

0 comments on commit dc45ccb

Please sign in to comment.