Skip to content

remote_files: Add support for directly using local cache - #87

Open
joverlee521 wants to merge 2 commits into
mainfrom
use-local-cache
Open

joverlee521 wants to merge 2 commits into
mainfrom
use-local-cache

Conversation

@joverlee521

@joverlee521 joverlee521 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Description of proposed changes

The Snakemake storage usually checks the existence and revalidates remote files before using the local cache, which can lead to errors when running the workflow offline even if the local cache already exists.

This change adds support to directly use the local cache if it exists and bypass the remote file check when

  1. the config parameter use_remote_files is False
  2. the environment variable NEXTSTRAIN_REMOTE_FILES is False
  3. the workflow is running offline

Based on discussions in nextstrain/public#47 and changes tested in measles repo
nextstrain/measles@60634e2...b238682

Related issue(s)

Part of nextstrain/public#47

Checklist

The Snakemake storage usually checks the existence and revalidates remote
files before using the local cache, which can lead to errors when running
the workflow offline even if the local cache already exists.

This change adds support to directly use the local cache if it exists
and bypass the remote file check when
1. the config parameter `use_remote_files` is False
2. the environment variable `NEXTSTRAIN_REMOTE_FILES` is False
3. the workflow is running offline

Based on discussions in <nextstrain/public#47>
and changes tested in measles repo
<nextstrain/measles@60634e2...b238682>

@jameshadfield jameshadfield left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on and turning the prototype into a polished PR! I haven't tested the code but reading through it I think the behaviour is spot on. One minor query re: env variables is the only thing that stuck out to me.

Comment thread snakemake/remote_files.smk Outdated
Comment on lines +17 to +24
def is_online(host="8.8.8.8", port=53, timeout=3) -> bool:
"""
Check if workflow has network connection.
Based on <https://stackoverflow.com/a/33117579>
Host: 8.8.8.8 (google-public-dns-a.google.com)
OpenPort: 53/tcp
Service: domain (DNS/TCP)
"""

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I like this general "is online" approach better than the per-source checks in my original prototype

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, by checking against Google, is_online could return True when sources are unavailable, or False when sources are available but Google is down. This is very edge case-y though, I think it's fine to keep as-is.

@joverlee521

Copy link
Copy Markdown
Contributor Author

Will merge this next Tuesday to monitor downstream uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants