New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove raise that limits using --config with dicts #1341
Conversation
Thanks! Actually a test of the CLI is possible. This works via the shellcmd argument of the test run function, see this example: https://github.com/snakemake/snakemake/blob/main/tests/tests.py#L267 |
Hi. Sorry about the initial version of the pull request. I thought we were running Snakemake through a Bash script, but it was a Python one, so we were using the Snakemake API. I updated the description and added a simple test. Let me know if this style is correct, or if I could do anything else to fix it better or cleaner. |
Also, I saw you edited the title as "feat:". Isn't this a bug? |
Just want to second this request. I ran into this limitation yesterday; as it is right now I'd have to choose between changing the config values I want to alter to be flat, or something janky like having a template config file in which I do string replacement. Passing a (nested) python dict is so much cleaner. Hope to see it in the next version so I can use it in production! |
Actually, there is a somewhat dirty hack to make this behaviour work correctly, by specifying some, possibly meaningless, dummy "config_args" value when calling snakemake from python: snakemake.snakemake(
...
# dict with just the values to be updated, properly nested as the config expects it
config=config_overrrides,
# some dummy config arg, as would normally be passed on the command line via --config-args
config_args=["dummy=0"]
) This is because the throwing function |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Description
Snakemake use through other Python scripts using its API class
allows setting any kind of parameters but dictionaries. The code this PR removes was triggering an exception when there is no issue in using dictionaries as a setting inside the Python dictionary given to the Snakemake class through
config
.A simple test named
test_dicts_in_config()
, similar to the code above, is added totests/testapi.py
file to reproduce this issue. Test could be even simpler, as the Snakefile can be completely empty to reproduce the issue, but the one I wrote shows a rule using dicts throughconfig
working without theraise
.QC
docs/
) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).