class_docstr: Extends the functionality of dill to serialize arbitrary objects.
  
  Originally intended to serialize the anomaly detector class
  `~greykite.detection.anomaly_detector.AnomalyDetector`, but
  can be potentially used to serialize other objects.
  
  Outputs a dictionary that can be serialized by `json` or `yaml` libraries.
  The dictionary has a tree structure, where each node is either a
  serialized object, or a pair of type and directory of serialized objects.
  The base of the directory is called "ROOT".
  
  Usage
  -----
      # To serialize
      pickler = GreykitePickler()
      pickled = pickler.dumps(obj)
      pickled_json = json.dumps(pickled)
  
      # To deserialize
      pickled = json.loads(pickled_json)
      obj = pickler.loads(pickled)
  
  Attributes
  ----------
  obj: any
      The object to be serialized.
class_docstr_tok: ["Extends","the","functionality","of","dill","to","serialize","arbitrary","objects",".","Originally","intended","to","serialize","the","anomaly","detector","class","`","~greykite.detection.anomaly_detector.AnomalyDetector","`",",","but","can","be","potentially","used","to","serialize","other","objects",".","Outputs","a","dictionary","that","can","be","serialized","by","`","json","`","or","`","yaml","`","libraries",".","The","dictionary","has","a","tree","structure",",","where","each","node","is","either","a","serialized","object",",","or","a","pair","of","type","and","directory","of","serialized","objects",".","The","base","of","the","directory","is","called","``","ROOT","''",".","Usage","--","--","-","#","To","serialize","pickler","=","GreykitePickler","(",")","pickled","=","pickler.dumps","(","obj",")","pickled_json","=","json.dumps","(","pickled",")","#","To","deserialize","pickled","=","json.loads","(","pickled_json",")","obj","=","pickler.loads","(","pickled",")","Attributes","--","--","--","--","--","obj",":","any","The","object","to","be","serialized","."]
docstr: Returns a serialized string representation of the `obj`.
  The `obj` must be serializable by `dill`.
  
  Serialized output `dill` is a bytes object, which can not be stored in a json file.
  This method encodes the bytes object to a base64 string, which can be stored in a json file.
  
  Parameters
  ----------
  obj: any
      The object to be serialized. Must be serializable by `dill`.
  
  Returns
  -------
  serialized_string: `str`
      A serialized string representation of the object.
docstr_tok: ["Returns","a","serialized","string","representation","of","the","`","obj","`",".","The","`","obj","`","must","be","serializable","by","`","dill","`",".","Serialized","output","`","dill","`","is","a","bytes","object",",","which","can","not","be","stored","in","a","json","file",".","This","method","encodes","the","bytes","object","to","a","base64","string",",","which","can","be","stored","in","a","json","file",".","Parameters","--","--","--","--","--","obj",":","any","The","object","to","be","serialized",".","Must","be","serializable","by","`","dill","`",".","Returns","--","--","--","-","serialized_string",":","`","str","`","A","serialized","string","representation","of","the","object","."]
code: def dumps_to_str(obj):
      """Returns a serialized string representation of the `obj`.
      The `obj` must be serializable by `dill`.
  
      Serialized output `dill` is a bytes object, which can not be stored in a json file.
      This method encodes the bytes object to a base64 string, which can be stored in a json file.
  
      Parameters
      ----------
      obj: any
          The object to be serialized. Must be serializable by `dill`.
  
      Returns
      -------
      serialized_string: `str`
          A serialized string representation of the object.
      """
      return codecs.encode(dill.dumps(obj), "base64").decode()
  
file_path: greykite/greykite/detection/common/pickler.py
imports: import codecs
  import inspect
  from collections import OrderedDict
  import dill
label_desc: Use image node_id 13 for calling the GreykitePickler obj's underlying member method code with example usage: obj.dumps_to_str(obj) and returns: codecs