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 25, 2024
1 parent 7ccf653 commit 2268c90
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 96 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
2 changes: 1 addition & 1 deletion hydra/test_utils/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __enter__(self) -> "TaskTestFunction":
self.temp_dir = tempfile.mkdtemp()
overrides = copy.deepcopy(self.overrides)
assert overrides is not None
overrides.append(f"hydra.run.dir={self.temp_dir}")
overrides.append(f'hydra.run.dir="{self.temp_dir}"')
self.job_ret = self.hydra.run(
config_name=self.config_name,
task_function=self,
Expand Down
12 changes: 6 additions & 6 deletions plugins/hydra_ax_sweeper/tests/test_ax_sweeper_plugin.py
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion tests/test_basic_sweeper.py
Original file line number Diff line number Diff line change
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
8 changes: 4 additions & 4 deletions tests/test_callbacks.py
Original file line number Diff line number Diff line change
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)
2 changes: 1 addition & 1 deletion tests/test_examples/test_advanced_config_search_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tests/test_examples/test_advanced_package_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
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
2 changes: 1 addition & 1 deletion tests/test_examples/test_basic_sweep.py
Original file line number Diff line number Diff line change
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
12 changes: 6 additions & 6 deletions tests/test_examples/test_instantiate_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions tests/test_examples/test_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_specializing_config_example(
def test_write_protect_config_node(tmpdir: Any) -> None:
cmd = [
"examples/patterns/write_protect_config_node/frozen.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"data_bits=10",
]
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_extending_configs(
monkeypatch.chdir("examples/patterns/extending_configs")
cmd = [
"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 @@ -112,7 +112,7 @@ def test_configuring_experiments(
monkeypatch.chdir("examples/patterns/configuring_experiments")
cmd = [
"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 @@ -183,7 +183,7 @@ def test_multi_select(
monkeypatch.chdir("examples/patterns/multi-select")
cmd = [
"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
18 changes: 9 additions & 9 deletions tests/test_examples/test_structured_configs_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_1_basic_run(tmpdir: Path) -> None:
result, _err = run_python_script(
[
"examples/tutorials/structured_configs/1_minimal/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
)
Expand All @@ -37,7 +37,7 @@ def test_1_basic_run_with_override_error(tmpdir: Path) -> None:
err = run_with_error(
[
"examples/tutorials/structured_configs/1_minimal/my_app_type_error.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
)
Expand All @@ -48,7 +48,7 @@ def test_1_basic_override(tmpdir: Path) -> None:
result, _err = run_python_script(
[
"examples/tutorials/structured_configs/1_minimal/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"port=9090",
]
Expand All @@ -59,7 +59,7 @@ def test_1_basic_override(tmpdir: Path) -> None:
def test_1_basic_override_type_error(tmpdir: Path) -> None:
cmd = [
"examples/tutorials/structured_configs/1_minimal/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
"port=foo",
]
Expand All @@ -79,7 +79,7 @@ def test_2_static_complex(tmpdir: Path) -> None:
result, _err = run_python_script(
[
"examples/tutorials/structured_configs/2_static_complex/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
)
Expand All @@ -99,7 +99,7 @@ def test_2_static_complex(tmpdir: Path) -> None:
def test_3_config_groups(tmpdir: Path, overrides: Any, expected: Any) -> None:
cmd = [
"examples/tutorials/structured_configs/3_config_groups/my_app.py",
"hydra.run.dir=" + str(tmpdir),
f'hydra.run.dir="{str(tmpdir)}"',
"hydra.job.chdir=True",
]
cmd.extend(overrides)
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_3_config_groups_with_inheritance(
) -> None:
cmd = [
"examples/tutorials/structured_configs/3_config_groups/my_app_with_inheritance.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 @@ -145,7 +145,7 @@ def test_3_config_groups_with_inheritance(
def test_4_defaults(tmpdir: Path) -> None:
cmd = [
"examples/tutorials/structured_configs/4_defaults/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 @@ -168,7 +168,7 @@ def test_4_defaults(tmpdir: Path) -> None:
],
)
def test_5_structured_config_schema(tmpdir: Path, path: str) -> None:
cmd = [path, "hydra.run.dir=" + str(tmpdir), "hydra.job.chdir=True"]
cmd = [path, f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True"]
result, _err = run_python_script(cmd)
assert OmegaConf.create(result) == {
"db": {
Expand Down
Loading

0 comments on commit 2268c90

Please sign in to comment.