Navigation Menu

Skip to content

Commit

Permalink
fix: do not apply module prefix in case of remote files
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Feb 26, 2022
1 parent 2681f6f commit 5645b3f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
14 changes: 8 additions & 6 deletions snakemake/path_modifier.py
Expand Up @@ -52,11 +52,15 @@ def modify(self, path, property=None):
return modified_path

def replace_prefix(self, path, property=None):
if (
self.trie is None and self.prefix is None
) or property in self.skip_properties:
if (self.trie is None and self.prefix is None) or (
property in self.skip_properties
or os.path.isabs(path)
or path.startswith("..")
or is_flagged(path, "remote_object")
):
# no replacement
return path

if self.trie is not None:
prefixes = self.trie.prefix_items(str(path))
if len(prefixes) > 1:
Expand All @@ -74,10 +78,8 @@ def replace_prefix(self, path, property=None):
else:
# no matching prefix
return path

# prefix case
if os.path.isabs(path) or path.startswith(".."):
# do not apply prefix if path is not within the workdir
return path
return self.prefix + path

def apply_default_remote(self, path):
Expand Down
14 changes: 11 additions & 3 deletions tests/test_modules_prefix/module-test/Snakefile
@@ -1,13 +1,21 @@
configfile: "config.yaml" # does not exist, but this statement should be ignored on module import
from snakemake.remote.HTTP import RemoteProvider as HTTPRemoteProvider


configfile: "config.yaml" # does not exist, but this statement should be ignored on module import


HTTP = HTTPRemoteProvider()


def some_func():
return 15


rule a:
input:
HTTP.remote("raw.githubusercontent.com/snakemake/snakemake/main/LICENSE.md"),
output:
"results/test.out",
"/tmp/foo.txt"
"/tmp/foo.txt",
shell:
"echo {config[test]} > {output[0]}; touch {output[1]}"
"echo {config[test]} > {output[0]}; touch {output[1]}"

0 comments on commit 5645b3f

Please sign in to comment.