Skip to content

Make CachedNodeNorm/CachedNameRes caches scopable and timeouts configurable for long-lived consumers #98

Description

@gaurav

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:

  1. 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.
  2. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions