Skip to content

Commit

Permalink
Windows compatibility:
Browse files Browse the repository at this point in the history
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
  • Loading branch information
omry committed Aug 17, 2019
1 parent f52431a commit a9d06fc
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ __pycache__
*.egg-info
.nox
report.json
.coverage
.coverage
pip-wheel-metadata
3 changes: 2 additions & 1 deletion hydra/_internal/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion hydra/plugins/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 3 additions & 1 deletion hydra/test_utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import subprocess
import sys
import tempfile

import logging
import pytest
import six
from omegaconf import OmegaConf
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions news/63.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Override_dirname separator changed from : to =, for example: foo/a:10,b:10 => foo/a=10,b=10
1 change: 1 addition & 0 deletions news/63.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hydra is now compatible with Windows
2 changes: 1 addition & 1 deletion tests/test_demos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def test_custom_task_name(
),
{},
["a=1", "b=2"],
"foo-a:1,b:2",
"foo-a=1,b=2",
),
],
)
Expand Down Expand Up @@ -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",
),
],
)
Expand Down

0 comments on commit a9d06fc

Please sign in to comment.