From a9d06fca65c612bc0eb62a291a3d082587d903b4 Mon Sep 17 00:00:00 2001 From: omry Date: Sat, 17 Aug 2019 09:24:42 -0700 Subject: [PATCH] Windows compatibility: 1. Paths in get_load_history are now normalized to be identical between Windows and Unix 2. override dirname separator changes from : to = 3. Task tests are now shutting down logging to allow the output directory to be deleted fixes #63 --- .gitignore | 3 ++- hydra/_internal/config_loader.py | 3 ++- hydra/plugins/common/utils.py | 2 +- hydra/test_utils/test_utils.py | 4 +++- news/63.bugfix | 1 + news/63.feature | 1 + tests/test_demos.py | 2 +- tests/test_integration.py | 4 ++-- 8 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 news/63.bugfix create mode 100644 news/63.feature diff --git a/.gitignore b/.gitignore index ffc31068aa9..fcff79a3f22 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ __pycache__ *.egg-info .nox report.json -.coverage \ No newline at end of file +.coverage +pip-wheel-metadata \ No newline at end of file diff --git a/hydra/_internal/config_loader.py b/hydra/_internal/config_loader.py index d7a678c20db..3d47e44f879 100644 --- a/hydra/_internal/config_loader.py +++ b/hydra/_internal/config_loader.py @@ -72,6 +72,7 @@ def _find_config(self, filepath, including_config_dir): else: config_file = os.path.join(path, filepath) + config_file = config_file.replace('\\', '/') if self._exists(is_pkg, config_file): return prefix + config_file return None @@ -190,7 +191,7 @@ def _load_config_impl(self, input_file, including_config_dir): loaded_cfg = None filename = self._find_config(input_file, including_config_dir) if filename is None: - self.all_config_checked.append((input_file, False)) + self.all_config_checked.append((input_file.replace('\\', '/'), False)) else: is_pkg = filename.startswith("pkg://") if is_pkg: diff --git a/hydra/plugins/common/utils.py b/hydra/plugins/common/utils.py index 3823dccf71a..87ab55ce26b 100644 --- a/hydra/plugins/common/utils.py +++ b/hydra/plugins/common/utils.py @@ -44,7 +44,7 @@ def save_config(cfg, filename): def get_overrides_dirname(lst, exclude_keys=[]): lst = [x for x in lst if x not in exclude_keys] lst.sort() - return re.sub(pattern="[=]", repl=":", string=",".join(lst)) + return re.sub(pattern="[=]", repl="=", string=",".join(lst)) def filter_overrides(overrides): diff --git a/hydra/test_utils/test_utils.py b/hydra/test_utils/test_utils.py index c7a5b71c306..c2a64eeba91 100644 --- a/hydra/test_utils/test_utils.py +++ b/hydra/test_utils/test_utils.py @@ -10,7 +10,7 @@ import subprocess import sys import tempfile - +import logging import pytest import six from omegaconf import OmegaConf @@ -76,6 +76,8 @@ def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): + # release log file handles + logging.shutdown() shutil.rmtree(self.temp_dir) def _(conf_dir, conf_filename=None, overrides=None, strict=False): diff --git a/news/63.bugfix b/news/63.bugfix new file mode 100644 index 00000000000..67a142694cf --- /dev/null +++ b/news/63.bugfix @@ -0,0 +1 @@ +Override_dirname separator changed from : to =, for example: foo/a:10,b:10 => foo/a=10,b=10 \ No newline at end of file diff --git a/news/63.feature b/news/63.feature new file mode 100644 index 00000000000..144c89114b6 --- /dev/null +++ b/news/63.feature @@ -0,0 +1 @@ +Hydra is now compatible with Windows \ No newline at end of file diff --git a/tests/test_demos.py b/tests/test_demos.py index 731470e52bc..ce2ea1823ce 100644 --- a/tests/test_demos.py +++ b/tests/test_demos.py @@ -134,7 +134,7 @@ def test_demo_1_workdir(tmpdir): "hydra.run.dir=" + str(tmpdir), ] result = subprocess.check_output(cmd) - assert result.decode("utf-8") == "Working directory : {}\n".format(tmpdir) + assert result.decode("utf-8").rstrip() == "Working directory : {}".format(tmpdir) @pytest.mark.parametrize( diff --git a/tests/test_integration.py b/tests/test_integration.py index 74f95046425..bfce8894afe 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -174,7 +174,7 @@ def test_custom_task_name( ), {}, ["a=1", "b=2"], - "foo-a:1,b:2", + "foo-a=1,b=2", ), ], ) @@ -294,7 +294,7 @@ def test_custom_local_run_workdir( }, {}, ["a=1", "b=2"], - "hydra_cfg/a:1,b:2", + "hydra_cfg/a=1,b=2", ), ], )