Skip to content

make ls more resilient in case of metadata loading fails with pynwb for some reason #282

@t-b

Description

@t-b

Follow up from NeurodataWithoutBorders/pynwb#1321.

Can someone explain why HardwareTests-V2-IP8.nwb is good with

$ dandi --log-level DEBUG ls HardwareTests-V2-IP8.nwb
2020-11-24 01:20:38,661 [   DEBUG] No newer (than 0.7.2) version of dandi/dandi-cli found available
2020-11-24 01:20:41,977 [   DEBUG] Calling memoized version of <function get_metadata at 0x0000000008A4A678> for E:\projekte\mies-igor\tools\unit-testing\HardwareTests-V2-IP8.nwb
- age: null
  date_of_birth: null
  experiment_description: null
  experimenter: null
  genotype: null
  identifier: ac24acc942a5b87538bf15d140e06b4576481565b77b114877c4d26ba23fc09e
  institution: null
  keywords: null
  lab: null
  nd_types:
  - Device (7)
  - IntracellularElectrode (6)
  - LabNotebook
  - LabNotebookDevice
  - StimulusSets
  - Subject
  - SweepTable
  - Testpulse
  - TestpulseDevice
  - TimeSeries (4)
  - UserComment
  - UserCommentDevice
  - VoltageClampSeries (2)
  - VoltageClampStimulusSeries (2)
  number_of_electrodes: 0
  number_of_units: 0
  nwb_version: 2.2.4
  path: HardwareTests-V2-IP8.nwb
  related_publications: null
  session_description: PLACEHOLDER
  session_id: null
  session_start_time: 2020-11-21 20:42:02.721000+00:00
  sex: null
  size: 9180392
  species: null
  subject_id: null
(

but bad.nwb gives

$ dandi --log-level DEBUG ls bad.nwb
2020-11-24 12:18:13,126 [   DEBUG] No newer (than 0.7.2) version of dandi/dandi-cli found available
2020-11-24 12:18:17,903 [   DEBUG] Calling memoized version of <function get_metadata at 0x0000000008A49678> for E:\projekte\mies-igor\tools\unit-testing\bad.nwb
2020-11-24 12:18:17,917 [   DEBUG] Running original <function get_metadata at 0x0000000008A49678> on 'E:\\projekte\\mies-igor\\tools\\unit-testing\\bad.nwb'
2020-11-24 12:18:20,087 [   DEBUG] Call to get_metadata on bad.nwb failed: Could not construct IntracellularElectrode object due to: IntracellularElectrode.__init__: incorrect type for 'description' (got 'bytes', expected 'str')
2020-11-24 12:18:20,087 [   DEBUG] Problem obtaining metadata for bad.nwb: 'NoneType' object has no attribute 'items'
2020-11-24 12:18:20,087 [ WARNING] Failed to operate on some paths (empty records were listed):
 AttributeError: 1 paths
- path: bad.nwb
  size: 31985390

Both have the exact same HDF5 type

E:\projekte\mies-igor\tools\unit-testing>h5dump -d "/general/intracellular_ephys/electrode_0/description" bad.nwb HardwareTests-V2-IP8.nwb
HDF5 "bad.nwb" {
DATASET "/general/intracellular_ephys/electrode_0/description" {
   DATATYPE  H5T_STRING {
      STRSIZE H5T_VARIABLE;
      STRPAD H5T_STR_NULLTERM;
      CSET H5T_CSET_UTF8;
      CTYPE H5T_C_S1;
   }
   DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
   DATA {
   (0): "Headstage 0"
   }
}
}
HDF5 "HardwareTests-V2-IP8.nwb" {
DATASET "/general/intracellular_ephys/electrode_0/description" {
   DATATYPE  H5T_STRING {
      STRSIZE H5T_VARIABLE;
      STRPAD H5T_STR_NULLTERM;
      CSET H5T_CSET_UTF8;
      CTYPE H5T_C_S1;
   }
   DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
   DATA {
   (0): "Headstage 0"
   }
}
}

files.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions