diff --git a/snakemake/path_modifier.py b/snakemake/path_modifier.py index 2ba697b9e..4ccc1bfc4 100644 --- a/snakemake/path_modifier.py +++ b/snakemake/path_modifier.py @@ -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: @@ -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): diff --git a/tests/test_modules_prefix/module-test/Snakefile b/tests/test_modules_prefix/module-test/Snakefile index 7703450b6..732fb5081 100644 --- a/tests/test_modules_prefix/module-test/Snakefile +++ b/tests/test_modules_prefix/module-test/Snakefile @@ -1,4 +1,10 @@ -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(): @@ -6,8 +12,10 @@ def some_func(): 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]}" \ No newline at end of file + "echo {config[test]} > {output[0]}; touch {output[1]}"