Esempio n. 1
0
def compose(
    config_file: Optional[str] = None,
    overrides: List[str] = [],
    strict: Optional[bool] = None,
) -> DictConfig:
    """
    :param config_file: optional config file to load
    :param overrides: list of overrides for config file
    :param strict: optionally override the default strict mode
    :return: the composed config
    """
    assert (
        GlobalHydra().is_initialized()
    ), "GlobalHydra is not initialized, use @hydra.main() or call hydra.experimental.initialize() first"

    gh = GlobalHydra.instance()
    assert gh.hydra is not None
    cfg = gh.hydra.compose_config(config_file=config_file,
                                  overrides=overrides,
                                  strict=strict)
    assert isinstance(cfg, DictConfig)

    if "hydra" in cfg:
        del cfg["hydra"]
    return cfg
Esempio n. 2
0
def test_initialize_with_config_dir() -> None:
    try:
        assert not GlobalHydra().is_initialized()
        hydra.experimental.initialize(config_dir="../hydra/test_utils/configs",
                                      strict=True)
        assert GlobalHydra().is_initialized()

        config_search_path = (
            GlobalHydra.instance().hydra.config_loader.config_search_path)
        idx = config_search_path.find_first_match(
            SearchPath(provider="main", search_path=None))
        assert idx != -1
    finally:
        GlobalHydra().clear()
Esempio n. 3
0
def test_config_installed(
        hydra_global_context: TGlobalHydraContext,  # noqa: F811
) -> None:
    """
    Tests that color options are available for both hydra/hydra_logging and hydra/job_logging
    """

    with hydra_global_context(
            config_dir="../hydra_plugins/hydra_colorlog/conf"):
        config_loader = GlobalHydra.instance().hydra.config_loader
        assert "colorlog" in config_loader.get_group_options(
            "hydra/job_logging")
        assert "colorlog" in config_loader.get_group_options(
            "hydra/hydra_logging")