Skip to content

Commit

Permalink
Use latest configstore singleton instead of storing it (facebookresea…
Browse files Browse the repository at this point in the history
…rch#2928)

* Use latest configstore singleton instead of storing it

* add news file
  • Loading branch information
jesszzzz authored Aug 7, 2024
1 parent 6557a93 commit f4fe484
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 4 additions & 6 deletions hydra/_internal/core_plugins/structured_config_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions news/2928.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix StructuredConfigStore using old singleton copy when using lazy imports

0 comments on commit f4fe484

Please sign in to comment.