-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hi,
I'm getting this error when I try to upload my dicom images to couchdb:
"TypeError: Object of type MultiValue is not JSON serializable"

What I've done:
- Installed couchdb via docker.
- I have Chronicle and couchSite cloned and "working".
- Using python3.8 I installed couchdb and pydicom
- Getting error at step:
./bin/record.py <path to dicom data>
Offending line:
couchdb.json.encode(value).encode('utf-8')
My first try at fixing this was to use this advice for casting a MultiValue object to a list:
https://bitbucket.org/openrem/openrem/issues/803
Example:
self.modalities_in_study = json.dumps(x)
Into
self.modalities_in_study = json.dumps(list(x))
Now in this example it was (approx. line: 100 inside a try block):
if isinstance(value, pydicom.multival.MultiValue):
couchdb.json.encode(list(value)).encode('utf-8')
else:
couchdb.json.encode(value).encode('utf-8')
This works for a bit but feels hacky. It works until we get to line ~262:
doc_id, doc_rev = self.db.save(document)
I've even printed the data to be saved as a document and it's a simple dictionary:

...
I don't feel like I should have to edit "couchdb", "json" or "pydicom" to get this to work. Is there something with record.py that I"m configuring wrong? Could it be our data?
