From b0cd0c78f75837477a7d296f4634cf71e2fa258d Mon Sep 17 00:00:00 2001 From: Cade Daniel Date: Sat, 7 Jan 2023 14:25:12 -0800 Subject: [PATCH 1/4] Marking strings with invalid escape sequences as raw strings Signed-off-by: Cade Daniel --- pytest.ini | 11 +++++++++++ python/ray/_private/runtime_env/context.py | 2 +- python/ray/air/util/tensor_extensions/pandas.py | 2 +- python/ray/data/grouped_dataset.py | 2 +- .../workloads/deployment_graph_wide_ensemble.py | 4 ++-- .../workloads/serve_handle_wide_ensemble.py | 2 +- rllib/algorithms/algorithm_config.py | 2 +- rllib/algorithms/dqn/dqn.py | 2 +- rllib/algorithms/marwil/marwil.py | 2 +- rllib/algorithms/mbmpo/mbmpo.py | 2 +- rllib/algorithms/r2d2/r2d2.py | 2 +- 11 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000000000..480891b59312c --- /dev/null +++ b/pytest.ini @@ -0,0 +1,11 @@ +[pytest] +# Configure pytest to fail any test that raises an unexpected warning. +# This will enable us to catch usages of deprecated features in downstream libraries, +# before they are hard-deprecated. +# Furthermore, they will catch any test issues which may hide bugs. +# The format is `action:message_regex:category:module:line`. +filterwarnings = + # Fail builds on any unexpected warnings. + # See https://docs.google.com/document/d/1TVMfmhO0vD1MdkVrqRS9t4om2shMTY9nqdqqOopNv0M for more details. + error + ignore:.*: diff --git a/python/ray/_private/runtime_env/context.py b/python/ray/_private/runtime_env/context.py index 7a954c2facdba..582063ad0896e 100644 --- a/python/ray/_private/runtime_env/context.py +++ b/python/ray/_private/runtime_env/context.py @@ -66,7 +66,7 @@ def exec_worker(self, passthrough_args: List[str], language: Language): else: executable = "exec " - passthrough_args = [s.replace(" ", "\ ") for s in passthrough_args] + passthrough_args = [s.replace(" ", r"\ ") for s in passthrough_args] exec_command = " ".join([f"{executable}"] + passthrough_args) command_str = " ".join(self.command_prefix + [exec_command]) # TODO(SongGuyang): We add this env to command for macOS because it doesn't diff --git a/python/ray/air/util/tensor_extensions/pandas.py b/python/ray/air/util/tensor_extensions/pandas.py index 4201be97201f9..987f05dba49eb 100644 --- a/python/ray/air/util/tensor_extensions/pandas.py +++ b/python/ray/air/util/tensor_extensions/pandas.py @@ -335,7 +335,7 @@ def name(self) -> str: @classmethod def construct_from_string(cls, string: str): - """ + r""" Construct this type from a string. This is useful mainly for data types that accept parameters. diff --git a/python/ray/data/grouped_dataset.py b/python/ray/data/grouped_dataset.py index 4935086e35813..d2c32e365ff04 100644 --- a/python/ray/data/grouped_dataset.py +++ b/python/ray/data/grouped_dataset.py @@ -394,7 +394,7 @@ def count(self) -> Dataset[U]: def sum( self, on: Union[KeyFn, List[KeyFn]] = None, ignore_nulls: bool = True ) -> Dataset[U]: - """Compute grouped sum aggregation. + r"""Compute grouped sum aggregation. This is a blocking operation. diff --git a/release/serve_tests/workloads/deployment_graph_wide_ensemble.py b/release/serve_tests/workloads/deployment_graph_wide_ensemble.py index c1be05da4f28c..ad9918bafe21e 100644 --- a/release/serve_tests/workloads/deployment_graph_wide_ensemble.py +++ b/release/serve_tests/workloads/deployment_graph_wide_ensemble.py @@ -1,4 +1,4 @@ -""" +r""" Test that focuses on wide fanout of deployment graph -> Node_1 / \ @@ -56,7 +56,7 @@ def combine(value_refs): def test_wide_fanout_deployment_graph( fanout_degree, init_delay_secs=0, compute_delay_secs=0 ): - """ + r""" Test that focuses on wide fanout of deployment graph -> Node_1 / \ diff --git a/release/serve_tests/workloads/serve_handle_wide_ensemble.py b/release/serve_tests/workloads/serve_handle_wide_ensemble.py index 3ffeb98121b30..0ad06e4e03027 100644 --- a/release/serve_tests/workloads/serve_handle_wide_ensemble.py +++ b/release/serve_tests/workloads/serve_handle_wide_ensemble.py @@ -1,4 +1,4 @@ -""" +r""" This test is parity of release/serve_tests/workloads/deployment_graph_wide_ensemble.py Instead of using graph api, the test is using pure handle to diff --git a/rllib/algorithms/algorithm_config.py b/rllib/algorithms/algorithm_config.py index e2e63c479428f..45cab1e13ded2 100644 --- a/rllib/algorithms/algorithm_config.py +++ b/rllib/algorithms/algorithm_config.py @@ -2301,7 +2301,7 @@ def get_multi_agent_setup( spaces: Optional[Dict[PolicyID, Tuple[Space, Space]]] = None, default_policy_class: Optional[Type[Policy]] = None, ) -> Tuple[MultiAgentPolicyConfigDict, Callable[[PolicyID, SampleBatchType], bool]]: - """Compiles complete multi-agent config (dict) from the information in `self`. + r"""Compiles complete multi-agent config (dict) from the information in `self`. Infers the observation- and action spaces, the policy classes, and the policy's configs. The returned `MultiAgentPolicyConfigDict` is fully unified and strictly diff --git a/rllib/algorithms/dqn/dqn.py b/rllib/algorithms/dqn/dqn.py index 6dc4da804723d..ffc0524c0e571 100644 --- a/rllib/algorithms/dqn/dqn.py +++ b/rllib/algorithms/dqn/dqn.py @@ -51,7 +51,7 @@ class DQNConfig(SimpleQConfig): - """Defines a configuration class from which a DQN Algorithm can be built. + r"""Defines a configuration class from which a DQN Algorithm can be built. Example: >>> from ray.rllib.algorithms.dqn.dqn import DQNConfig diff --git a/rllib/algorithms/marwil/marwil.py b/rllib/algorithms/marwil/marwil.py index 64edafc596fc1..74c222abafb62 100644 --- a/rllib/algorithms/marwil/marwil.py +++ b/rllib/algorithms/marwil/marwil.py @@ -178,7 +178,7 @@ def build( ) -> "Algorithm": if not self._set_off_policy_estimation_methods: deprecation_warning( - old="MARWIL used to have off_policy_estimation_methods " + old=r"MARWIL used to have off_policy_estimation_methods " "is and wis by default. This has" "changed to off_policy_estimation_methods: \{\}." "If you want to use an off-policy estimator, specify it in" diff --git a/rllib/algorithms/mbmpo/mbmpo.py b/rllib/algorithms/mbmpo/mbmpo.py index d27c68c09a4b6..cf03cebdce88b 100644 --- a/rllib/algorithms/mbmpo/mbmpo.py +++ b/rllib/algorithms/mbmpo/mbmpo.py @@ -41,7 +41,7 @@ class MBMPOConfig(AlgorithmConfig): - """Defines a configuration class from which an MBMPO Algorithm can be built. + r"""Defines a configuration class from which an MBMPO Algorithm can be built. Example: >>> from ray.rllib.algorithms.mbmpo import MBMPOConfig diff --git a/rllib/algorithms/r2d2/r2d2.py b/rllib/algorithms/r2d2/r2d2.py index d5e1d770e93a8..a67d0071f301e 100644 --- a/rllib/algorithms/r2d2/r2d2.py +++ b/rllib/algorithms/r2d2/r2d2.py @@ -14,7 +14,7 @@ class R2D2Config(DQNConfig): - """Defines a configuration class from which a R2D2 Algorithm can be built. + r"""Defines a configuration class from which a R2D2 Algorithm can be built. Example: >>> from ray.rllib.algorithms.r2d2.r2d2 import R2D2Config From 5d67e6b5bc9492be3961962a0d1ab7741691841e Mon Sep 17 00:00:00 2001 From: Cade Daniel Date: Sat, 7 Jan 2023 17:25:48 -0800 Subject: [PATCH 2/4] Enabling default behavior for tests that verify warnings Signed-off-by: Cade Daniel --- python/ray/tests/test_client_builder.py | 3 +++ python/ray/tests/test_placement_group.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/python/ray/tests/test_client_builder.py b/python/ray/tests/test_client_builder.py index 444006ca3809c..4587c6bfcbdd9 100644 --- a/python/ray/tests/test_client_builder.py +++ b/python/ray/tests/test_client_builder.py @@ -325,6 +325,9 @@ def has_client_deprecation_warn(warning: Warning, expected_replacement: str) -> @pytest.mark.skipif( sys.platform == "win32", reason="pip not supported in Windows runtime envs." ) +@pytest.mark.filterwarnings( + "default:Starting a connection through `ray.client` will be deprecated" +) def test_client_deprecation_warn(): """ Tests that calling ray.client directly raises a deprecation warning with diff --git a/python/ray/tests/test_placement_group.py b/python/ray/tests/test_placement_group.py index 25d046ca10d11..00c14aa0fbd91 100644 --- a/python/ray/tests/test_placement_group.py +++ b/python/ray/tests/test_placement_group.py @@ -512,6 +512,7 @@ def test_placement_group_empty_bundle_error(ray_start_regular, connect_to_client ray.util.placement_group([]) +@pytest.mark.filterwarnings("default:placement_group parameter is deprecated") def test_placement_group_scheduling_warning(ray_start_regular_shared): @ray.remote class Foo: @@ -557,6 +558,9 @@ def foo(): assert not w +@pytest.mark.filterwarnings( + "default:Setting 'object_store_memory' for actors is deprecated" +) def test_object_store_memory_deprecation_warning(ray_start_regular_shared): with warnings.catch_warnings(record=True) as w: From e4b9651659c575d79034449bd2c0b906bd53d898 Mon Sep 17 00:00:00 2001 From: Cade Daniel Date: Sat, 7 Jan 2023 19:23:06 -0800 Subject: [PATCH 3/4] Missed enabling warning in test. --- python/ray/tests/test_placement_group.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/ray/tests/test_placement_group.py b/python/ray/tests/test_placement_group.py index 00c14aa0fbd91..edc79ce52aa69 100644 --- a/python/ray/tests/test_placement_group.py +++ b/python/ray/tests/test_placement_group.py @@ -561,6 +561,9 @@ def foo(): @pytest.mark.filterwarnings( "default:Setting 'object_store_memory' for actors is deprecated" ) +@pytest.mark.filterwarnings( + "default:Setting 'object_store_memory' for bundles is deprecated" +) def test_object_store_memory_deprecation_warning(ray_start_regular_shared): with warnings.catch_warnings(record=True) as w: From 8197d64a08b9ac8d72569cc0f9fb48ad9c81cffb Mon Sep 17 00:00:00 2001 From: Cade Daniel Date: Tue, 10 Jan 2023 10:33:59 -0800 Subject: [PATCH 4/4] PR comments --- pytest.ini | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pytest.ini b/pytest.ini index 480891b59312c..55573022769e9 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,11 +1,10 @@ [pytest] -# Configure pytest to fail any test that raises an unexpected warning. -# This will enable us to catch usages of deprecated features in downstream libraries, -# before they are hard-deprecated. -# Furthermore, they will catch any test issues which may hide bugs. -# The format is `action:message_regex:category:module:line`. + filterwarnings = - # Fail builds on any unexpected warnings. - # See https://docs.google.com/document/d/1TVMfmhO0vD1MdkVrqRS9t4om2shMTY9nqdqqOopNv0M for more details. + # This means: treat every warning as error, except for warnings that match .* (aka all warnings), ignore those. + # This triggers the SyntaxError described in https://github.com/ray-project/ray/pull/31523 but keeps the status quo + # warning behavior until https://github.com/ray-project/ray/pull/31219 . error + + # The format is `action:message_regex:category:module:line`. ignore:.*: