How to use the cloudpickle.cloudpickle 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 ray-project / ray / python / ray / pickling.py View on Github external
def _fill_function(func, globals, defaults, closure, dict):
  """Fill in the resst of the function data.

  This fills in the rest of function data into the skeleton function object
  that were created via _make_skel_func(), including closures.
  """
  result = cloudpickle._fill_function(func, globals, defaults, dict)
  if pythonapi is not None:
    for i, v in enumerate(closure):
      pythonapi.PyCell_Set(c_void_p(id(result.__closure__[i])),
                           c_void_p(id(v)))
  return result
github ray-project / ray / python / ray / pickling.py View on Github external
def dumps(obj):
  stringio = cloudpickle.StringIO()
  dump(obj, stringio)
  return stringio.getvalue()
github ray-project / ray / python / ray / pickling.py View on Github external
def save_function_tuple(self, func):
    (code, f_globals, defaults,
     closure, dct, base_globals) = self.extract_func_data(func)

    self.save(_fill_function)
    self.write(pickle.MARK)

    self.save(_make_skel_func if pythonapi else cloudpickle._make_skel_func)
    self.save((code,
               (map(lambda _: cloudpickle._make_cell(None), closure)
                if closure and pythonapi is not None
                else closure),
               base_globals))
    self.write(pickle.REDUCE)
    self.memoize(func)

    self.save(f_globals)
    self.save(defaults)
    self.save(closure)
    self.save(dct)
    self.write(pickle.TUPLE)
    self.write(pickle.REDUCE)