Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop py3.7 & fix CI #2854

Merged
merged 8 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions hydra/experimental/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(
config_path=config_path,
job_name=job_name,
caller_stack_depth=caller_stack_depth + 1,
version_base=str(version.getbase()),
odelalleau marked this conversation as resolved.
Show resolved Hide resolved
)

def __enter__(self, *args: Any, **kwargs: Any) -> None:
Expand Down Expand Up @@ -80,7 +81,9 @@ def __init__(self, config_module: str, job_name: str = "app") -> None:
deprecation_warning(message=message)

self.delegate = real_initialize_config_module(
config_module=config_module, job_name=job_name
config_module=config_module,
job_name=job_name,
version_base=str(version.getbase()),
)

def __enter__(self, *args: Any, **kwargs: Any) -> None:
Expand Down Expand Up @@ -116,7 +119,9 @@ def __init__(self, config_dir: str, job_name: str = "app") -> None:
deprecation_warning(message=message)

self.delegate = real_initialize_config_dir(
config_dir=config_dir, job_name=job_name
config_dir=config_dir,
job_name=job_name,
version_base=str(version.getbase()),
)

def __enter__(self, *args: Any, **kwargs: Any) -> None:
Expand Down
14 changes: 8 additions & 6 deletions tests/defaults_list/test_defaults_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,13 +942,15 @@ def test_legacy_override_hydra_version_base_1_1(
hydra_restore_singletons: Any,
) -> None:
version.setbase("1.1")
msg = dedent(
"""\
Invalid overriding of hydra/help:
Default list overrides requires 'override' keyword.
See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/defaults_list_override for more information."""
msg_regex = r"Invalid overriding of hydra/(help|output):" + re.escape(
dedent(
"""
Default list overrides requires 'override' keyword.
See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/defaults_list_override for more information.
"""
)
)
with warns(expected_warning=UserWarning, match=re.escape(msg)):
with warns(expected_warning=UserWarning, match=msg_regex):
_test_defaults_tree_impl(
config_name=config_name,
input_overrides=overrides,
Expand Down
13 changes: 11 additions & 2 deletions tests/test_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,14 +727,23 @@ def test_deprecated_initialize_config_module(hydra_restore_singletons: Any) -> N


def test_initialize_without_config_path(tmpdir: Path) -> None:
expected = dedent(
expected0 = dedent(
f"""
The version_base parameter is not specified.
Please specify a compatibility version level, or None.
Will assume defaults for version {version.__compat_version__}"""
)
expected1 = dedent(
"""\
config_path is not specified in hydra.initialize().
See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/changes_to_hydra_main_config_path for more information."""
)
with warns(expected_warning=UserWarning, match=re.escape(expected)):
with warns(expected_warning=UserWarning) as record:
with initialize():
pass
assert len(record) == 2
assert str(record[0].message) == expected0
assert str(record[1].message) == expected1


@mark.usefixtures("initialize_hydra_no_path")
Expand Down
16 changes: 10 additions & 6 deletions tests/test_config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,17 @@ def test_load_config_file_with_schema_validation(
config_search_path=create_config_search_path(path)
)

msg = dedent(
"""\
'config' is validated against ConfigStore schema with the same name.
This behavior is deprecated in Hydra 1.1 and will be removed in Hydra 1.2.
See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/automatic_schema_matching for migration instructions."""
msg = (
r"""'(config|db/mysql)' is validated against ConfigStore schema with the same name\."""
+ re.escape(
dedent(
"""
This behavior is deprecated in Hydra 1.1 and will be removed in Hydra 1.2.
See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/automatic_schema_matching for migration instructions.""" # noqa: E501 line too long
)
)
)
with warns(UserWarning, match=re.escape(msg)):
with warns(UserWarning, match=msg):
cfg = config_loader.load_configuration(
config_name="config",
overrides=["+db=mysql"],
Expand Down