How to use the cloudpickle.CloudPickler.dispatch function in cloudpickle

To help you get started, we’ve selected a few cloudpickle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tensorflow / probability / tensorflow_probability / python / layers / distribution_layer.py View on Github external
def inject_addons(self):
    tensor_class = tf.convert_to_tensor(1.).__class__
    CloudPickler.dispatch[tensor_class] = _TensorCloudPickler.save_tensor
github llllllllll / cloudpickle-generators / cloudpickle_generators / __init__.py View on Github external
def unregister():
    """Unregister the cloudpickle extension.
    """
    if CloudPickler.dispatch.get(GeneratorType) is _save_generator:
        # make sure we are only removing the dispatch we added, not someone
        # else's
        del CloudPickler.dispatch[GeneratorType]

    if sys.version_info >= (3, 5, 0):
        if CloudPickler.dispatch.get(CoroutineType) is _save_coroutine:
            del CloudPickler.dispatch[CoroutineType]

    if sys.version_info >= (3, 6, 0):
        if (CloudPickler.dispatch.get(AsyncGeneratorType) is
                _save_async_generator):
            del CloudPickler.dispatch[AsyncGeneratorType]
github llllllllll / cloudpickle-generators / cloudpickle_generators / __init__.py View on Github external
def register():
    """Register the cloudpickle extension.
    """
    CloudPickler.dispatch[GeneratorType] = _save_generator
    if sys.version_info >= (3, 5, 0):
        CloudPickler.dispatch[CoroutineType] = _save_coroutine
    if sys.version_info >= (3, 6, 0):
        CloudPickler.dispatch[AsyncGeneratorType] = _save_async_generator