diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000000000..55573022769e9 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,10 @@ +[pytest] + +filterwarnings = + # 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:.*: 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 11a3953756d04..dd27136880d38 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/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..edc79ce52aa69 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,12 @@ def foo(): assert not w +@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: 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 144efe64846e2..6f4496b4840cf 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