Skip to content

validating extension requires all parent types be imported #909

@bendichter

Description

@bendichter

Bug

Steps to Reproduce

from pynwb.spec import NWBNamespaceBuilder, NWBGroupSpec

name = 'test'

doc = 'doc'
ns_builder = NWBNamespaceBuilder(doc=doc, name=name, version='0.1',
                                 author=['Ben Dichter'],
                                 contact='[email protected]')

# import the core types used by this extension
ns_builder.include_type('ElectricalSeries', namespace='core')

ndtype = NWBGroupSpec(neurodata_type_inc='ElectricalSeries', doc='doc')

ns_path = name + '.namespace.yaml'
ext_source = name + '.extensions.yaml'

# Export
ns_builder.add_spec(ext_source, ndtype)
ns_builder.export(ns_path)

and then to validate:

 python -m pynwb.validate -p test.namespace.yaml some_file.nwb

you get the following error:

Validating against test
Traceback (most recent call last):
  File "/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/anaconda3/lib/python3.6/site-packages/pynwb/validate.py", line 69, in <module>
    main()
  File "/anaconda3/lib/python3.6/site-packages/pynwb/validate.py", line 60, in main
    ret = ret or _validate_helper(io=io, namespace=ns)
  File "/anaconda3/lib/python3.6/site-packages/pynwb/validate.py", line 21, in _validate_helper
    errors = validate(**kwargs)
  File "/anaconda3/lib/python3.6/site-packages/hdmf/utils.py", line 403, in func_call
    return func(**parsed['args'])
  File "/anaconda3/lib/python3.6/site-packages/pynwb/__init__.py", line 184, in validate
    validator = ValidatorMap(__NS_CATALOG.get_namespace(namespace))
  File "/anaconda3/lib/python3.6/site-packages/hdmf/utils.py", line 388, in func_call
    return func(self, **parsed['args'])
  File "/anaconda3/lib/python3.6/site-packages/hdmf/validate/validator.py", line 166, in __init__
    spec = self.__ns.get_spec(t)
  File "/anaconda3/lib/python3.6/site-packages/hdmf/utils.py", line 388, in func_call
    return func(self, **parsed['args'])
  File "/anaconda3/lib/python3.6/site-packages/hdmf/spec/namespace.py", line 140, in get_spec
    raise ValueError("No specification for '%s' in namespace '%s'" % (data_type, self.name))
ValueError: No specification for 'TimeSeries' in namespace 'test'

You can get rid of this error by including 'TimeSeries', 'NWBDataInterface', and 'NWBContainer' to imported types. This is only an issue for the validator. pynwb writes and reads just fine with only the child imported.

Environment

Please describe your environment according to the following bullet points.

  • Python Executable: Conda
  • Python Version: Python 3.6
  • Operating System: macOS
  • Pynwb Version: latest

Checklist

  • Have you ensured the feature or change was not already reported ?
  • Have you included a brief and descriptive title?
  • Have you included a clear description of the problem you are trying to solve?
  • Have you included a minimal code snippet that reproduces the issue you are encountering?
  • Have you checked our Contributing document?

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: HDMFissues related to the use, depending on, or affecting HDMFtopic: validatorissues related to validation of files

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions