-
-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
access hydra config through ${hydra:key}
- Loading branch information
Showing
7 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
cwd: ${hydra:runtime.cwd} | ||
job_name: ${hydra:job.name} | ||
config_name: ${hydra:job.config_name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Hydra config can now be accessed through interpolation using ${hydra:key}, for example ${hydra:job.name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved | ||
from omegaconf import OmegaConf, open_dict | ||
from typing import Any | ||
|
||
from hydra._internal.config_loader_impl import ConfigLoaderImpl | ||
from hydra._internal.utils import create_config_search_path | ||
from hydra.core import utils | ||
from hydra.core.hydra_config import HydraConfig | ||
|
||
|
||
def test_foo(restore_singletons: Any) -> Any: | ||
utils.setup_globals() | ||
|
||
config_loader = ConfigLoaderImpl( | ||
config_search_path=create_config_search_path("pkg://hydra.test_utils.configs") | ||
) | ||
cfg = config_loader.load_configuration( | ||
config_name="accessing_hydra_config", overrides=[] | ||
) | ||
HydraConfig.instance().set_config(cfg) | ||
with open_dict(cfg): | ||
del cfg["hydra"] | ||
assert cfg.job_name == "UNKNOWN_NAME" | ||
assert cfg.config_name == "accessing_hydra_config" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters