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

[Bug]: validation error on NWB Zarr file #221

Open
3 tasks done
CodyCBakerPhD opened this issue Sep 25, 2024 · 1 comment
Open
3 tasks done

[Bug]: validation error on NWB Zarr file #221

CodyCBakerPhD opened this issue Sep 25, 2024 · 1 comment
Labels
category: bug errors in the code or code behavior priority: medium non-critical problem and/or affecting only a small set of users

Comments

@CodyCBakerPhD
Copy link
Contributor

CodyCBakerPhD commented Sep 25, 2024

What happened?

Ran across this while debugging Zarr support for NWB Inspector NeurodataWithoutBorders/nwbinspector#513

An actual error this time, for a relatively simple file

Only detectable by running validation on the file (io.write and io.read both work fine)

Opening here since it only happens for NWBZarrIO, but might be a HDMF or PyNWB issue so feel free to transfer this

Steps to Reproduce

import datetime
import uuid

import hdmf_zarr
import numpy
import pynwb

nwbfile = pynwb.NWBFile(
    session_description="",
    identifier=str(uuid.uuid4()),
    session_start_time=datetime.datetime.now().astimezone()
)
regular_timestamps = numpy.arange(1.2, 11.2, 2)
timestamps_length = len(regular_timestamps)
time_series = pynwb.TimeSeries(
    name="test_time_series",
    data=numpy.zeros(shape=(timestamps_length, timestamps_length - 1)),
    timestamps=regular_timestamps,
    unit="",
)
nwbfile.add_acquisition(time_series)

nwbfile_path = "../test_validation_time_series.nwb.zarr"
with hdmf_zarr.NWBZarrIO(path=nwbfile_path, mode="w") as io:
    io.write(nwbfile)

with hdmf_zarr.NWBZarrIO(path=nwbfile_path, mode="r") as io:
    invalidations = pynwb.validate(io=io)

Traceback

Traceback (most recent call last):
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\IPython\core\interactiveshell.py", line 3577, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-5-43139d2216bf>", line 28, in <module>
    invalidations = pynwb.validate(io=io)
                    ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\utils.py", line 672, in func_call
    return func(**pargs)
           ^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\pynwb\validate.py", line 145, in validate
    validation_errors = _validate_helper(io=io, namespace=namespace or CORE_NAMESPACE)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\pynwb\validate.py", line 29, in _validate_helper
    return validator.validate(builder)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\utils.py", line 668, in func_call
    return func(args[0], **pargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 299, in validate
    return validator.validate(builder)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\utils.py", line 668, in func_call
    return func(args[0], **pargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 479, in validate
    errors.extend(self.__validate_children(builder))
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 505, in __validate_children
    yield from self.__validate_child_builder(child_spec, child_builder, parent_builder)
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 555, in __validate_child_builder
    yield from child_validator.validate(child_builder)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\utils.py", line 668, in func_call
    return func(args[0], **pargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 479, in validate
    errors.extend(self.__validate_children(builder))
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 505, in __validate_children
    yield from self.__validate_child_builder(child_spec, child_builder, parent_builder)
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 555, in __validate_child_builder
    yield from child_validator.validate(child_builder)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\utils.py", line 668, in func_call
    return func(args[0], **pargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 479, in validate
    errors.extend(self.__validate_children(builder))
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 505, in __validate_children
    yield from self.__validate_child_builder(child_spec, child_builder, parent_builder)
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 555, in __validate_child_builder
    yield from child_validator.validate(child_builder)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\utils.py", line 668, in func_call
    return func(args[0], **pargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 437, in validate
    dtype, string_format = get_type(data, builder.dtype)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\theac\anaconda3\envs\nwbinspector_created_9_25_24\Lib\site-packages\hdmf\validate\validator.py", line 157, in get_type
    dtype, string_format = get_type(data[0][i])
                                    ~~~~~~~^^^
IndexError: invalid index to scalar variable.

Operating System

Windows

Python Executable

Conda

Python Version

3.12

Package Versions

No response

Code of Conduct

@mavaylon1
Copy link
Contributor

Thanks for raising this issue. We will take a look after SFN.

@mavaylon1 mavaylon1 added category: bug errors in the code or code behavior priority: medium non-critical problem and/or affecting only a small set of users labels Sep 30, 2024
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 priority: medium non-critical problem and/or affecting only a small set of users
Projects
None yet
Development

No branches or pull requests

2 participants