asdf
asdf copied to clipboard
RepresenterError while writing a sample file
The following code crashes on 2.3.0 for me:
asdf.AsdfFile(tree={"a": 1}).write_to("/tmp/1.asdf")
with
RepresenterError: cannot represent an object: {'history': {'extensions': []}, 'a': 1, 'asdf_library': {'name': 'asdf', 'author': 'Space Telescope Science Institute', 'version': '2.3.0', 'homepage': 'http://github.com/spacetelescope/asdf'}}
I run Python 3.5.
I can't reproduce this in a new conda environment using Py35. Is it possible that you have another version of ASDF installed in the same environment? Maybe in development mode from a source checkout?
I can reproduce it neither now... Most likely this is a weird glitch in my environment. Closing. I will reopen if we get this error again.
I just got this error in an ipynb, running macOS 10.15.7 (19H1419), Intel Core i9, py-3.8.10, asdf-2.8.2. In my case, I was using imageio.imread
to get an array from an image, and then asdf.AsdfFile({'img': img}).write_to(os.path.expanduser('~/tmp/junk.asdf'))
(note: imageio actually returns a subclass of ndarray, <class 'imageio.core.util.Array'>
) . I re-ran the notebook and it completely went away.
I wasn't doing anything super strange in this notebook, though I did try to parse some buffers which were corrupted, leading to ValueError: Input object does not appear to be an ASDF file or a FITS with ASDF extension
, as expected.
Here's my imports:
import os
import json
import yaml
from pathlib import Path
import io
import PIL
import imageio
import numpy as np
import pandas as pd
from see import see
Unfortunately I lost the full traceback when I reset. I wish this error report was more insightful. I know how frustrating it is to track down Heisenbugs, so I hope this is at least a datapoint of "hey there is this transient error that occurs sometimes. Resetting state seems to fix it".
Thanks for the new clues on this @xkortex (and for excavating the right issue to attach them to!). I'll reopen the issue and at some point see if I can figure out how to reproduce.
Testing this with the current development ASDF (3.0) I'm not seeing any issue serializing and deserializing the result of imageio.imread
. Given this and the age of the issue I'm going to close this for now. Feel free to reopen this if the error reoccurs.