Skip to content

Commit

Permalink
Cleanup internal usage of HydraConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
omry committed Jan 26, 2021
1 parent 41c3119 commit 085e6d6
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 14 deletions.
Expand Up @@ -7,7 +7,6 @@

from hydra.core.config_loader import ConfigLoader
from hydra.core.config_store import ConfigStore
from hydra.core.hydra_config import HydraConfig
from hydra.core.singleton import Singleton
from hydra.core.utils import (
JobReturn,
Expand Down Expand Up @@ -101,7 +100,6 @@ def launch(
# but instead should be populated remotely before calling the task_function.
sweep_config.hydra.job.id = f"job_id_for_{idx}"
sweep_config.hydra.job.num = idx
HydraConfig.instance().set_config(sweep_config)

# If your launcher is executing code in a different process, it is important to restore
# the singleton state in the new process.
Expand Down
2 changes: 0 additions & 2 deletions hydra/_internal/core_plugins/basic_launcher.py
Expand Up @@ -8,7 +8,6 @@

from hydra.core.config_loader import ConfigLoader
from hydra.core.config_store import ConfigStore
from hydra.core.hydra_config import HydraConfig
from hydra.core.utils import (
JobReturn,
configure_log,
Expand Down Expand Up @@ -72,7 +71,6 @@ def launch(
with open_dict(sweep_config):
sweep_config.hydra.job.id = idx
sweep_config.hydra.job.num = idx
HydraConfig.instance().set_config(sweep_config)
ret = run_job(
config=sweep_config,
task_function=self.task_function,
Expand Down
3 changes: 0 additions & 3 deletions hydra/_internal/hydra.py
Expand Up @@ -13,7 +13,6 @@
from hydra._internal.utils import get_column_widths, run_and_report
from hydra.core.config_loader import ConfigLoader
from hydra.core.config_search_path import ConfigSearchPath
from hydra.core.hydra_config import HydraConfig
from hydra.core.plugins import Plugins
from hydra.core.utils import (
JobReturn,
Expand Down Expand Up @@ -104,7 +103,6 @@ def run(
with_log_configuration=with_log_configuration,
run_mode=RunMode.RUN,
)
HydraConfig.instance().set_config(cfg)

return run_job(
config=cfg,
Expand All @@ -129,7 +127,6 @@ def multirun(
with_log_configuration=with_log_configuration,
run_mode=RunMode.MULTIRUN,
)
HydraConfig.instance().set_config(cfg)

sweeper = Plugins.instance().instantiate_sweeper(
config=cfg, config_loader=self.config_loader, task_function=task_function
Expand Down
5 changes: 0 additions & 5 deletions plugins/hydra_ax_sweeper/tests/test_ax_sweeper_plugin.py
Expand Up @@ -5,7 +5,6 @@
from typing import Any, List

import pytest
from hydra.core.hydra_config import HydraConfig
from hydra.core.plugins import Plugins
from hydra.plugins.sweeper import Sweeper
from hydra.test_utils.test_utils import (
Expand Down Expand Up @@ -177,10 +176,6 @@ def test_configuration_set_via_cmd_and_default_config(
],
)
with sweep:
ax_config = HydraConfig.get().sweeper.ax_config
assert ax_config.max_trials == 2
assert ax_config.early_stop.max_epochs_without_improvement == 2
assert ax_config.experiment.minimize is True
assert sweep.returns is None
returns = OmegaConf.load(f"{sweep.temp_dir}/optimization_results.yaml")
assert isinstance(returns, DictConfig)
Expand Down
Expand Up @@ -7,7 +7,6 @@

import cloudpickle # type: ignore
import pickle5 as pickle # type: ignore
from hydra.core.hydra_config import HydraConfig
from hydra.core.singleton import Singleton
from hydra.core.utils import JobReturn, configure_log, filter_overrides, setup_globals
from omegaconf import OmegaConf, open_dict, read_write
Expand Down Expand Up @@ -108,7 +107,7 @@ def launch(
)

return launch_jobs(
launcher, local_tmp_dir, Path(HydraConfig.get().sweep.dir)
launcher, local_tmp_dir, Path(launcher.config.hydra.sweep.dir)
)


Expand Down

0 comments on commit 085e6d6

Please sign in to comment.