NeurodataWithoutBorders / pynwb

A Python API for working with Neurodata stored in the NWB Format
https://pynwb.readthedocs.io
Other
175 stars 85 forks source link

[Bug]: offset object mapper bug #1465

Closed bendichter closed 2 years ago

bendichter commented 2 years ago

What happened?

It looks like these is some problem with the object mapper for offset

Steps to Reproduce

with NWBHDF5IO("behavioral_tutorial.nwb", "w") as io:
    io.write(nwbfile)

Traceback

Traceback (most recent call last):
  File "/Users/bendichter/dev/pynwb/docs/gallery/domain/plot_behavior.py", line 348, in <module>
    io.write(nwbfile)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/backends/hdf5/h5tools.py", line 407, in write
    call_docval_func(super().write, kwargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 424, in call_docval_func
    return func(*fargs, **fkwargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/backends/io.py", line 49, in write
    f_builder = self.__manager.build(container, source=self.__source, root=True)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/manager.py", line 171, in build
    result = self.__type_map.build(container, self, source=source, spec_ext=spec_ext, export=export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/manager.py", line 769, in build
    builder = obj_mapper.build(container, manager, builder=builder, source=source, spec_ext=spec_ext, export=export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 699, in build
    self.__add_groups(builder, self.__spec.groups, container, manager, source, export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 1023, in __add_groups
    self.__add_groups(sub_builder, spec.groups, container, build_manager, source, export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 1036, in __add_groups
    self.__add_containers(builder, spec, attr_value, build_manager, source, container, export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 1094, in __add_containers
    self.__add_containers(builder, spec, container, build_manager, source, parent_container, export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 1056, in __add_containers
    new_builder = build_manager.build(value, source=source, spec_ext=spec, export=export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/manager.py", line 171, in build
    result = self.__type_map.build(container, self, source=source, spec_ext=spec_ext, export=export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/manager.py", line 769, in build
    builder = obj_mapper.build(container, manager, builder=builder, source=source, spec_ext=spec_ext, export=export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 699, in build
    self.__add_groups(builder, self.__spec.groups, container, manager, source, export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 1036, in __add_groups
    self.__add_containers(builder, spec, attr_value, build_manager, source, container, export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 1094, in __add_containers
    self.__add_containers(builder, spec, container, build_manager, source, parent_container, export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 1056, in __add_containers
    new_builder = build_manager.build(value, source=source, spec_ext=spec, export=export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/manager.py", line 171, in build
    result = self.__type_map.build(container, self, source=source, spec_ext=spec_ext, export=export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/manager.py", line 769, in build
    builder = obj_mapper.build(container, manager, builder=builder, source=source, spec_ext=spec_ext, export=export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 699, in build
    self.__add_groups(builder, self.__spec.groups, container, manager, source, export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 1036, in __add_groups
    self.__add_containers(builder, spec, attr_value, build_manager, source, container, export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 1094, in __add_containers
    self.__add_containers(builder, spec, container, build_manager, source, parent_container, export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/objectmapper.py", line 1056, in __add_containers
    new_builder = build_manager.build(value, source=source, spec_ext=spec, export=export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/manager.py", line 171, in build
    result = self.__type_map.build(container, self, source=source, spec_ext=spec_ext, export=export)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/manager.py", line 762, in build
    obj_mapper = self.get_map(container)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 583, in func_call
    return func(args[0], **pargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/build/manager.py", line 719, in get_map
    mapper = mapper_cls(spec)
  File "/Users/bendichter/dev/pynwb/src/pynwb/io/base.py", line 32, in __init__
    self.map_spec('offset', data_spec.get_attribute('offset'))
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 582, in func_call
    pargs = _check_args(args, kwargs)
  File "/Users/bendichter/opt/miniconda3/lib/python3.9/site-packages/hdmf/utils.py", line 575, in _check_args
    raise ExceptionType(msg)
TypeError: ObjectMapper.map_spec: None is not allowed for 'spec' (expected 'Spec', not None)

Operating System

macOS

Python Executable

Python

Python Version

3.9

Package Versions

No response

Code of Conduct

rly commented 2 years ago

I will take a look

rly commented 2 years ago

I cannot reproduce this with the latest dev branch. However I can reproduce this if I do not update the nwb-schema submodule. Please run git submodule update on pynwb and rerun this and let me know if the issue persists.

bendichter commented 2 years ago

That fixed it, thanks. Oddly, the problem persisted when I uninstalled pynwb and hdmf and then reinstalled them, but the git submodule update did indeed work