Code Monkey home page Code Monkey logo

Comments (3)

LukaP-BB avatar LukaP-BB commented on June 12, 2024 1

Which rule a is this referencing? :

Well, rule.a is referencing the only rule that is in scope, aka the one defined in main.smk.

Thanks for providing an option that is working, I appreciate it ❤️
However, I believe it to be more of a workaround than an actual "good" way of doing it. I would much rather specify only the rules I'm interested in instead of importing everything and then only use a subset of the rules.

I think Hocnonsense is right here :

and I've found that it is caused by refering rules.a.output in rules.b in imported.smk

and this is indeed a bug.
Since I'm overwriting the inputs, I don't see the point in trying to interpret input: rules.a.output in imported.smk

from snakemake.

cademirch avatar cademirch commented on June 12, 2024

Which rule a is this referencing? :

use rule b from imported as b with:
    input: rules.a.output

Seems like main's rule a would shadow imported's since they both are called rule a.

Assuming you want to use main's rule a as input you could do this in your main.smk:

# main.smk

module imported:
    snakefile: "imported.smk"
use rule * from imported as imported_*

rule a:
    output: "a.from_main.txt"
    shell: "touch {output}"

use rule imported_b as b with:
    input: rules.a.output

rule target:
    input: 
        rules.b.output

Dryrun output:

❯ snakemake -s main.smk target -n
Building DAG of jobs...
Job stats:
job       count
------  -------
a             1
b             1
target        1
total         3

Execute 1 jobs...

[Wed Apr 24 16:32:44 2024]
localrule a:
    output: a.from_main.txt
    jobid: 2
    reason: Missing output files: a.from_main.txt
    resources: tmpdir=<TBD>

Execute 1 jobs...

[Wed Apr 24 16:32:44 2024]
localrule b:
    input: a.from_main.txt
    output: b.txt
    jobid: 1
    reason: Missing output files: b.txt; Input files updated by another job: a.from_main.txt
    resources: tmpdir=<TBD>

Execute 1 jobs...

[Wed Apr 24 16:32:44 2024]
localrule target:
    input: b.txt
    jobid: 0
    reason: Input files updated by another job: b.txt
    resources: tmpdir=<TBD>

Job stats:
job       count
------  -------
a             1
b             1
target        1
total         3

from snakemake.

Hocnonsense avatar Hocnonsense commented on June 12, 2024

I also meet this exception, and I've found that it is caused by refering rules.a.output in rules.b in imported.smk

It happened when loading module module imported:
as you ONLY select b to be used (use rule b from imported as b with:),
snakemake go through each rule and only record the one you select, otherwise, it does nothing:

def rule(self, name=None, lineno=None, snakefile=None, checkpoint=False):
# choose a name for an unnamed rule
if name is None:
name = str(len(self._rules) + 1)
if self.modifier.skip_rule(name):
def decorate(ruleinfo):
# do nothing, ignore rule
return ruleinfo.func
return decorate

def skip_rule(self, rulename):
return (
self.rule_whitelist is not None and rulename not in self.rule_whitelist
) or (self.rule_exclude_list is not None and rulename in self.rule_exclude_list)

if you try to print workflow.modifier.rule_whitelist, you will find that it is not None

I think this is more similar to a bug than a behavier.

from snakemake.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.