update screenshot
This commit is contained in:
+9
-20
@@ -228,23 +228,18 @@ class SharedArgs:
|
||||
if not force and hasattr(SharedArgs, "_cached_available_stores"):
|
||||
return SharedArgs._cached_available_stores or []
|
||||
|
||||
# Refresh the cache. When not forcing, prefer a lightweight configured-name
|
||||
# pass to avoid instantiating backends (which may perform work such as opening DBs).
|
||||
if not force:
|
||||
SharedArgs._refresh_store_choices_cache(config, skip_instantiation=True)
|
||||
else:
|
||||
SharedArgs._refresh_store_choices_cache(config, skip_instantiation=False)
|
||||
# Autocomplete and shared arg choices must only expose backends that actually
|
||||
# initialized successfully. Do a full refresh when the cache is missing.
|
||||
SharedArgs._refresh_store_choices_cache(config, skip_instantiation=False)
|
||||
return SharedArgs._cached_available_stores or []
|
||||
|
||||
@staticmethod
|
||||
def _refresh_store_choices_cache(config: Optional[Dict[str, Any]] = None, skip_instantiation: bool = False) -> None:
|
||||
"""Refresh the cached store choices list. Should be called once at startup.
|
||||
|
||||
This performs a lightweight pass first (reads configured names only, without
|
||||
instantiating backend classes) to avoid side-effects during autocompletion or
|
||||
other quick lookups. When `skip_instantiation` is False, the function will
|
||||
attempt a full StoreRegistry initialization to filter out backends that failed
|
||||
to initialize properly.
|
||||
Store choices are user-facing and should only include backends that actually
|
||||
initialized successfully. When `skip_instantiation` is True, this method keeps
|
||||
the cache empty rather than surfacing configured-but-disabled store names.
|
||||
|
||||
Args:
|
||||
config: Config dict. If not provided, will try to load from config module.
|
||||
@@ -259,15 +254,10 @@ class SharedArgs:
|
||||
SharedArgs._cached_available_stores = []
|
||||
return
|
||||
|
||||
# Lightweight pass: return configured names without instantiating backends
|
||||
try:
|
||||
from Store.registry import list_configured_backend_names
|
||||
SharedArgs._cached_available_stores = list_configured_backend_names(config) or []
|
||||
except Exception:
|
||||
SharedArgs._cached_available_stores = []
|
||||
SharedArgs._cached_available_stores = []
|
||||
|
||||
# If caller explicitly requested a full scan, instantiate registry to get
|
||||
# only backends that actually initialized successfully.
|
||||
# If caller requested a lightweight pass, avoid exposing configured names
|
||||
# that may be disabled or unavailable.
|
||||
if skip_instantiation:
|
||||
return
|
||||
|
||||
@@ -278,7 +268,6 @@ class SharedArgs:
|
||||
if available:
|
||||
SharedArgs._cached_available_stores = available
|
||||
except Exception:
|
||||
# Keep the lightweight list if full initialization fails
|
||||
pass
|
||||
except Exception:
|
||||
SharedArgs._cached_available_stores = []
|
||||
|
||||
Reference in New Issue
Block a user