Skip to content
Permalink
Browse files
fix: remove raise that limits using --config with dicts (#1341)
* Remove raise that limits using --config with dicts

* Added a test case name 'test_dicts_in_config'

Co-authored-by: Johannes Köster <johannes.koester@tu-dortmund.de>
  • Loading branch information
lpla and johanneskoester committed Feb 21, 2022
1 parent 8ed0c8c commit bd65057a782355ede86ad0bb912e063ff25a97f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
@@ -970,8 +970,6 @@ def unparse_config(config):
raise ValueError("config is not a dict")
items = []
for key, value in config.items():
if isinstance(value, dict):
raise ValueError("config may only be a flat dict")
encoded = "'{}'".format(value) if isinstance(value, str) else value
items.append("{}={}".format(key, encoded))
return items
@@ -57,3 +57,22 @@ async def main():
async_run(main())
else:
asyncio.run(main())


def test_dicts_in_config():
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, this option " + config["this_option"] + "; this test dictionary " + config["test"]["this_dict"], file=f)
"""
),
file=f,
)
snakemake(path, workdir=tmpdir, config={"this_option": "does_not_break", "test": {'this_dict':'shoult_not_either'}})

0 comments on commit bd65057

Please sign in to comment.