NeurodataWithoutBorders / matnwb

A Matlab interface for reading and writing NWB files
BSD 2-Clause "Simplified" License
50 stars 32 forks source link

Cached Spec Writes are Unsupported #149

Closed lawrence-mbf closed 5 years ago

lawrence-mbf commented 5 years ago

At the current moment, MatNWB does not support writing schema files or cached specs.

The reason for not writing cached specs stems from the fact that cached specs are, by default, only written in JSON format. This is not possible with MatNWB's YAML parser.

However, should we work around this issue, the default YAML string produced by the YAML parser on export() produces a YAML with specific tags that end up breaking the default pynwb yaml importer, shown below:

!java.util.LinkedHashMap
namespaces: 
- !java.util.LinkedHashMap
   name: core
   doc: NWB namespace
...
   full_name: NWB core
   schema: 
   - !java.util.LinkedHashMap
      source: nwb.base.yaml
      title: Base data types
      doc: This source module contains base data types used throughout the NWB:N data format.
   - !java.util.LinkedHashMap
      source: nwb.epoch.yaml
      title: Epochs
      doc: This source module contains neurodata_types for epoch data.
...
   version: 2.0.1
nclack commented 5 years ago

also see discussion in #124

nclack commented 5 years ago

Spec load/decode in pynwb seems to occur here

oruebel commented 5 years ago

@nclack yes the JSON loader won't be able to read YAML. However, a YAML loader should be able to load both JSON and YAML. I.e., we could possible use yaml.load (instead of json.load) in HDMF to read the spec. However, in general we'd ideally write JSON (not YAML) specs to the file.

nclack commented 5 years ago

@oruebel

@ln-vidrio and I were just talking about this and came to the same conclusion. Writing the JSON is the next thing to try, imo. We have the object representation in Java, so we need to identify/validate the right JSON encoder to use.