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

Inspection for execution sections in 'use' section #408

Closed
dakochik opened this issue Jul 28, 2021 · 5 comments
Closed

Inspection for execution sections in 'use' section #408

dakochik opened this issue Jul 28, 2021 · 5 comments
Assignees
Milestone

Comments

@dakochik
Copy link
Contributor

If an execution section appears in 'use' section, we are getting misleading message:

127199324-845f9c69-9799-4e09-9aab-b8e78e5c5fd8

But in this case, snakemake prints an error with message: "Unexpected keyword shell in rule definition"
So, we need to add a more appropriate message.
Related to #355

@iromeo
Copy link
Contributor

iromeo commented Jul 30, 2021

Similar for subworflows:

subworkflow foo:
    input: ""

See ..../python3.8/site-packages/snakemake/parser.py

        if is_name(token):
            try:
                if token.string == "snakefile":
                    self.has_snakefile = True
                if token.string == "workdir":
                    self.has_workdir = True
                for t in self.subautomaton(token.string).consume():
                    yield t
            except KeyError:
                self.error(
                    "Unexpected keyword {} in "
                    "subworkflow definition".format(token.string),
                    token,
                )

@iromeo
Copy link
Contributor

iromeo commented Jul 30, 2021

For module, see Module.block_content(), ModuleReplacePrefix, ModuleSkipValidation ModuleConfig, ModuleMetaWrapper, ModuleSnakefile

    def block_content(self, token):
        if is_name(token):
            try:
                if token.string == "snakefile":
                    self.has_snakefile = True
                if token.string == "meta_wrapper":
                    self.has_meta_wrapper = True
                for t in self.subautomaton(token.string).consume():
                    yield t
            except KeyError:
                self.error(
                    "Unexpected keyword {} in "
                    "module definition".format(token.string),
                    token,
                )

For Use, see UseRule.block_content. AFAIU supported sections is taken from variable:

rule_property_subautomata = dict(
    name=Name,
    input=Input,
    output=Output,
    params=Params,
    threads=Threads,
    resources=Resources,
    priority=Priority,
    version=Version,
    log=Log,
    message=Message,
    benchmark=Benchmark,
    conda=Conda,
    singularity=Singularity,
    container=Container,
    containerized=Containerized,
    envmodules=EnvModules,
    wildcard_constraints=WildcardConstraints,
    shadow=Shadow,
    group=Group,
    cache=Cache,
    handover=Handover,
)

dakochik pushed a commit that referenced this issue Aug 11, 2021
…f unrecognized subsection is acceptable for another section

Resolves: #408
@dakochik
Copy link
Contributor Author

Fixed:

unrecognized section #1
unrecognized section #2

dakochik pushed a commit that referenced this issue Aug 12, 2021
dakochik pushed a commit that referenced this issue Aug 12, 2021
dakochik pushed a commit that referenced this issue Aug 16, 2021
refactored: tests and error messages

Resolves: #408
dakochik pushed a commit that referenced this issue Aug 16, 2021
@iromeo
Copy link
Contributor

iromeo commented Aug 16, 2021

@dakochik Please add short feature demo (png or gif)

iromeo pushed a commit that referenced this issue Aug 16, 2021
feat: Inspection: Show ERROR for execution sections in 'use' section (#408)
@dakochik
Copy link
Contributor Author

Done:

unused log section use case

@iromeo iromeo modified the milestones: use-module-syntax, next major Oct 31, 2021
@iromeo iromeo closed this as completed Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants