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

fix: failure to properly apply default remote prefix in combination with the unpack marker #1448

Merged
merged 2 commits into from Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions snakemake/rules.py
Expand Up @@ -787,8 +787,6 @@ def _apply_wildcards(
groupid=groupid,
**aux_params
)
if apply_path_modifier and not incomplete:
item = self.apply_path_modifier(item, property=property)

if is_unpack and not incomplete:
if not allow_unpack:
Expand All @@ -808,14 +806,14 @@ def _apply_wildcards(
)
# Allow streamlined code with/without unpack
if isinstance(item, list):
pairs = zip([None] * len(item), item)
pairs = zip([None] * len(item), item, [_is_callable] * len(item))
else:
assert isinstance(item, dict)
pairs = item.items()
pairs = [(name, item, _is_callable) for name, item in item.items()]
else:
pairs = [(name, item)]
pairs = [(name, item, _is_callable)]

for name, item in pairs:
for name, item, from_callable in pairs:
is_iterable = True
if not_iterable(item) or no_flattening:
item = [item]
Expand All @@ -829,6 +827,10 @@ def _apply_wildcards(
raise WorkflowError(
"Function did not return str or list " "of str.", rule=self
)

if from_callable and apply_path_modifier and not incomplete:
item_ = self.apply_path_modifier(item_, property=property)

concrete = concretize(item_, wildcards, _is_callable)
newitems.append(concrete)
if mapping is not None:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_github_issue1396/Snakefile
@@ -0,0 +1,16 @@
def get_files(wildcards):
files_1 = expand("file_{i}", i=list(range(1, 5)))
files_2 = expand("file_{i}", i=list(range(5, 9)))
return {"files_1": files_1, "files_2": files_2}


rule all:
input:
unpack(get_files),


rule make_files:
output:
expand("file_{i}", i=list(range(1, 9))),
shell:
"touch {output}"
Empty file.
17 changes: 17 additions & 0 deletions tests/test_google_lifesciences.py
Expand Up @@ -109,3 +109,20 @@ def test_cloud_checkpoints_issue574():
)
finally:
cleanup_google_storage(storage_prefix, bucket_name)


def test_github_issue1396():
bucket_name = "snakemake-testing-%s" % next(tempfile._get_candidate_names())
create_google_storage(bucket_name)
storage_prefix = "test_github_issue1396"
workdir = dpath("test_github_issue1396")
try:
run(
workdir,
default_remote_prefix="%s/%s" % (bucket_name, storage_prefix),
google_lifesciences=True,
google_lifesciences_cache=False,
dryrun=True,
)
finally:
cleanup_google_storage(storage_prefix, bucket_name)