Closed
Description
Bug Report
Description
When inserting into a table with an attribute of the longblob datatype, the following error occurs: AttributeError: module 'collections' has no attribute 'Mapping'
. I have tested the changes in the pull request #1002 and these changes resolve this issue. Thanks!
Reproducibility
- OS Debian GNU/Linux 11 (bullseye)
- Python 3.10.4
- DataJoint Version 0.13.4
Error stack
In [8]: miniscope.ProcessingParamSet.insert_new_params(
...: processing_method='caiman',
...: paramset_id=0,
...: paramset_desc='Calcium imaging analysis with CaImAn using default parameters',
...: params=params)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [8], in <cell line: 1>()
----> 1 miniscope.ProcessingParamSet.insert_new_params(
2 processing_method='caiman',
3 paramset_id=0,
4 paramset_desc='Calcium imaging analysis with CaImAn using default parameters',
5 params=params)
File /main/element-miniscope/element_miniscope/miniscope.py:321, in ProcessingParamSet.insert_new_params(cls, processing_method, paramset_id, paramset_desc, params)
318 raise dj.DataJointError(
319 'The specified param-set already exists - name: {}'.format(pname))
320 else:
--> 321 cls.insert1(param_dict)
File /opt/conda/lib/python3.10/site-packages/datajoint/table.py:325, in Table.insert1(self, row, **kwargs)
318 def insert1(self, row, **kwargs):
319 """
320 Insert one data record into the table. For ``kwargs``, see ``insert()``.
321
322 :param row: a numpy record, a dict-like object, or an ordered sequence to be inserted
323 as one row.
324 """
--> 325 self.insert((row,), **kwargs)
File /opt/conda/lib/python3.10/site-packages/datajoint/table.py:397, in Table.insert(self, rows, replace, skip_duplicates, ignore_extra_fields, allow_direct_insert)
394 return
396 field_list = [] # collects the field list from first row (passed by reference)
--> 397 rows = list(
398 self.__make_row_to_insert(row, field_list, ignore_extra_fields)
399 for row in rows
400 )
401 if rows:
402 try:
File /opt/conda/lib/python3.10/site-packages/datajoint/table.py:398, in <genexpr>(.0)
394 return
396 field_list = [] # collects the field list from first row (passed by reference)
397 rows = list(
--> 398 self.__make_row_to_insert(row, field_list, ignore_extra_fields)
399 for row in rows
400 )
401 if rows:
402 try:
File /opt/conda/lib/python3.10/site-packages/datajoint/table.py:883, in Table.__make_row_to_insert(self, row, field_list, ignore_extra_fields)
881 elif isinstance(row, collections.abc.Mapping): # dict-based
882 check_fields(row)
--> 883 attributes = [
884 self.__make_placeholder(name, row[name], ignore_extra_fields)
885 for name in self.heading
886 if name in row
887 ]
888 else: # positional
889 try:
File /opt/conda/lib/python3.10/site-packages/datajoint/table.py:884, in <listcomp>(.0)
881 elif isinstance(row, collections.abc.Mapping): # dict-based
882 check_fields(row)
883 attributes = [
--> 884 self.__make_placeholder(name, row[name], ignore_extra_fields)
885 for name in self.heading
886 if name in row
887 ]
888 else: # positional
889 try:
File /opt/conda/lib/python3.10/site-packages/datajoint/table.py:824, in Table.__make_placeholder(self, name, value, ignore_extra_fields)
822 value = value.bytes
823 elif attr.is_blob:
--> 824 value = blob.pack(value)
825 value = (
826 self.external[attr.store].put(value).bytes
827 if attr.is_external
828 else value
829 )
830 elif attr.is_attachment:
File /opt/conda/lib/python3.10/site-packages/datajoint/blob.py:572, in pack(obj, compress)
568 assert isinstance(obj, bytes) and obj.startswith(
569 (b"ZL123\0", b"mYm\0", b"dj0\0")
570 )
571 return obj
--> 572 return Blob().pack(obj, compress=compress)
File /opt/conda/lib/python3.10/site-packages/datajoint/blob.py:554, in Blob.pack(self, obj, compress)
552 def pack(self, obj, compress):
553 self.protocol = b"mYm\0" # will be replaced with dj0 if new features are used
--> 554 blob = self.pack_blob(
555 obj
556 ) # this may reset the protocol and must precede protocol evaluation
557 blob = self.protocol + blob
558 if compress and len(blob) > 1000:
File /opt/conda/lib/python3.10/site-packages/datajoint/blob.py:191, in Blob.pack_blob(self, obj)
189 if isinstance(obj, uuid.UUID):
190 return self.pack_uuid(obj)
--> 191 if isinstance(obj, collections.Mapping):
192 return self.pack_dict(obj)
193 if isinstance(obj, str):
AttributeError: module 'collections' has no attribute 'Mapping'