Skip to content
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

KeyError and CreateRuleException while using modifying use statement #958

Open
ashwinvis opened this issue Apr 16, 2021 · 2 comments
Open
Labels
bug Something isn't working

Comments

@ashwinvis
Copy link
Contributor

Snakemake version 6.1.1 and git version 6.1.1+7.g5349f2a4

Describe the bug

Errors are thrown if we have modified rules made using the use rule ... as ... with: syntax in a Snakemake module while snakemake --list.

Minimal example

Assume there are two rules defined in a module other_workflow.smk. There is one scenario in which everything works as expected and 2 in which errors are thrown.

rule some_task:
    output: "output.txt"
    shell: "cat hello >> {output}"

use rule some_task as another_task with:
    output: "another.txt"
  1. Working Snakefile
module other_workflow:
    snakefile: "other_workflow.smk"

use rule * from other_workflow
❯ snakemake -l          
some_task
another_task
  1. Buggy Snakefile
module other_workflow:
    snakefile: "other_workflow.smk"

use rule * from other_workflow as other_*
❯ snakemake -l 
KeyError in line 7 of /home/avmo/src/sandbox/snakemake-module-issue/other_workflow.smk:
'some_task'
  File "/home/avmo/src/sandbox/snakemake-module-issue/Snakefile", line 5, in <module>
  File "/home/avmo/src/sandbox/snakemake-module-issue/other_workflow.smk", line 7, in <module>

It seems like an issue with the scope of the modules.

  1. Buggy Snakefile
module other_workflow:
    snakefile: "other_workflow.smk"

use rule * from other_workflow

use rule some_task from other_workflow as other_some_task with:
    output:  "some-result.txt"
❯ snakemake -l
CreateRuleException in line 7 of /home/avmo/src/sandbox/snakemake-module-issue/other_workflow.smk:
The name another_task is already used by another rule
  File "/home/avmo/src/sandbox/snakemake-module-issue/Snakefile", line 9, in <module>
  File "/home/avmo/src/sandbox/snakemake-module-issue/other_workflow.smk", line 7, in <module>

It seems like an issue with importing rules multiple times

@ashwinvis ashwinvis added the bug Something isn't working label Apr 16, 2021
@ashwinvis ashwinvis changed the title Key error while using modifying use statement in the module KeyError and CreateRuleException while using modifying use statement Apr 16, 2021
@ashwinvis
Copy link
Contributor Author

Really bad workaround for case 2. Buggy Snakefile

If other_workflow.smk is re-written as

rule some_task:
    output: "output.txt"
    shell: "cat hello >> {output}"

use rule other_some_task as another_task with:
    output: "another.txt"

the 2. Buggy snakefile case works where it shouldn't have!

❯ snakemake -l                                                                                                                                                                
other_some_task
another_task

@ashwinvis
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant