node_launch_exception.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from typing import Any, Optional, Tuple
  2. from ray.util.annotations import DeveloperAPI
  3. @DeveloperAPI
  4. class NodeLaunchException(Exception):
  5. """A structured exception that can be thrown by a node provider during a
  6. `create_node` call to pass additional information for observability.
  7. """
  8. def __init__(
  9. self,
  10. category: str,
  11. description: str,
  12. src_exc_info: Optional[Tuple[Any, Any, Any]], # The
  13. ):
  14. """Args:
  15. category: A short (<20 chars) label for the error.
  16. description: A longer, human readable description of the error.
  17. src_exc_info: The source exception info if applicable. This is a
  18. tuple of (type, exception, traceback) as returned by
  19. sys.exc_info()
  20. """
  21. super().__init__(f"Node Launch Exception ({category}): {description}")
  22. self.category = category
  23. self.description = description
  24. self.src_exc_info = src_exc_info
  25. def __reduce__(self):
  26. # NOTE: Since tracebacks can't be pickled, we'll drop the optional
  27. # traceback if we have to serialize this object.
  28. return (
  29. self.__class__,
  30. (self.category, self.description, None),
  31. )