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

Unresolved reference for 'rule' in 'run' section #283

Closed
BertBog opened this issue May 4, 2020 · 5 comments
Closed

Unresolved reference for 'rule' in 'run' section #283

BertBog opened this issue May 4, 2020 · 5 comments
Assignees
Labels
codeInsight Code completion, resolve
Milestone

Comments

@BertBog
Copy link

BertBog commented May 4, 2020

Hey,

When I'm referencing the 'rule' variable in the python code of the 'run' section, it gets flagged as an unresolved reference, but the code itself works fine.
Would it be possible to fix this? For other variables such as 'threads' or 'input' it works fine.

Best regards,
Bert

@iromeo
Copy link
Contributor

iromeo commented May 5, 2020

@BertBog could you provide a code example for this issue? What rule is used for, is it your own variable or some provided by snakemake?

@BertBog
Copy link
Author

BertBog commented May 5, 2020

We mainly use it to log information about rule execution to a database. But a basic use case would be something like this:

rule do_something:
    output:
        TXT = "test_file.txt"
    run:
        print("Executing rule: {}".format(rule))
        with open(output.TXT, 'w') as handle:
            handle.write('done\n')

@iromeo
Copy link
Contributor

iromeo commented May 5, 2020

Oh, I don't know about this feature, thx. I'll add support for it in future versions, need to investigate snakemake sources, what API is available for rule variable, what is it's type, etc.

@iromeo
Copy link
Contributor

iromeo commented May 10, 2020

Updated:
This var is available as a parameter of run wrapper function generated by snakemake, e.g.:

@workflow.run
def __rule_do_something(input, output, params, wildcards, threads, resources, log, version, rule, conda_env, container_img, singularity_args, use_singularity, env_modules, bench_record, jobid, is_shell, bench_iteration, cleanup_scripts, shadow_dir, edit_notebook):
   ...

Run function is generated by snakemake.parser.Run class

@iromeo iromeo closed this as completed in cd76134 May 10, 2020
@iromeo iromeo self-assigned this May 10, 2020
@iromeo iromeo added the codeInsight Code completion, resolve label May 10, 2020
@iromeo iromeo added this to the 0.6.1 milestone May 10, 2020
@iromeo
Copy link
Contributor

iromeo commented May 10, 2020

Error not shown for 'rule' and 'jobid', also rule is in completion list:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codeInsight Code completion, resolve
Projects
None yet
Development

No branches or pull requests

2 participants