Skip to content

Commit bc00423

Browse files
committed
force_refresh: propagate through unwrapped @with_solr_cache decorators
v1.12.9 added force_refresh URL parsing in handle_run_query and a signature check in _run_query, but the check was looking for a 'force_refresh' parameter by name. The @with_solr_cache decorator in solr_result_cache.py defines its wrapper as 'def wrapper(*args, **kwargs)' without @functools.wraps, so inspect.signature(get_instances) returns the wrapper's signature — no 'force_refresh' parameter visible — and the kwarg was never forwarded. The SOLR-side cache kept serving the stale 0 entry for FBbt_00007484 regardless of URL flag, even after container restart. Two fixes: 1. ha_api._run_query: also pass force_refresh when the function accepts **kwargs (VAR_KEYWORD parameter kind). The @with_solr_cache wrapper pops force_refresh off kwargs before delegating to the inner function, so this is safe even when the underlying function doesn't itself declare the parameter. 2. solr_result_cache.with_solr_cache: add @functools.wraps(func) so the decorated function's signature, name, qualname and docstring are preserved. Future introspection (and tooling like Sphinx) will then see the inner function's parameters as expected. Verified path: URL ?force_refresh=true -> handle_run_query parses it, invalidates rcache entry -> _run_query sees VAR_KEYWORD in fn signature, adds to kwargs -> wrapper(*args, **kwargs) pops force_refresh, clears its SOLR entry -> inner get_instances recomputes from Owlery+Neo4j (~31,499 rows for FBbt_00007484) and the wrapper writes the fresh result back.
1 parent b37f7bd commit bc00423

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/vfbquery/ha_api.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,18 @@ def _run_query(short_form, func_name, force_refresh=False):
358358
if force_refresh:
359359
try:
360360
import inspect
361-
if "force_refresh" in inspect.signature(fn).parameters:
361+
params = inspect.signature(fn).parameters
362+
# Pass force_refresh either when the function names it directly
363+
# OR when it accepts **kwargs (which is what the
364+
# @with_solr_cache wrapper does — it pops `force_refresh` off
365+
# kwargs before calling the inner function). Without the **kwargs
366+
# check we miss every decorated function, because the wrapper has
367+
# signature (*args, **kwargs) — no `force_refresh` parameter
368+
# name — and the SOLR cache keeps serving stale entries.
369+
accepts_kwargs = any(
370+
p.kind == inspect.Parameter.VAR_KEYWORD for p in params.values()
371+
)
372+
if "force_refresh" in params or accepts_kwargs:
362373
kwargs["force_refresh"] = True
363374
except (TypeError, ValueError):
364375
# builtins / C functions have no introspectable signature; skip.

src/vfbquery/solr_result_cache.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Neo4j queries and data processing.
1111
"""
1212

13+
import functools
1314
import json
1415
import os
1516
import re
@@ -765,6 +766,7 @@ def get_term_info(short_form, force_refresh=False, **kwargs):
765766
The decorated function can accept a 'force_refresh' parameter to bypass cache.
766767
"""
767768
def decorator(func):
769+
@functools.wraps(func)
768770
def wrapper(*args, **kwargs):
769771
# Check if force_refresh is requested (pop it before passing to function)
770772
force_refresh = kwargs.pop('force_refresh', False)

0 commit comments

Comments
 (0)