From f4fe48442992defef7c2ddd0a6d014e3c371a073 Mon Sep 17 00:00:00 2001 From: jesszzzz Date: Wed, 7 Aug 2024 13:23:46 -0400 Subject: [PATCH] Use latest configstore singleton instead of storing it (#2928) * Use latest configstore singleton instead of storing it * add news file --- .../_internal/core_plugins/structured_config_source.py | 10 ++++------ news/2928.bugfix | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 news/2928.bugfix diff --git a/hydra/_internal/core_plugins/structured_config_source.py b/hydra/_internal/core_plugins/structured_config_source.py index 1817032b408..6e4f457c95e 100644 --- a/hydra/_internal/core_plugins/structured_config_source.py +++ b/hydra/_internal/core_plugins/structured_config_source.py @@ -9,12 +9,10 @@ class StructuredConfigSource(ConfigSource): - store: ConfigStore def __init__(self, provider: str, path: str) -> None: super().__init__(provider=provider, path=path) # Import the module, the __init__ there is expected to register the configs. - self.store = ConfigStore.instance() if self.path != "": try: importlib.import_module(self.path) @@ -30,7 +28,7 @@ def scheme() -> str: def load_config(self, config_path: str) -> ConfigResult: normalized_config_path = self._normalize_file_name(config_path) - ret = self.store.load(config_path=normalized_config_path) + ret = ConfigStore.instance().load(config_path=normalized_config_path) provider = ret.provider if ret.provider is not None else self.provider header = {"package": ret.package} return ConfigResult( @@ -44,17 +42,17 @@ def available(self) -> bool: return True def is_group(self, config_path: str) -> bool: - type_ = self.store.get_type(config_path.rstrip("/")) + type_ = ConfigStore.instance().get_type(config_path.rstrip("/")) return type_ == ObjectType.GROUP def is_config(self, config_path: str) -> bool: filename = self._normalize_file_name(config_path.rstrip("/")) - type_ = self.store.get_type(filename) + type_ = ConfigStore.instance().get_type(filename) return type_ == ObjectType.CONFIG def list(self, config_path: str, results_filter: Optional[ObjectType]) -> List[str]: ret: List[str] = [] - files = self.store.list(config_path) + files = ConfigStore.instance().list(config_path) for file in files: self._list_add_result( diff --git a/news/2928.bugfix b/news/2928.bugfix new file mode 100644 index 00000000000..c8544ff89be --- /dev/null +++ b/news/2928.bugfix @@ -0,0 +1 @@ +Fix StructuredConfigStore using old singleton copy when using lazy imports