Skip to content
Permalink
Browse files
fix: fix errors occurring when refering to input func via rules.<rule…
…name>.input (#1669)

* fix: fix errors occurring when refering to input func via rules.<rulename>.input

* skip win

* fix for cases when a prefix is provided
  • Loading branch information
johanneskoester committed May 20, 2022
1 parent f1ffbf2 commit 28a47959bca2d135f82f9d8901b2b0aa228f30cb
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 1 deletion.
@@ -1443,6 +1443,9 @@ def git_content(git_file):

def strip_wildcard_constraints(pattern):
"""Return a string that does not contain any wildcard constraints."""
if is_callable(pattern):
# do not apply on e.g. input functions
return pattern

def strip_constraint(match):
return "{{{}}}".format(match.group("name"))
@@ -1270,7 +1270,23 @@ def output(self):

@lazy_property
def input(self):
return self.rule.input._stripped_constraints()
def modify_callable(item):
if is_callable(item):
# For callables ensure that the rule's original path modifier is applied as well.

def inner(wildcards):
return self.rule.apply_path_modifier(
item(wildcards), self.rule.input_modifier, property="input"
)

return inner
else:
# For strings, the path modifier has been already applied.
return item

return InputFiles(
toclone=self.rule.input, strip_constraints=True, custom_map=modify_callable
)

@lazy_property
def params(self):
@@ -0,0 +1,14 @@
module mod1:
snakefile:
"module1/Snakefile"
prefix:
"test/"


use rule * from mod1 as mod1_*


rule all:
input:
rules.mod1_all.input,
default_target: True
@@ -0,0 +1 @@
C
@@ -0,0 +1,15 @@
def txt_output(wildcards):
return ["results/C.txt"]


rule all:
input:
txt_output


rule txt:
output:
"results/C.txt"
shell:
"echo 'C' "
">{output} "
@@ -1646,6 +1646,11 @@ def test_retries():
run(dpath("test_retries"))


@skip_on_windows # OS agnostic
def test_module_input_func():
run(dpath("test_module_input_func"))


@skip_on_windows # the testcase only has a linux-64 pin file
def test_conda_pin_file():
run(dpath("test_conda_pin_file"), use_conda=True)

0 comments on commit 28a4795

Please sign in to comment.