-
Notifications
You must be signed in to change notification settings - Fork 20
Ignore cache if Nextclade or dataset version is different #466
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
02c6b24
nextclade: check use of cache in separate script/rule
joverlee521 325d4bd
Ignore cache if Nextclade or dataset version is different
joverlee521 988fbec
bin/fetch-cache-version: Add comment
joverlee521 6c6a4ff
Simplify nextclade_dataset input
joverlee521 9a2ca57
Move downloaded Nextclade executable to `data/nextclade`
joverlee521 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/bin/bash | ||
|
|
||
| # this script intentionally doesn't `set -euo pipefail` | ||
| # because otherwise the `head -n 2` step triggers SIGPIPE | ||
| # causing the script to exit before it is done. | ||
|
|
||
| s3_url="${1:?An S3 URL is required as the first argument}" | ||
|
|
||
|
|
||
| trap '' SIGPIPE | ||
|
|
||
| (aws s3 cp "$s3_url" - \ | ||
| | zstd -T0 -dcq \ | ||
| | head -n 2 \ | ||
| | tsv-select -H -f 'nextclade_version,dataset_version' \ | ||
| | tail -n 1 \ | ||
| | jq --raw-input -c ' | ||
| split("\t") | ||
| | { "nextclade_version": .[0], "nextclade_dataset_version": .[1] }') \ | ||
| 2> /dev/null | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| bin="$(dirname "$0")" | ||
| vendored="$bin"/../vendored | ||
|
|
||
| main() { | ||
| s3_dst="${1:?A destination s3:// URL where the renew file is hosted is required as the first argument.}" | ||
| s3_src="${2:?A source s3:// URL where the fallback renew file is hosted is required as the second argument.}" | ||
| nextclade="${3:?A path to the Nextclade executable is required as the third argument}" | ||
| nextclade_dataset="${4:?A path to a Nextclade dataset ZIP archive is required as the fourth argument}" | ||
| # Nextclade dataset reference wildcard | ||
| reference="${5:-}" | ||
|
|
||
| if renew-flag-exists; then | ||
| echo "[INFO] Found renew flag" >&2 | ||
| echo "false" | ||
| exit 0 | ||
| fi | ||
|
|
||
| cache_versions="$(get-cache-version-info)" | ||
| cache_nextclade_version="$(echo "$cache_versions" | jq -r .nextclade_version)" | ||
| current_nextclade_version="$("$nextclade" --version)" | ||
| if [[ "$cache_nextclade_version" != "$current_nextclade_version" ]]; then | ||
| echo "[INFO] Current Nextclade version ($current_nextclade_version) is different from cache version ($cache_nextclade_version)" >&2 | ||
| echo "false" | ||
| exit 0 | ||
| fi | ||
|
|
||
| cache_dataset_version="$(echo "$cache_versions" | jq -r .nextclade_dataset_version)" | ||
| current_dataset_version="$(unzip -p "$nextclade_dataset" pathogen.json | jq -r '.version.tag')" | ||
| if [[ "$cache_dataset_version" != "$current_dataset_version" ]]; then | ||
| echo "[INFO] Current Nextclade dataset version ($current_dataset_version) is different from cache version ($cache_dataset_version)" >&2 | ||
| echo "false" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "true" | ||
| } | ||
|
|
||
| renew-flag-exists() { | ||
| local renew_file="nextclade$reference.tsv.zst.renew" | ||
| local dst_renew_file="$s3_dst/$renew_file" | ||
| local src_renew_file="$s3_src/$renew_file" | ||
|
|
||
| "$vendored"/s3-object-exists "$dst_renew_file" || "$vendored"/s3-object-exists "$src_renew_file" | ||
| } | ||
|
|
||
| get-cache-version-info() { | ||
| # TODO: Update check a separate file for version info | ||
| # Currently just checks the first row of the nextclade.tsv file | ||
| local version_file="nextclade$reference.tsv.zst" | ||
| local dst_version_file="$s3_dst/$version_file" | ||
| local src_version_file="$s3_src/$version_file" | ||
|
|
||
| "$bin"/fetch-cache-version "$dst_version_file" || "$bin"/cache-version "$src_version_file" | ||
| } | ||
|
|
||
| main "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.