Skip to content

Commit

Permalink
Fix windows tests failing due to ~ in directory
Browse files Browse the repository at this point in the history
  • Loading branch information
jesszzzz committed Oct 24, 2024
1 parent 7ccf653 commit 6f3d326
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_python_run(self, tmpdir: str) -> None:
[
sys.executable,
"hydra_app/main.py",
f"hydra.run.dir={tmpdir}",
f'hydra.run.dir="{tmpdir}"',
"app.user=test_user",
]
)
Expand All @@ -26,7 +26,7 @@ def test_python_run(self, tmpdir: str) -> None:
def test_installed_run(self, tmpdir: str) -> None:
self.verify_output(
subprocess.check_output(
["hydra_app", f"hydra.run.dir={tmpdir}", "app.user=test_user"]
["hydra_app", f'hydra.run.dir="{tmpdir}"', "app.user=test_user"]
)
)

Expand Down
18 changes: 9 additions & 9 deletions plugins/hydra_ax_sweeper/tests/test_ax_sweeper_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from hydra.core.plugins import Plugins
from hydra.plugins.sweeper import Sweeper
from hydra.test_utils.test_utils import (
TSweepRunner,
chdir_plugin_root,
run_python_script,
TSweepRunner,
)
from omegaconf import DictConfig, OmegaConf
from pytest import mark, raises

from hydra_plugins.hydra_ax_sweeper.ax_sweeper import AxSweeper
from omegaconf import DictConfig, OmegaConf
from pytest import mark, raises

chdir_plugin_root()

Expand Down Expand Up @@ -216,7 +216,7 @@ def test_ax_logging(tmpdir: Path, cmd_arg: str, expected_str: str) -> None:
cmd = [
"tests/apps/polynomial.py",
"-m",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"polynomial.x=interval(-5, -2)",
"polynomial.z=10",
Expand All @@ -239,7 +239,7 @@ def test_search_space_exhausted_exception(tmpdir: Path, cmd_args: List[str]) ->
cmd = [
"tests/apps/polynomial.py",
"-m",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"hydra.sweeper.ax_config.max_trials=2",
] + cmd_args
Expand All @@ -260,7 +260,7 @@ def test_search_space_with_constraint_metric(tmpdir: Path, cmd_args: List[str])
cmd = [
"tests/apps/polynomial_with_constraint.py",
"-m",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"hydra.sweeper.ax_config.max_trials=2",
] + cmd_args
Expand Down Expand Up @@ -294,7 +294,7 @@ def test_jobs_using_choice_between_lists(
cmd = [
"tests/apps/polynomial_with_list_coefficients.py",
"-m",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"hydra.sweeper.ax_config.max_trials=3",
] + [cmd_arg]
Expand Down Expand Up @@ -331,7 +331,7 @@ def test_jobs_using_choice_between_dicts(
cmd = [
"tests/apps/polynomial_with_dict_coefficients.py",
"-m",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"hydra.sweeper.ax_config.max_trials=3",
] + [cmd_arg]
Expand All @@ -345,7 +345,7 @@ def test_example_app(tmpdir: Path) -> None:
cmd = [
"example/banana.py",
"-m",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"banana.x=int(interval(-5, 5))",
"banana.y=interval(-5, 10.1)",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_basic_sweeper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from textwrap import dedent
from typing import Any, List, Optional

from pytest import mark, param

from hydra._internal.core_plugins.basic_sweeper import BasicSweeper
from hydra.core.override_parser.overrides_parser import OverridesParser
from hydra.test_utils.test_utils import assert_multiline_regex_search, run_process

from pytest import mark, param


@mark.parametrize(
"args,max_batch_size,expected",
Expand Down Expand Up @@ -70,7 +70,7 @@ def test_partial_failure(
"tests/test_apps/app_can_fail/my_app.py",
"--multirun",
"+divisor=1,0",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"hydra.hydra_logging.formatters.simple.format='[HYDRA] %(message)s'",
]
Expand Down
14 changes: 7 additions & 7 deletions tests/test_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
from textwrap import dedent
from typing import Any, List

from omegaconf import open_dict, read_write
from pytest import mark, param

from hydra.core.utils import JobReturn, JobStatus
from hydra.test_utils.test_utils import (
assert_regex_match,
Expand All @@ -18,6 +15,9 @@
run_python_script,
)

from omegaconf import open_dict, read_write
from pytest import mark, param

chdir_hydra_root()


Expand Down Expand Up @@ -98,7 +98,7 @@ def test_app_with_callbacks(
) -> None:
cmd = [
app_path,
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"hydra.hydra_logging.formatters.simple.format='[HYDRA] %(message)s'",
"hydra.job_logging.formatters.simple.format='[JOB] %(message)s'",
Expand All @@ -120,7 +120,7 @@ def test_experimental_save_job_info_callback(tmpdir: Path, multirun: bool) -> No

cmd = [
app_path,
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.sweep.dir=" + str(tmpdir),
"hydra.job.chdir=True",
]
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_save_job_return_callback(tmpdir: Path, multirun: bool) -> None:
cmd = [
sys.executable,
app_path,
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.sweep.dir=" + str(tmpdir),
"hydra.job.chdir=True",
]
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_experimental_rerun(

cmd = [
app_path,
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.sweep.dir=" + str(tmpdir),
"hydra.job.chdir=False",
"hydra.hydra_logging.formatters.simple.format='[HYDRA] %(message)s'",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_env_defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def test_env_defaults(tmpdir: Path) -> None:
cmd = [
"tests/test_apps/custom_env_defaults/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
run_python_script(cmd)
8 changes: 4 additions & 4 deletions tests/test_examples/test_advanced_config_search_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from pathlib import Path
from typing import List, Optional

from omegaconf import OmegaConf
from pytest import mark

from hydra.test_utils.test_utils import (
chdir_hydra_root,
run_python_script,
run_with_error,
)

from omegaconf import OmegaConf
from pytest import mark

chdir_hydra_root()


Expand All @@ -36,7 +36,7 @@ def test_config_search_path(
) -> None:
cmd = [
"examples/advanced/config_search_path/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
cmd.extend(args)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_examples/test_advanced_package_overrides.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
from pathlib import Path

from omegaconf import OmegaConf

from hydra.test_utils.test_utils import chdir_hydra_root, run_python_script

from omegaconf import OmegaConf

chdir_hydra_root()


def test_advanced_package_override_simple(tmpdir: Path) -> None:
cmd = [
"examples/advanced/package_overrides/simple.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
result, _err = run_python_script(cmd)
Expand All @@ -23,7 +23,7 @@ def test_advanced_package_override_simple(tmpdir: Path) -> None:
def test_advanced_package_override_two_packages(tmpdir: Path) -> None:
cmd = [
"examples/advanced/package_overrides/two_packages.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
result, _err = run_python_script(cmd)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_examples/test_basic_sweep.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from textwrap import dedent
from typing import List

from pytest import mark

from hydra.test_utils.test_utils import (
assert_regex_match,
chdir_hydra_root,
run_python_script,
)

from pytest import mark

chdir_hydra_root()


Expand Down Expand Up @@ -70,7 +70,7 @@ def test_basic_sweep_example(
cmd = [
app_path,
"--multirun",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"hydra.hydra_logging.formatters.simple.format='[HYDRA] %(message)s'",
"hydra.job_logging.formatters.simple.format='[JOB] %(message)s'",
Expand Down
10 changes: 5 additions & 5 deletions tests/test_examples/test_configure_hydra.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_custom_help(tmpdir: Path) -> None:
result, _err = run_python_script(
[
"examples/configure_hydra/custom_help/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"--help",
]
Expand Down Expand Up @@ -55,7 +55,7 @@ def test_custom_help(tmpdir: Path) -> None:
def test_job_name_no_config_override(tmpdir: Path) -> None:
cmd = [
"examples/configure_hydra/job_name/no_config_file_override.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
result, _err = run_python_script(cmd)
Expand All @@ -65,7 +65,7 @@ def test_job_name_no_config_override(tmpdir: Path) -> None:
def test_job_name_with_config_override(tmpdir: Path) -> None:
cmd = [
"examples/configure_hydra/job_name/with_config_file_override.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
result, _err = run_python_script(cmd)
Expand All @@ -90,7 +90,7 @@ def test_job_override_dirname(tmpdir: Path) -> None:
def test_logging(tmpdir: Path) -> None:
cmd = [
"examples/configure_hydra/logging/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
result, _err = run_python_script(cmd)
Expand All @@ -100,7 +100,7 @@ def test_logging(tmpdir: Path) -> None:
def test_disabling_logging(tmpdir: Path) -> None:
cmd = [
"examples/configure_hydra/logging/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"hydra/job_logging=none",
"hydra/hydra_logging=none",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_examples/test_experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def test_rerun(tmpdir: Path) -> None:
cmd = [
"examples/experimental/rerun/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"hydra.hydra_logging.formatters.simple.format='[HYDRA] %(message)s'",
"hydra.job_logging.formatters.simple.format='[JOB] %(message)s'",
Expand Down
16 changes: 8 additions & 8 deletions tests/test_examples/test_instantiate_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from textwrap import dedent
from typing import List

from pytest import mark, param

from hydra.test_utils.test_utils import (
assert_text_same,
chdir_hydra_root,
run_python_script,
)

from pytest import mark, param

chdir_hydra_root()


Expand All @@ -24,7 +24,7 @@
def test_instantiate_object(tmpdir: Path, overrides: List[str], output: str) -> None:
cmd = [
"examples/instantiate/object/my_app.py",
f"hydra.run.dir={tmpdir}",
f'hydra.run.dir="{tmpdir}"',
"hydra.job.chdir=True",
] + overrides
result, _err = run_python_script(cmd)
Expand All @@ -46,7 +46,7 @@ def test_instantiate_object_recursive(
) -> None:
cmd = [
"examples/instantiate/object_recursive/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
] + overrides
result, _err = run_python_script(cmd)
Expand All @@ -56,7 +56,7 @@ def test_instantiate_object_recursive(
def test_instantiate_object_partial(tmpdir: Path) -> None:
cmd = [
"examples/instantiate/partial/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
result, _err = run_python_script(cmd)
Expand All @@ -73,7 +73,7 @@ def test_instantiate_object_partial(tmpdir: Path) -> None:
def test_instantiate_schema(tmpdir: Path, overrides: List[str], output: str) -> None:
cmd = [
"examples/instantiate/schema/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
] + overrides
result, _err = run_python_script(cmd)
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_instantiate_schema_recursive(
) -> None:
cmd = [
"examples/instantiate/schema_recursive/my_app.py",
f"hydra.run.dir={tmpdir}",
f'hydra.run.dir="{tmpdir}"',
"hydra.job.chdir=True",
] + overrides
result, _err = run_python_script(cmd)
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_instantiate_docs_example(
) -> None:
cmd = [
"examples/instantiate/docs_example/my_app.py",
f"hydra.run.dir={tmpdir}",
f'hydra.run.dir="{tmpdir}"',
"hydra.job.chdir=True",
] + overrides
result, _err = run_python_script(cmd)
Expand Down
Loading

0 comments on commit 6f3d326

Please sign in to comment.