Repository navigation
Add weekly warm-reference-cache workflow - #1529
Conversation
Keeps the committed reference cache (publications/) complete so the full `just validate-all` reference phase stays cache-bound instead of re-fetching references from PubMed/providers every run. - scripts/warm_reference_cache.py: chunked `linkml-reference-validator validate data` over the whole corpus with full-text fetching on (the validator's default). References come from structured YAML fields, not a prose regex, so no malformed cache filenames are produced; raw PDFs (publications/files/) are gitignored. - just warm-references: recipe wrapping the script. - .github/workflows/warm-reference-cache.yaml: weekly (Mon 04:00 UTC) + workflow_dispatch; runs the warm, skips if the cache is unchanged, otherwise commits publications/ and opens/updates a PR (mirrors generate-pages's token/branch/PR pattern). On a complete cache the warm is a clean no-op. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Claude finished @cmungall's task in 4m 25s —— View job PR Review: Add weekly warm-reference-cache workflow (#1529)
Review ResultsStatus: Changes requested — one critical bug, one related important issue, two minor suggestions. Checklist (adapted for infrastructure PR)
Findings
SummaryWell-structured PR that correctly mirrors the |
| if git diff --quiet publications/; then | ||
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | ||
| echo "Reference cache already complete; nothing to commit." | ||
| else | ||
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | ||
| git diff --stat publications/ | tail -1 | ||
| fi |
There was a problem hiding this comment.
🔴 CRITICAL: git diff --quiet only detects changes to tracked files. The primary purpose of this workflow is to cache new references (new PMID_*.md files that don't exist yet on main). These untracked files will be invisible to git diff, causing the workflow to report "nothing to commit" and skip the PR — exactly when it should act.
The metadata step at line 65 (git diff --name-only) has the same issue: the CHANGED count will miss new files.
Fix: use git status --porcelain which detects both modified tracked files and new untracked files:
| if git diff --quiet publications/; then | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| echo "Reference cache already complete; nothing to commit." | |
| else | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| git diff --stat publications/ | tail -1 | |
| fi | |
| git add publications/ | |
| if git diff --cached --quiet; then | |
| git reset HEAD publications/ >/dev/null 2>&1 | |
| echo "has_changes=false" >> "$GITHUB_OUTPUT" | |
| echo "Reference cache already complete; nothing to commit." | |
| else | |
| echo "has_changes=true" >> "$GITHUB_OUTPUT" | |
| git diff --cached --stat | tail -1 | |
| fi |
This stages first, then checks the staging area with --cached. The later git add publications/ on line 86 becomes a no-op (already staged), and CHANGED on line 65 should also use git diff --cached --name-only to match.
An alternative without pre-staging:
if [ -z "$(git status --porcelain publications/)" ]; then| if: steps.check-changes.outputs.has_changes == 'true' | ||
| id: metadata | ||
| run: | | ||
| CHANGED=$(git diff --name-only publications/ | wc -l | tr -d ' ') |
There was a problem hiding this comment.
🟡 IMPORTANT: Same issue as the check-changes step — git diff --name-only misses new untracked files. If you adopt the git add + --cached approach above, this becomes:
| CHANGED=$(git diff --name-only publications/ | wc -l | tr -d ' ') | |
| CHANGED=$(git diff --cached --name-only publications/ | wc -l | tr -d ' ') |
| - name: Checkout repository | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 |
There was a problem hiding this comment.
🔵 SUGGESTION: fetch-depth: 0 clones the full history. The warm script doesn't use git history — it only reads files from HEAD. The later git fetch origin "$BRANCH_NAME" only needs the remote ref tip. fetch-depth: 1 would be faster and lighter. (Consistent with generate-pages which also uses 0, so this is a minor point — just noting the optimization opportunity.)
| fetch-depth: 0 | |
| fetch-depth: 1 |
| ], | ||
| stdout=subprocess.DEVNULL, |
There was a problem hiding this comment.
🔵 SUGGESTION: Both stdout and stderr are silenced. If the validator crashes or can't be found, the only signal is the progress counter stopping (the FileNotFoundError from subprocess.run would propagate, but a crash mid-validation would be invisible). Consider keeping stderr visible for diagnostics, or at least logging a warning if returncode != 0 for a whole chunk:
result = subprocess.run(
[...],
stdout=subprocess.DEVNULL,
check=False,
)
if result.returncode != 0:
print(f" (chunk {i//CHUNK + 1} had validation issues, returncode={result.returncode})", flush=True)Not critical since validation failures are expected, but it would make debugging easier if something unexpected happens during the weekly run.
There was a problem hiding this comment.
Review Summary
Clean, well-structured workflow that mirrors the existing generate-pages pattern. The Python script is simple and correct, and the justfile recipe fits naturally. However, there is one critical bug in the change-detection logic that would cause the workflow to silently skip its primary use case.
Checklist (adapted for infrastructure PR)
- Workflow structure follows existing
generate-pagespattern - Python script is correct and handles errors appropriately
- Config file (
conf/reference_validator_config.yaml) exists -
publications/files/is properly gitignored - Justfile recipe is well-placed and documented
- Change detection catches new (untracked) files — 🔴 see inline comment
Key finding
🔴 git diff --quiet publications/ does not detect new untracked files. The whole point of this workflow is to cache new references that create new PMID_*.md files. These are untracked on main, so git diff reports no changes and the commit/PR step is skipped. The metadata step (git diff --name-only) has the same gap. See inline comment for suggested fix using git add + git diff --cached, or git status --porcelain.
Everything else looks good — the concurrency group, PAT fallback, branch reuse via force-with-lease, and single-PR-update pattern are all sound.
Why
The warmed reference cache (PR #1527) keeps the full
validate-allreference phase fast only as long as it stays complete. As genes/references are added, new entries go uncached andvalidate-allre-fetches them. This workflow keeps the cache continuously complete.What
scripts/warm_reference_cache.py— runslinkml-reference-validator validate dataover the whole corpus in chunks with full-text fetching on (the validator's default). References are read from the structured YAML fields (not a prose regex), so it cannot produce the malformedPMID_123).mdjunk the earlier ad-hoc warm did. Validation pass/fail is ignored — the goal is only to populatepublications/.just warm-references— recipe wrapping the script..github/workflows/warm-reference-cache.yaml— runs weekly (Mon 04:00 UTC) +workflow_dispatch. Warms, then skips if the cache is unchanged; otherwise commitspublications/and opens/updates a single PR (auto/warm-reference-cache), mirroringgenerate-pages's token/bot/force-push/PR pattern. Raw fetched PDFs (publications/files/) are gitignored.Behavior
On a complete cache the warm is a clean no-op (verified locally: re-running the validator over already-cached genes makes zero tracked changes), so most weeks produce no PR. Only genuinely new/incomplete references trigger a cache-update PR — which needs no real review (cache data) and can be merged at leisure.
🤖 Generated with Claude Code