mirror of
https://github.com/wassname/ray.git
synced 2026-07-29 11:26:04 +08:00
Fix bug in serializing arguments of tasks that are more complex objects (#72)
* Give more informative error message when we do not know how to serialize a class. * Check that passing arguments to remote functions and getting them does not change their values. * fix serialization bug * fix tests for common module * Formatting. * Bug fix in init_pickle_module signature. * Use pickle with HIGHEST_PROTOCOL.
This commit is contained in:
committed by
Robert Nishihara
parent
1499834be1
commit
58e8bbcb34
+25
-3
@@ -50,11 +50,11 @@ PRIMITIVE_OBJECTS = [0, 0.0, 0.9, 0L, 1L << 62, "a", string.printable, "\u262F",
|
||||
np.array(["hi", 3], dtype=object),
|
||||
np.array([["hi", u"hi"], [1.3, 1L]])]
|
||||
|
||||
COMPLEX_OBJECTS = [#[[[[[[[[[[[[]]]]]]]]]]]],
|
||||
COMPLEX_OBJECTS = [[[[[[[[[[[[[]]]]]]]]]]]],
|
||||
{"obj{}".format(i): np.random.normal(size=[100, 100]) for i in range(10)},
|
||||
#{(): {(): {(): {(): {(): {(): {(): {(): {(): {(): {(): {(): {}}}}}}}}}}}}},
|
||||
#((((((((((),),),),),),),),),),
|
||||
#{"a": {"b": {"c": {"d": {}}}}}
|
||||
((((((((((),),),),),),),),),),
|
||||
{"a": {"b": {"c": {"d": {}}}}}
|
||||
]
|
||||
|
||||
class Foo(object):
|
||||
@@ -144,6 +144,28 @@ class SerializationTest(unittest.TestCase):
|
||||
|
||||
ray.worker.cleanup()
|
||||
|
||||
def testPassingArgumentsByValue(self):
|
||||
ray.init(start_ray_local=True, num_workers=1)
|
||||
|
||||
@ray.remote
|
||||
def f(x):
|
||||
return x
|
||||
|
||||
ray.register_class(Exception)
|
||||
ray.register_class(CustomError)
|
||||
ray.register_class(Point)
|
||||
ray.register_class(Foo)
|
||||
ray.register_class(Bar)
|
||||
ray.register_class(Baz)
|
||||
ray.register_class(NamedTupleExample)
|
||||
|
||||
# Check that we can pass arguments by value to remote functions and that
|
||||
# they are uncorrupted.
|
||||
for obj in RAY_TEST_OBJECTS:
|
||||
assert_equal(obj, ray.get(f.remote(obj)))
|
||||
|
||||
ray.worker.cleanup()
|
||||
|
||||
class WorkerTest(unittest.TestCase):
|
||||
|
||||
def testPutGet(self):
|
||||
|
||||
Reference in New Issue
Block a user