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: properly use retry mechanism in source cache #1564

Merged
merged 1 commit into from Apr 5, 2022
Merged
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
7 changes: 3 additions & 4 deletions snakemake/sourcecache.py
Expand Up @@ -346,7 +346,7 @@ def runtime_cache_path(self):

def open(self, source_file, mode="r"):
cache_entry = self._cache(source_file)
return self._open(LocalSourceFile(cache_entry), mode)
return self._open_local_or_remote(LocalSourceFile(cache_entry), mode)

def exists(self, source_file):
try:
Expand Down Expand Up @@ -378,7 +378,7 @@ def _cache(self, source_file):

def _do_cache(self, source_file, cache_entry):
# open from origin
with self._open(source_file, "rb") as source:
with self._open_local_or_remote(source_file, "rb") as source:
tmp_source = tempfile.NamedTemporaryFile(
prefix=str(cache_entry),
delete=False, # no need to delete since we move it below
Expand All @@ -398,7 +398,7 @@ def _do_cache(self, source_file, cache_entry):
os.utime(cache_entry, times=(mtime, mtime))

def _open_local_or_remote(self, source_file, mode):
from retry import retry_call
from retry.api import retry_call

if source_file.is_local:
return self._open(source_file, mode)
Expand All @@ -409,7 +409,6 @@ def _open_local_or_remote(self, source_file, mode):
tries=3,
delay=3,
backoff=2,
logger=logger,
)

def _open(self, source_file, mode):
Expand Down