Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NWB files without cached namespaces do not validate #1157

Closed
rly opened this issue Jan 22, 2020 · 4 comments
Closed

NWB files without cached namespaces do not validate #1157

rly opened this issue Jan 22, 2020 · 4 comments
Labels
category: bug errors in the code or code behavior topic: validator issues related to validation of files

Comments

@rly
Copy link
Contributor

rly commented Jan 22, 2020

Example: The Allen Institute Visual Coding NWB files do not have cached specs.

python -m pynwb.validate probe_760640083_lfp.nwb

Output:

c:\users\ryan\documents\nwb\hdmf\src\hdmf\backends\hdf5\h5tools.py:100: UserWarning: No cached namespaces found in C:\Users\Ryan\Documents\NWB\allen-visual-coding-nwb\visual_coding\example_ecephys_project_cache\session_756029989\probe_760640083_lfp.nwb
  warnings.warn(msg)
The file C:\Users\Ryan\Documents\NWB\allen-visual-coding-nwb\visual_coding\example_ecephys_project_cache\session_756029989\probe_760640083_lfp.nwb has no cached namespace information. Falling back to pynwb namespace information.
Validating C:\Users\Ryan\Documents\NWB\allen-visual-coding-nwb\visual_coding\example_ecephys_project_cache\session_756029989\probe_760640083_lfp.nwb against pynwb namespace information using namespace hdmf-common.
Traceback (most recent call last):
  File "C:\Users\Ryan\Miniconda3\envs\pynwb-dev\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\Ryan\Miniconda3\envs\pynwb-dev\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\users\ryan\documents\nwb\pynwb\src\pynwb\validate.py", line 115, in <module>
    main()
  File "c:\users\ryan\documents\nwb\pynwb\src\pynwb\validate.py", line 109, in main
    ret = ret or _validate_helper(io=io, namespace=ns)
  File "c:\users\ryan\documents\nwb\pynwb\src\pynwb\validate.py", line 24, in _validate_helper
    errors = validate(**kwargs)
  File "c:\users\ryan\documents\nwb\hdmf\src\hdmf\utils.py", line 455, in func_call
    return func(**parsed['args'])
  File "c:\users\ryan\documents\nwb\pynwb\src\pynwb\__init__.py", line 199, in validate
    return validator.validate(builder)
  File "c:\users\ryan\documents\nwb\hdmf\src\hdmf\utils.py", line 453, in func_call
    return func(args[0], **parsed['args'])
  File "c:\users\ryan\documents\nwb\hdmf\src\hdmf\validate\validator.py", line 233, in validate
    raise ValueError(msg)
ValueError: builder for container 'root' must have data type defined with attribute 'data_type'

It looks like when there are no cached specs, the validator tries to validate the file against the hdmf-common-schema, but the file uses the data type key 'neurodata_type' instead of 'data_type'.

@rly rly added the category: bug errors in the code or code behavior label Jan 22, 2020
@rly
Copy link
Contributor Author

rly commented Jan 22, 2020

Using the default validate function, however, seems to work:

from pynwb import validate, NWBHDF5IO
with NWBHDF5IO('probe_760640083_lfp.nwb') as io:
    io.validate()

output:

[TimeSeries/control (processing/current_source_density/current_source_density/control): incorrect shape - expected '[None]', got '(384, 2)', 
DynamicTable/colnames (general/extracellular_ephys/electrodes.colnames): incorrect type - expected 'text', got 'ascii']

@t-b
Copy link
Collaborator

t-b commented Jan 22, 2020

@rly Does it work with #1094?

We should add some tests using the CLI validation tool as well into test.py. This seems to work too differently.

@rly
Copy link
Contributor Author

rly commented Jan 22, 2020

@t-b No, it does not work with #1094. Testing #1094 led me here.

rly added a commit that referenced this issue Jan 23, 2020
@t-b t-b added the topic: validator issues related to validation of files label Jan 30, 2020
t-b pushed a commit to t-b/pynwb that referenced this issue Feb 2, 2020
t-b pushed a commit to t-b/pynwb that referenced this issue Feb 2, 2020
@t-b
Copy link
Collaborator

t-b commented Feb 6, 2020

This should be fixed with #1164.

@t-b t-b closed this as completed Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug errors in the code or code behavior topic: validator issues related to validation of files
Projects
None yet
Development

No branches or pull requests

2 participants