From 4069686e0f3343ba53905f5d6b58af2961cb6827 Mon Sep 17 00:00:00 2001 From: architkulkarni Date: Mon, 19 Jul 2021 09:28:33 -0700 Subject: [PATCH] Revert "Improve error message for oversized function (#17133)" (#17184) This reverts commit 3e53619d6479beea383a86f2ec1bd89e3756f6c2. --- README.rst | 2 +- doc/source/data/dataset.rst | 5 --- python/ray/_private/function_manager.py | 14 ++++----- python/ray/_private/utils.py | 41 +++++++++---------------- python/ray/ray_constants.py | 4 +-- python/ray/tests/test_basic.py | 19 ------------ python/ray/tests/test_failure.py | 3 +- python/ray/worker.py | 6 ++-- 8 files changed, 28 insertions(+), 66 deletions(-) diff --git a/README.rst b/README.rst index b2c4b8761..e9bdaf2e7 100644 --- a/README.rst +++ b/README.rst @@ -36,7 +36,7 @@ Install Ray with: ``pip install ray``. For nightly wheels, see the .. _`Dask`: https://docs.ray.io/en/master/dask-on-ray.html .. _`Horovod`: https://horovod.readthedocs.io/en/stable/ray_include.html .. _`Scikit-learn`: joblib.html -.. _`Datasets`: https://docs.ray.io/en/master/data/dataset.html + Quick Start diff --git a/doc/source/data/dataset.rst b/doc/source/data/dataset.rst index db1b7fcb2..cae70725c 100644 --- a/doc/source/data/dataset.rst +++ b/doc/source/data/dataset.rst @@ -314,11 +314,6 @@ Datasets can read and write in parallel to `custom datasources FUNCTION_SIZE_ERROR_THRESHOLD={}" - " MiB). Check that its definition is not implicitly capturing a " - "large array or other object in scope. Tip: use ray.put() to " - "put large objects in the Ray object store.").format( - obj_type, name, length // (1024 * 1024), - ray_constants.FUNCTION_SIZE_ERROR_THRESHOLD // (1024 * 1024)) - raise ValueError(error) + warning_message = ( + "Warning: The {} {} has size {} when pickled. " + "It will be stored in Redis, which could cause memory issues. " + "This may mean that its definition uses a large array or other object." + ).format(obj_type, name, length) + push_error_to_driver( + worker, + ray_constants.PICKLING_LARGE_OBJECT_PUSH_ERROR, + warning_message, + job_id=worker.current_job_id) def is_main_thread(): diff --git a/python/ray/ray_constants.py b/python/ray/ray_constants.py index c12f4f924..f713563e0 100644 --- a/python/ray/ray_constants.py +++ b/python/ray/ray_constants.py @@ -69,9 +69,7 @@ DEFAULT_ACTOR_METHOD_NUM_RETURN_VALS = 1 # If a remote function or actor (or some other export) has serialized size # greater than this quantity, print an warning. -FUNCTION_SIZE_WARN_THRESHOLD = 10**7 -FUNCTION_SIZE_ERROR_THRESHOLD = env_integer("FUNCTION_SIZE_ERROR_THRESHOLD", - (10**8)) +PICKLE_OBJECT_WARNING_SIZE = 10**7 # If remote functions with the same source are imported this many times, then # print a warning. diff --git a/python/ray/tests/test_basic.py b/python/ray/tests/test_basic.py index 2ead52aee..e1ee57997 100644 --- a/python/ray/tests/test_basic.py +++ b/python/ray/tests/test_basic.py @@ -619,25 +619,6 @@ def test_args_named_and_star(ray_start_shared_local_modes): ray.get(remote_test_function.remote(local_method, actor_method)) -def test_oversized_function(ray_start_shared_local_modes): - bar = np.zeros(100 * 1024 * 1024) - - @ray.remote - class Actor: - def foo(self): - return len(bar) - - @ray.remote - def f(): - return len(bar) - - with pytest.raises(ValueError): - f.remote() - - with pytest.raises(ValueError): - Actor.remote() - - def test_args_stars_after(ray_start_shared_local_modes): def star_args_after(a="hello", b="heo", *args, **kwargs): return a, b, args, kwargs diff --git a/python/ray/tests/test_failure.py b/python/ray/tests/test_failure.py index 3678eb76b..e0407a728 100644 --- a/python/ray/tests/test_failure.py +++ b/python/ray/tests/test_failure.py @@ -524,8 +524,7 @@ def test_export_large_objects(ray_start_regular, error_pubsub): p = error_pubsub import ray.ray_constants as ray_constants - large_object = np.zeros( - 2 * ray_constants.FUNCTION_SIZE_WARN_THRESHOLD, dtype=np.uint8) + large_object = np.zeros(2 * ray_constants.PICKLE_OBJECT_WARNING_SIZE) @ray.remote def f(): diff --git a/python/ray/worker.py b/python/ray/worker.py index 000bad70e..3d00994fd 100644 --- a/python/ray/worker.py +++ b/python/ray/worker.py @@ -53,7 +53,7 @@ from ray.exceptions import ( from ray._private.function_manager import FunctionActorManager from ray._private.ray_logging import setup_logger from ray._private.ray_logging import global_worker_stdstream_dispatcher -from ray._private.utils import check_oversized_function +from ray._private.utils import check_oversized_pickle from ray.util.inspect import is_cython from ray.experimental.internal_kv import _internal_kv_get, \ _internal_kv_initialized @@ -392,8 +392,8 @@ class Worker: # we don't need to export it again. return - check_oversized_function(pickled_function, function.__name__, - "function", self) + check_oversized_pickle(pickled_function, function.__name__, + "function", self) # Run the function on all workers. self.redis_client.hset(