Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def inject_addons(self):
tensor_class = tf.convert_to_tensor(1.).__class__
CloudPickler.dispatch[tensor_class] = _TensorCloudPickler.save_tensor
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]
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