Skip to content

Conversation

sampan-s-nayak
Copy link
Contributor

@sampan-s-nayak sampan-s-nayak commented Sep 2, 2025

builds on top of #55878

Because we are using cloud pickle to deserailize the exception, custom serializers registered using register_serializer already work out of the box. This PR adds a test case to cover this usecase, adds a new section to the docs describing what users can do when they run into the issue and updates the UnserializableException error message to point to the section in the docs

Related issue number

NA

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

sampan and others added 25 commits August 25, 2025 08:18
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: Sampan S Nayak <sampansnayak2@gmail.com>
Signed-off-by: sampan <sampan@anyscale.com>
…nserializable-exception2

Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: Sampan S Nayak <sampansnayak2@gmail.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
@sampan-s-nayak sampan-s-nayak changed the title [core] Allow configuration of serialization of Ray Errors [core] Improve docs for custom serialization for exceptions + add test Sep 8, 2025
Signed-off-by: sampan <sampan@anyscale.com>
@sampan-s-nayak sampan-s-nayak marked this pull request as ready for review September 8, 2025 09:17
@sampan-s-nayak sampan-s-nayak requested a review from a team as a code owner September 8, 2025 09:17
@sampan-s-nayak sampan-s-nayak requested a review from a team as a code owner September 8, 2025 09:17
@sampan-s-nayak sampan-s-nayak added the go add ONLY when ready to merge, run all tests label Sep 8, 2025
@ray-gardener ray-gardener bot added docs An issue or change related to documentation core Issues that should be addressed in Ray Core labels Sep 8, 2025
sampan added 2 commits September 8, 2025 14:46
Signed-off-by: sampan <sampan@anyscale.com>
…unserializable-exception2

Signed-off-by: sampan <sampan@anyscale.com>
@@ -330,6 +330,42 @@ def f():
assert clean_noqa(expected_output) == scrub_traceback(str(excinfo.value))


def test_exception_with_registered_serializer(shutdown_only):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file can probably be converted to using ray_start_regular_shared -- can you try? (separate PR if you prefer)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill raise a separate pr for this

Signed-off-by: sampan <sampan@anyscale.com>
@@ -202,6 +202,61 @@ There are at least 3 ways to define your custom serialization process:
except TypeError:
pass

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a link here by doing

.. _custom-exception-serializer

so that later on you can refer in the docstring.

@@ -916,7 +916,8 @@ class UnserializableException(RayError):
the original exception along with its stack trace that was captured at the
time of serialization.

reference for more details: https://docs.ray.io/en/latest/ray-core/objects/serialization.html
For more details and how to handle this with custom serializers, see:
https://docs.ray.io/en/latest/ray-core/objects/serialization.html#custom-serializers-for-exceptions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
https://docs.ray.io/en/latest/ray-core/objects/serialization.html#custom-serializers-for-exceptions
:ref:`xxx <custom-exception-serializer>`

Signed-off-by: sampan <sampan@anyscale.com>
@sampan-s-nayak
Copy link
Contributor Author

@jjyao addressed comments

@jjyao jjyao merged commit 427100d into ray-project:master Sep 10, 2025
5 checks passed
Aydin-ab pushed a commit to Aydin-ab/ray-aydin that referenced this pull request Sep 10, 2025
ray-project#56156)

Signed-off-by: sampan <sampan@anyscale.com>
Signed-off-by: Sampan S Nayak <sampansnayak2@gmail.com>
Co-authored-by: sampan <sampan@anyscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues that should be addressed in Ray Core docs An issue or change related to documentation go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants