Hello,
I want to define a parent rule that performs some generic functionality that can be specified for other rules that inherit from it through parameters that are used in the parent rule. My reflex was to write something like the example Snakefile below.
rule parent:
run:
with open(output[1], "w") as f:
f.write(params.content)
use rule parent as child with:
output:
"test.txt"
params:
content="a"
rule all:
input:
"test.txt"
However, when trying to run it, I have the following error "TypeError in file "path/to/Snakefile", line 12: cannot unpack non-iterable NoneType object". After debugging I realised that this is because there was no params specified in the parent rule. Adding any parameter to it fixes the issue.
This comes from this line in the ruleinfo.py file:
|
original_positional, original_keyword = self.__dict__["params"] |
Since the parent rule doesn't have a params section, the params attribute remains None, thus it can't be unpacked.
Would it be more interesting to have a clearer error message in this case ?
Or if it considered better to change the Snakefile specification to not require a params section in the parent rule, this can be done by simply initializing "params = ((), dict())" instead of "params = None".
In any case, I can propose a PR with the preferred solution.
Hello,
I want to define a parent rule that performs some generic functionality that can be specified for other rules that inherit from it through parameters that are used in the parent rule. My reflex was to write something like the example Snakefile below.
However, when trying to run it, I have the following error "TypeError in file "path/to/Snakefile", line 12: cannot unpack non-iterable NoneType object". After debugging I realised that this is because there was no params specified in the parent rule. Adding any parameter to it fixes the issue.
This comes from this line in the ruleinfo.py file:
snakemake/src/snakemake/ruleinfo.py
Line 79 in 67ad5eb
Since the parent rule doesn't have a params section, the params attribute remains None, thus it can't be unpacked.
Would it be more interesting to have a clearer error message in this case ?
Or if it considered better to change the Snakefile specification to not require a params section in the parent rule, this can be done by simply initializing "params = ((), dict())" instead of "params = None".
In any case, I can propose a PR with the preferred solution.