MCPcopy Index your code
hub / github.com/ray-project/ray / test_raytaskerror_serialization

Function test_raytaskerror_serialization

python/ray/tests/test_failure.py:688–714  ·  view source on GitHub ↗

Test that RayTaskError with dual exception instances can be properly serialized.

(ray_start_regular)

Source from the content-addressed store, hash-verified

686
687
688def test_raytaskerror_serialization(ray_start_regular):
689 """Test that RayTaskError with dual exception instances can be properly serialized."""
690 import ray.cloudpickle as pickle
691
692 class MyException(Exception):
693 def __init__(self, one, two):
694 self.one = one
695 self.two = two
696
697 def __reduce__(self):
698 return self.__class__, (self.one, self.two)
699
700 original_exception = MyException("test 1", "test 2")
701 ray_task_error = ray.exceptions.RayTaskError(
702 function_name="test_function",
703 traceback_str="test traceback",
704 cause=original_exception,
705 )
706
707 dual_exception = ray_task_error.make_dual_exception_instance()
708 pickled = pickle.dumps(dual_exception)
709 unpickled = pickle.loads(pickled)
710
711 assert isinstance(unpickled, ray.exceptions.RayTaskError)
712 assert isinstance(unpickled, MyException)
713 assert unpickled.one == "test 1"
714 assert unpickled.two == "test 2"
715
716
717if __name__ == "__main__":

Callers

nothing calls this directly

Calls 2

MyExceptionClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…