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

feat: add support for comma in wildcards #2659

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Feelx234
Copy link

@Feelx234 Feelx234 commented Jan 30, 2024

Description

This is one part of two PR necessary to allow for commas in wildcards. This PR introduces the necessary decoding changes.

The test case will currently fail as the other PR (snakemake/snakemake-interface-executor-plugins#56) is necessary to properly handle the encoding.

QC

  • The PR contains a test case for the changes or the changes are already covered by an existing test case.
  • The documentation (docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).

Copy link

sonarcloud bot commented Jan 30, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@Feelx234 Feelx234 changed the title added support for comma in wildcards add support for comma in wildcards Jan 30, 2024
@Feelx234 Feelx234 changed the title add support for comma in wildcards feat: add support for comma in wildcards Jan 30, 2024
@johanneskoester
Copy link
Contributor

johanneskoester commented Feb 19, 2024

Thanks a lot for your PR! However, I don't really get it. Commas in wildcards are already supported now:

rule a:
    output:
	"test.{foo}.txt"
    shell:
	"touch {output}"

with

snakemake -n test.abc,d.txt

works just fine.

@Feelx234
Copy link
Author

Hey johannes,

Thanks for your reply. Apparently my test case was ill chosen. It took me a moment to figure out what went wrong. Apparently for the "bug" to show up we need to have a rule calling another rule and the other rule needs to have a run field rather than a shell field.

import subprocess

rule a:
    output:
	    "test2/{bar}_{i}.txt"
    run:
        subprocess.run(["touch", output[0]])

rule b:
    input:
        "test2/{bar}_1.txt"
    output:
        "test_{bar}.txt",
    shell:
        'touch "{output[0]}"'

Now if we do a dry run it works
snakemake "test_abcd,.txt" --cores 1 -n
but the actual execution errors
snakemake "test_abcd,.txt" --cores 1
with the traceback

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "(...)/snakemake/__main__.py", line 4, in <module>
    main()
  File "(...)/snakemake/__init__.py", line 3167, in main
    target_jobs=parse_target_jobs_cli_args(args),
  File "(...)/snakemake/target_jobs.py", line 21, in parse_target_jobs_cli_args
    wildcards = dict(
  File "(...)/snakemake/target_jobs.py", line 22, in <genexpr>
    parse_wildcard(entry) for entry in wildcards.split(",")
  File "(...)/snakemake/target_jobs.py", line 19, in parse_wildcard
    return parse_key_value_arg(entry, errmsg)
  File "(...)/snakemake/common/__init__.py", line 49, in parse_key_value_arg
    raise ValueError(errmsg + f" (Unparseable value: {repr(arg)})")
ValueError: Invalid target wildcards definition: entries have to be defined as WILDCARD=VALUE pairs (Unparseable value: '')

Also if we have no comma it works: ;)

snakemake "test_abcd.txt" --cores 1

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

Successfully merging this pull request may close these issues.

None yet

2 participants