CachedNodeNorm / CachedNameRes were designed for a single pytest run, but as library components (see #95 / #96) they have two rough edges for long-lived consumers like the Babel Explorer Streamlit app:
-
Process-global registries with unbounded per-instance caches. from_url() caches one instance per URL in a module-level dict (cached_node_norms_by_url / cached_nameres_by_url), and each instance's self.cache never evicts. A Streamlit app comparing many endpoints/queries over a long session accumulates results indefinitely, and the global registry means a "fresh" lookup can return a stale cached value after the underlying data changes (e.g. re-running against the same endpoint after a redeploy).
- Proposal: offer a way to construct a non-shared instance, and/or a
clear() method / max-size or TTL eviction. Keep from_url() as the convenient default.
-
Hardcoded 30s request timeout. Fine for CI, but a UI may want a shorter timeout (fail fast) or a consumer may want retries.
- Proposal: make
timeout a constructor/parameter, optionally with a simple retry policy.
Neither is a blocker for the current consumers, but both would make the service clients safer to embed in a long-running process.
Filed as a follow-up to the library carve-out (#67).
CachedNodeNorm/CachedNameReswere designed for a single pytest run, but as library components (see #95 / #96) they have two rough edges for long-lived consumers like the Babel Explorer Streamlit app:Process-global registries with unbounded per-instance caches.
from_url()caches one instance per URL in a module-level dict (cached_node_norms_by_url/cached_nameres_by_url), and each instance'sself.cachenever evicts. A Streamlit app comparing many endpoints/queries over a long session accumulates results indefinitely, and the global registry means a "fresh" lookup can return a stale cached value after the underlying data changes (e.g. re-running against the same endpoint after a redeploy).clear()method / max-size or TTL eviction. Keepfrom_url()as the convenient default.Hardcoded 30s request timeout. Fine for CI, but a UI may want a shorter timeout (fail fast) or a consumer may want retries.
timeouta constructor/parameter, optionally with a simple retry policy.Neither is a blocker for the current consumers, but both would make the service clients safer to embed in a long-running process.
Filed as a follow-up to the library carve-out (#67).