diff --git a/src/hydra_plugins/anemoi_searchpath/anemoi_searchpath_plugin.py b/src/hydra_plugins/anemoi_searchpath/anemoi_searchpath_plugin.py index 173a629c..199c1a4b 100644 --- a/src/hydra_plugins/anemoi_searchpath/anemoi_searchpath_plugin.py +++ b/src/hydra_plugins/anemoi_searchpath/anemoi_searchpath_plugin.py @@ -1,3 +1,11 @@ +# (C) Copyright 2024 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. + import logging import os from pathlib import Path @@ -24,6 +32,7 @@ def manipulate_search_path(self, search_path: ConfigSearchPath) -> None: ---------- search_path : ConfigSearchPath Hydra ConfigSearchPath object. + """ for suffix in ("", "config"): anemoi_home_path = Path(Path.home(), ".config", "anemoi", "training", suffix) @@ -38,7 +47,7 @@ def manipulate_search_path(self, search_path: ConfigSearchPath) -> None: for suffix in ("", "config"): env_anemoi_config_path = os.getenv("ANEMOI_CONFIG_PATH") if env_anemoi_config_path is None: - return + continue anemoi_config_path = Path(env_anemoi_config_path) if anemoi_config_path.exists() and not Path(anemoi_config_path, "config").exists(): search_path.prepend( diff --git a/tests/hydra/test_search_path_plugins.py b/tests/hydra/test_search_path_plugins.py index f7be00dd..6bfb8ef4 100644 --- a/tests/hydra/test_search_path_plugins.py +++ b/tests/hydra/test_search_path_plugins.py @@ -1,26 +1,21 @@ +# (C) Copyright 2024 ECMWF. +# +# This software is licensed under the terms of the Apache Licence Version 2.0 +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. +# In applying this licence, ECMWF does not waive the privileges and immunities +# granted to it by virtue of its status as an intergovernmental organisation +# nor does it submit to any jurisdiction. + from hydra import initialize from hydra.core.global_hydra import GlobalHydra from hydra.core.plugins import Plugins from hydra.plugins.search_path_plugin import SearchPathPlugin - -from hydra_plugins.anemoi_searchpath.anemoi_searchpath_plugin import AnemoiEnvSearchPathPlugin -from hydra_plugins.anemoi_searchpath.anemoi_searchpath_plugin import AnemoiHomeSearchPathPlugin -from hydra_plugins.anemoi_searchpath.anemoi_searchpath_plugin import UserCWDSearchPathPlugin +from hydra_plugins.anemoi_searchpath.anemoi_searchpath_plugin import AnemoiSearchPathPlugin def test_anemoi_home_searchpath_discovery() -> None: # Tests that this plugin can be discovered via the plugins subsystem when looking at all Plugins - assert AnemoiHomeSearchPathPlugin.__name__ in [x.__name__ for x in Plugins.instance().discover(SearchPathPlugin)] - - -def test_anemoi_env_searchpath_discovery() -> None: - # Tests that this plugin can be discovered via the plugins subsystem when looking at all Plugins - assert AnemoiEnvSearchPathPlugin.__name__ in [x.__name__ for x in Plugins.instance().discover(SearchPathPlugin)] - - -def test_anemoi_cwd_searchpath_discovery() -> None: - # Tests that this plugin can be discovered via the plugins subsystem when looking at all Plugins - assert UserCWDSearchPathPlugin.__name__ in [x.__name__ for x in Plugins.instance().discover(SearchPathPlugin)] + assert AnemoiSearchPathPlugin.__name__ in [x.__name__ for x in Plugins.instance().discover(SearchPathPlugin)] def test_config_installed() -> None: