From dc6db48e149df37cafecc426454937643287f725 Mon Sep 17 00:00:00 2001 From: Jieru Hu Date: Wed, 20 Jan 2021 11:34:32 -0800 Subject: [PATCH] local imports --- hydra/core/singleton.py | 8 ++++++++ .../tests/test_ray_aws_launcher.py | 17 +---------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/hydra/core/singleton.py b/hydra/core/singleton.py index d184a4e29a2..2b7fcb3f22f 100644 --- a/hydra/core/singleton.py +++ b/hydra/core/singleton.py @@ -18,6 +18,12 @@ def instance(cls: Any, *args: Any, **kwargs: Any) -> Any: @staticmethod def get_state() -> Any: + try: + from hydra.core.plugins import Plugins + + del Singleton._instances[Plugins] + except KeyError: + pass return { "instances": Singleton._instances, "omegaconf_resolvers": deepcopy(BaseContainer._resolvers), @@ -26,4 +32,6 @@ def get_state() -> Any: @staticmethod def set_state(state: Any) -> None: Singleton._instances = state["instances"] + from hydra.core.plugins import Plugins + Plugins.instance() BaseContainer._resolvers = deepcopy(state["omegaconf_resolvers"]) diff --git a/plugins/hydra_ray_launcher/tests/test_ray_aws_launcher.py b/plugins/hydra_ray_launcher/tests/test_ray_aws_launcher.py index 9418a9342c5..34c3473d06d 100644 --- a/plugins/hydra_ray_launcher/tests/test_ray_aws_launcher.py +++ b/plugins/hydra_ray_launcher/tests/test_ray_aws_launcher.py @@ -108,22 +108,7 @@ chdir_plugin_root() -def build_ray_launcher_wheel(tmpdir: str) -> str: - """ - This only works on ray launcher plugin wheels for now, reasons being in our base AMI - we do not necessarily have the dependency for other plugins. - """ - command = "python -m pip --disable-pip-version-check list | grep hydra | grep -v hydra-core " - output = subprocess.getoutput(command).split("\n") - plugins_path = [x.split()[0].replace("-", "_") for x in output] - assert ( - len(plugins_path) == 1 and "hydra_ray_launcher" == plugins_path[0] - ), "Ray test AMI doesn't have dependency installed for other plugins." - - return build_plugin_wheel(tmpdir) - - -def build_plugin_wheel(tmp_wheel_dir: str) -> str: +def build_ray_launcher_wheel(tmp_wheel_dir: str) -> str: chdir_hydra_root() plugin = "hydra_ray_launcher" os.chdir(Path("plugins") / plugin)