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

Pytest fails with unhandled UserWarnings #2855

Closed
Jasha10 opened this issue Feb 22, 2024 · 2 comments
Closed

Pytest fails with unhandled UserWarnings #2855

Jasha10 opened this issue Feb 22, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Jasha10
Copy link
Collaborator

Jasha10 commented Feb 22, 2024

CI is failing due to uncaught UserWarnings.
I'm not sure if these failures are showing up because of a change to hydra's codebase or by an update in the dependency stack.

Here are some example failures taken from the test_linux-3.10 CI job on PR #2854:

    def test_legacy_override_hydra_version_base_1_1(
        config_name: str,
        overrides: List[str],
        expected: DefaultsTreeNode,
        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."""
        )
>       with warns(expected_warning=UserWarning, match=re.escape(msg)):
E       UserWarning: In legacy_override_hydra2: Invalid overriding of hydra/output:
E       Default list overrides requires 'override' keyword.
E       See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/defaults_list_override for more information.

tests/defaults_list/test_defaults_tree.py:951: UserWarning
__________________________ test_deprecated_initialize __________________________

hydra_restore_singletons = None

    def test_deprecated_initialize(hydra_restore_singletons: Any) -> None:
        from hydra.experimental import initialize as expr_initialize
    
        msg = "hydra.experimental.initialize() is no longer experimental. Use hydra.initialize()"
    
        version.setbase("1.1")
>       with warns(expected_warning=UserWarning, match=re.escape(msg)):
E       UserWarning: 
E       The version_base parameter is not specified.
E       Please specify a compatibility version level, or None.
E       Will assume defaults for version 1.1

tests/test_compose.py:668: UserWarning
____________________ test_deprecated_initialize_config_dir _____________________

hydra_restore_singletons = None

    def test_deprecated_initialize_config_dir(hydra_restore_singletons: Any) -> None:
        from hydra.experimental import initialize_config_dir as expr_initialize_config_dir
    
        msg = "hydra.experimental.initialize_config_dir() is no longer experimental. Use hydra.initialize_config_dir()"
    
        version.setbase("1.1")
>       with warns(
            expected_warning=UserWarning,
            match=re.escape(msg),
        ):
E       UserWarning: 
E       The version_base parameter is not specified.
E       Please specify a compatibility version level, or None.
E       Will assume defaults for version 1.1

tests/test_compose.py:684: UserWarning
___________________ test_deprecated_initialize_config_module ___________________

hydra_restore_singletons = None

    def test_deprecated_initialize_config_module(hydra_restore_singletons: Any) -> None:
        from hydra.experimental import (
            initialize_config_module as expr_initialize_config_module,
        )
    
        msg = (
            "hydra.experimental.initialize_config_module() is no longer experimental."
            " Use hydra.initialize_config_module()"
        )
    
        version.setbase("1.1")
>       with warns(expected_warning=UserWarning, match=re.escape(msg)):
E       UserWarning: 
E       The version_base parameter is not specified.
E       Please specify a compatibility version level, or None.
E       Will assume defaults for version 1.1

tests/test_compose.py:715: UserWarning
_____________________ test_initialize_without_config_path ______________________

tmpdir = local('/tmp/pytest-of-circleci/pytest-9/test_initialize_without_config0')

    def test_initialize_without_config_path(tmpdir: Path) -> None:
        expected = 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)):
E       UserWarning: 
E       The version_base parameter is not specified.
E       Please specify a compatibility version level, or None.
E       Will assume defaults for version 1.1

tests/test_compose.py:735: UserWarning
_____ TestConfigLoader.test_load_config_file_with_schema_validation[file] ______

self = <tests.test_config_loader.TestConfigLoader object at 0x7fa7220e2950>
hydra_restore_singletons = None, path = 'file://hydra/test_utils/configs'

    def test_load_config_file_with_schema_validation(
        self, hydra_restore_singletons: Any, path: str
    ) -> None:
        with ConfigStoreWithProvider("this_test") as cs:
            cs.store(name="config", node=TopLevelConfig)
            cs.store(group="db", name="mysql", node=MySQLConfig, package="db")
    
        config_loader = ConfigLoaderImpl(
            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."""
        )
>       with warns(UserWarning, match=re.escape(msg)):
E       UserWarning: 
E       'db/mysql' is validated against ConfigStore schema with the same name.
E       This behavior is deprecated in Hydra 1.1 and will be removed in Hydra 1.2.
E       See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/automatic_schema_matching for migration instructions.

tests/test_config_loader.py:298: UserWarning
______ TestConfigLoader.test_load_config_file_with_schema_validation[pkg] ______

self = <tests.test_config_loader.TestConfigLoader object at 0x7fa7220e2a70>
hydra_restore_singletons = None, path = 'pkg://hydra.test_utils.configs'

    def test_load_config_file_with_schema_validation(
        self, hydra_restore_singletons: Any, path: str
    ) -> None:
        with ConfigStoreWithProvider("this_test") as cs:
            cs.store(name="config", node=TopLevelConfig)
            cs.store(group="db", name="mysql", node=MySQLConfig, package="db")
    
        config_loader = ConfigLoaderImpl(
            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."""
        )
>       with warns(UserWarning, match=re.escape(msg)):
E       UserWarning: 
E       'db/mysql' is validated against ConfigStore schema with the same name.
E       This behavior is deprecated in Hydra 1.1 and will be removed in Hydra 1.2.
E       See https://hydra.cc/docs/1.2/upgrades/1.0_to_1.1/automatic_schema_matching for migration instructions.

tests/test_config_loader.py:298: UserWarning
=========================== short test summary info ============================
FAILED tests/defaults_list/test_defaults_tree.py::test_legacy_override_hydra_version_base_1_1[legacy_override_hydra2] - UserWarning: In legacy_override_hydra2: Invalid overriding of hydra/output:
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.
FAILED tests/test_compose.py::test_deprecated_initialize - UserWarning: 
The version_base parameter is not specified.
Please specify a compatibility version level, or None.
Will assume defaults for version 1.1
FAILED tests/test_compose.py::test_deprecated_initialize_config_dir - UserWarning: 
The version_base parameter is not specified.
Please specify a compatibility version level, or None.
Will assume defaults for version 1.1
FAILED tests/test_compose.py::test_deprecated_initialize_config_module - UserWarning: 
The version_base parameter is not specified.
Please specify a compatibility version level, or None.
Will assume defaults for version 1.1
FAILED tests/test_compose.py::test_initialize_without_config_path - UserWarning: 
The version_base parameter is not specified.
Please specify a compatibility version level, or None.
Will assume defaults for version 1.1
FAILED tests/test_config_loader.py::TestConfigLoader::test_load_config_file_with_schema_validation[file] - UserWarning: 
@Jasha10 Jasha10 added the bug Something isn't working label Feb 22, 2024
@max-sixty
Copy link

Fixed by #2854 I think, FYI

@Jasha10
Copy link
Collaborator Author

Jasha10 commented Apr 3, 2024

Thanks @max-sixty.

@Jasha10 Jasha10 closed this as completed Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants