Add --force-refresh flag to overwrite owl_cache canonical slots#1
Merged
Conversation
The existing pre-warm pass walks every (query_type, entity_id) tuple
for the OWLERY + V3 endpoints and runs a GET against owl_cache
(v3-cached.virtualflybrain.org for V3, owl.virtualflybrain.org for
the legacy OWLERY queries). That's enough on first deploy when the
cache is cold, but it does nothing for a refresh: the very first
request after the wamup is served from the existing cache slot.
After a VFBquery release the deployed response shape may differ
(new columns, fixed wire format, etc.). We need a way to force-fetch
every entry from upstream and overwrite the canonical owl_cache
slot, in the background, so end-users hitting v3-cached after the
release get either a stale (previous-version) entry or a fresh
(post-warmup) entry -- never a cold miss.
owl_cache's companion change adds:
map $http_x_force_refresh $force_refresh {
default ${FORCE_CACHE_REFRESH_ON_REQUEST};
"~*^(true|1|yes)$" 1;
}
with the pre-existing `proxy_cache_bypass $force_refresh` and no
`proxy_no_cache` -- so a request with `X-Force-Refresh: true`
bypasses the cache for the fetch AND the upstream response then
overwrites the canonical slot.
This change adds the matching CLI flag. With `--force-refresh`,
every request sent through this tool gets `X-Force-Refresh: true`.
Without the flag, behaviour is unchanged (cold-cache pre-warm).
Mechanical changes:
- `run_query` and `run_query_type` now accept an optional `headers`
kwarg threaded through to `requests.get`.
- `--force-refresh` argparse flag (default off).
- `request_headers = {'X-Force-Refresh': 'true'}` built once in
`main` and passed to every executor submit.
Rollout order:
1. owl_cache header-based-force-refresh branch -> merge -> redeploy.
2. This owlery-cache-reload PR -> merge -> redeploy.
3. Jenkins job: `python main.py --force-refresh` after each
tagged VFBquery push.
There was a problem hiding this comment.
Pull request overview
Adds an opt-in CLI switch to force an owl_cache refresh during the pre-warm pass by attaching a request header that instructs the cache to bypass and overwrite the canonical slot. This supports post–VFBquery-release rollouts where response shapes change and stale cached entries must be replaced without causing cold misses for end users.
Changes:
- Thread an optional
headerskwarg throughrun_query_type→run_query→requests.Session().get(...). - Add
--force-refreshargparse flag to enable sendingX-Force-Refresh: trueon every request. - Build request headers once in
main()and pass them to all submitted query jobs.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The existing pre-warm pass walks every (query_type, entity_id) tuple for the OWLERY + V3 endpoints and runs a GET against owl_cache (v3-cached.virtualflybrain.org for V3, owl.virtualflybrain.org for the legacy OWLERY queries). That's enough on first deploy when the cache is cold, but it does nothing for a refresh: the very first request after the wamup is served from the existing cache slot.
After a VFBquery release the deployed response shape may differ (new columns, fixed wire format, etc.). We need a way to force-fetch every entry from upstream and overwrite the canonical owl_cache slot, in the background, so end-users hitting v3-cached after the release get either a stale (previous-version) entry or a fresh (post-warmup) entry -- never a cold miss.
owl_cache's companion change adds:
with the pre-existing
proxy_cache_bypass $force_refreshand noproxy_no_cache-- so a request withX-Force-Refresh: truebypasses the cache for the fetch AND the upstream response then overwrites the canonical slot.This change adds the matching CLI flag. With
--force-refresh, every request sent through this tool getsX-Force-Refresh: true. Without the flag, behaviour is unchanged (cold-cache pre-warm).Mechanical changes:
run_queryandrun_query_typenow accept an optionalheaderskwarg threaded through torequests.get.--force-refreshargparse flag (default off).request_headers = {'X-Force-Refresh': 'true'}built once inmainand passed to every executor submit.Rollout order:
python main.py --force-refreshafter each tagged VFBquery push.