trungdong/prov

RecursionError when using .serialize

tlenters opened this issue · 0 comments

I'm currently getting an error message when trying to serialize a ProvDocument. The strange thing is that I don't get this error when using your example notebook. I've added the full error log below. Is this something you've encountered before?

RecursionError                            Traceback (most recent call last)
<ipython-input-102-dedcd967efa6> in <module>
----> 1 doc.serialize()

/opt/conda/lib/python3.9/site-packages/prov/model.py in serialize(self, destination, format, **args)
   2477         if destination is None:
   2478             stream = io.StringIO()
-> 2479             serializer.serialize(stream, **args)
   2480             return stream.getvalue()
   2481         if hasattr(destination, "write"):

/opt/conda/lib/python3.9/site-packages/prov/serializers/provjson.py in serialize(self, stream, **kwargs)
     65         buf = io.StringIO()
     66         try:
---> 67             json.dump(self.document, buf, cls=ProvJSONEncoder, **kwargs)
     68             buf.seek(0, 0)
     69             # Right now this is a bytestream. If the object to stream to is

/opt/conda/lib/python3.9/json/__init__.py in dump(obj, fp, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)
    177     # could accelerate with writelines in some versions of Python, at
    178     # a debuggability cost
--> 179     for chunk in iterable:
    180         fp.write(chunk)
    181 

/opt/conda/lib/python3.9/json/encoder.py in _iterencode(o, _current_indent_level)
    437                 markers[markerid] = o
    438             o = _default(o)
--> 439             yield from _iterencode(o, _current_indent_level)
    440             if markers is not None:
    441                 del markers[markerid]

/opt/conda/lib/python3.9/json/encoder.py in _iterencode(o, _current_indent_level)
    429             yield from _iterencode_list(o, _current_indent_level)
    430         elif isinstance(o, dict):
--> 431             yield from _iterencode_dict(o, _current_indent_level)
    432         else:
    433             if markers is not None:

/opt/conda/lib/python3.9/json/encoder.py in _iterencode_dict(dct, _current_indent_level)
    403                 else:
    404                     chunks = _iterencode(value, _current_indent_level)
--> 405                 yield from chunks
    406         if newline_indent is not None:
    407             _current_indent_level -= 1

/opt/conda/lib/python3.9/json/encoder.py in _iterencode_dict(dct, _current_indent_level)
    403                 else:
    404                     chunks = _iterencode(value, _current_indent_level)
--> 405                 yield from chunks
    406         if newline_indent is not None:
    407             _current_indent_level -= 1

/opt/conda/lib/python3.9/json/encoder.py in _iterencode_list(lst, _current_indent_level)
    323                 else:
    324                     chunks = _iterencode(value, _current_indent_level)
--> 325                 yield from chunks
    326         if newline_indent is not None:
    327             _current_indent_level -= 1

/opt/conda/lib/python3.9/json/encoder.py in _iterencode_dict(dct, _current_indent_level)
    403                 else:
    404                     chunks = _iterencode(value, _current_indent_level)
--> 405                 yield from chunks
    406         if newline_indent is not None:
    407             _current_indent_level -= 1

/opt/conda/lib/python3.9/json/encoder.py in _iterencode(o, _current_indent_level)
    436                     raise ValueError("Circular reference detected")
    437                 markers[markerid] = o
--> 438             o = _default(o)
    439             yield from _iterencode(o, _current_indent_level)
    440             if markers is not None:

/opt/conda/lib/python3.9/site-packages/prov/serializers/provjson.py in default(self, o)
     96             return encode_json_document(o)
     97         else:
---> 98             return super(ProvJSONEncoder, self).encode(o)
     99 
    100 

/opt/conda/lib/python3.9/json/encoder.py in encode(self, o)
    197         # exceptions aren't as detailed.  The list call should be roughly
    198         # equivalent to the PySequence_Fast that ''.join() would do.
--> 199         chunks = self.iterencode(o, _one_shot=True)
    200         if not isinstance(chunks, (list, tuple)):
    201             chunks = list(chunks)

/opt/conda/lib/python3.9/json/encoder.py in iterencode(self, o, _one_shot)
    255                 self.key_separator, self.item_separator, self.sort_keys,
    256                 self.skipkeys, _one_shot)
--> 257         return _iterencode(o, 0)
    258 
    259 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,

... last 3 frames repeated, from the frame below ...

/opt/conda/lib/python3.9/site-packages/prov/serializers/provjson.py in default(self, o)
     96             return encode_json_document(o)
     97         else:
---> 98             return super(ProvJSONEncoder, self).encode(o)
     99 
    100 

RecursionError: maximum recursion depth exceeded while calling a Python object```