ray.tune.utils.diagnose_serialization#

ray.tune.utils.diagnose_serialization(trainable: Callable)[source]#

Utility for detecting why your trainable function isn’t serializing.

Parameters:

trainable – The trainable object passed to tune.Tuner(trainable). Currently only supports Function API.

Returns:

bool | set of unserializable objects.

Example:

import threading
# this is not serializable
e = threading.Event()

def test():
    print(e)

diagnose_serialization(test)
# should help identify that 'e' should be moved into
# the `test` scope.

# correct implementation
def test():
    e = threading.Event()
    print(e)

assert diagnose_serialization(test) is True

DeveloperAPI: This API may change across minor Ray releases.