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

Allow duplicate rule outputs if they are empty? #1367

Closed
vinisalazar opened this issue Feb 2, 2022 · 0 comments
Closed

Allow duplicate rule outputs if they are empty? #1367

vinisalazar opened this issue Feb 2, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@vinisalazar
Copy link
Contributor

vinisalazar commented Feb 2, 2022

Hi,

Is your feature request related to a problem? Please describe.
I have a rule in my workflow that has four outputs. However, I want two of these outputs to only be generated if a value in config is set to true. The way I achieved this by doing this:

rule my_rule:
    [...]
    output:
        optional_output_one: "file1.txt" if config["optional_output_one"] else (),
        optional_output_two: "file2.txt" if config["optional_output_two"] else (),

However, I get the following error when linting my workflow:

Duplicate output file pattern in rule my_rule. First two duplicate for entries optional_output_one and optional_output_two

Describe the solution you'd like
I modified the following line in function check_output_duplicates of rules.py:

if value in seen:

to

if value and value in seen:

and it fixed the problem. This disables the check if it's an empty value for the output file.

Describe alternatives you've considered
If you have any other suggestions or patterns on how to implement this logic that is better than what I've done, that would be very helpful.

Additional context
I'm not entirely sure if this change would introduce undesired or unexpected behaviour; however, if you agree with it, I'd appreciate the opportunity of contributing to Snakemake.

Thank you for any assistance you can provide.

Best,
Vini

@vinisalazar vinisalazar added the enhancement New feature or request label Feb 2, 2022
vinisalazar added a commit to vinisalazar/snakemake that referenced this issue Feb 2, 2022
  - Modify function 'check_output_duplicates' to check for empty value
  - Complete docstring
  - Add period at the end of raise message
  - Closes snakemake#1367
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant