Skip to content

[Serve] ServeHandle no longer serializable #13180

@simon-mo

Description

@simon-mo

What is the problem?

Ray version and other system information (Python version, TensorFlow version, OS):

from ray import serve
import ray

def f(_): pass

client = serve.start()
client.create_backend("f", f)
client.create_endpoint("f", backend="f")
handle = client.get_handle("f")

ray.put(handle)

ServeHandle can no longer be passed around to other Ray tasks and the error is really hard to debug

2021-01-04 21:15:59,360	INFO services.py:1173 -- View the Ray dashboard at http://127.0.0.1:8265
(pid=6369) 2021-01-04 21:16:01,432	INFO controller.py:346 -- Starting router with name 'hRhwaS:SERVE_CONTROLLER_ACTOR:SERVE_PROXY_ACTOR-node:192.168.31.141-0' on node 'node:192.168.31.141-0' listening on '127.0.0.1:8000'
(pid=6366) INFO:     Started server process [6366]
Traceback (most recent call last):
  File "a.py", line 11, in <module>
    ray.put(handle)
  File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/worker.py", line 1411, in put
    object_ref = worker.put_object(value, pin_object=True)
  File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/worker.py", line 262, in put_object
    serialized_value = self.get_serialization_context().serialize(value)
  File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/serialization.py", line 406, in serialize
    return self._serialize_to_msgpack(value)
  File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/serialization.py", line 386, in _serialize_to_msgpack
    self._serialize_to_pickle5(metadata, python_objects)
  File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/serialization.py", line 346, in _serialize_to_pickle5
    raise e
  File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/serialization.py", line 343, in _serialize_to_pickle5
    value, protocol=5, buffer_callback=writer.buffer_callback)
  File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/cloudpickle/cloudpickle_fast.py", line 73, in dumps
    cp.dump(obj)
  File "/Users/simonmo/miniconda3/envs/py37/lib/python3.7/site-packages/ray/cloudpickle/cloudpickle_fast.py", line 563, in dump
    return Pickler.dump(self, obj)
  File "stringsource", line 2, in ray._raylet.Count.__reduce_cython__
TypeError: self.c_tag_keys,self.metric cannot be converted to a Python object for pickling
(pid=6369) 2021-01-04 21:16:03,924	INFO controller.py:753 -- Registering route 'f' to endpoint 'f' with methods '['GET']'.
2021-01-04 21:16:06,021	INFO api.py:65 -- Shutting down Ray Serve because client went out of scope. To prevent this, either keep a reference to the client object or use serve.start(detached=True).

Reproduction (REQUIRED)

Please provide a short code snippet (less than 50 lines if possible) that can be copy-pasted to reproduce the issue. The snippet should have no external library dependencies (i.e., use fake or mock data / environments):

If the code snippet cannot be run by itself, the issue will be closed with "needs-repro-script".

  • I have verified my script runs in a clean environment and reproduces the issue.
  • I have verified the issue also occurs with the latest wheels.

Metadata

Metadata

Labels

P1Issue that should be fixed within a few weeksbugSomething that is supposed to be working; but isn'tserveRay Serve Related Issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions