NeurodataWithoutBorders / pynwb

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

[Bug]: Python warning when executing validate #1953

Open t-b opened 3 months ago

t-b commented 3 months ago

What happened?

I would expect no python warning from the below code:

Steps to Reproduce

Input:

python -m pynwb.validate --help

Output:

<frozen runpy>:128: RuntimeWarning: 'pynwb.validate' found in sys.modules after import of package 'pynwb', but prior to execution of 'pynwb.validate'; this may result in unpredictable behaviour
usage: validate.py [-h] [-lns] [-n NS] [--no-cached-namespace] paths [paths ...]

Validate an NWB file

positional arguments:
  paths                 NWB file paths

options:
  -h, --help            show this help message and exit
  -lns, --list-namespaces
                        List the available namespaces and exit.
  -n NS, --ns NS        the namespace to validate against
  --no-cached-namespace
                        Use the PyNWB loaded namespace (true) or use the cached namespace (false; default).

If --ns is not specified, validate against all namespaces in the NWB file.

### Traceback

_No response_

### Operating System

Linux

### Python Executable

Python

### Python Version

3.11

### Package Versions

$pip list Package Version


attrs 24.2.0 h5py 3.11.0 hdmf 3.14.3 jsonschema 4.23.0 jsonschema-specifications 2023.12.1 numpy 1.26.4 pandas 2.2.2 pip 23.0.1 pynwb 2.8.1 python-dateutil 2.9.0.post0 pytz 2024.1 referencing 0.35.1 rpds-py 0.20.0 ruamel.yaml 0.18.6 ruamel.yaml.clib 0.2.8 scipy 1.14.1 setuptools 66.1.1 six 1.16.0 tzdata 2024.1



### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/NeurodataWithoutBorders/pynwb/blob/dev/.github/CODE_OF_CONDUCT.rst)
- [X] Have you checked the [Contributing](https://github.com/NeurodataWithoutBorders/pynwb/blob/dev/docs/CONTRIBUTING.rst) document?
- [X] Have you ensured this bug was not already [reported](https://github.com/NeurodataWithoutBorders/pynwb/issues)?
stephprince commented 2 months ago

Thanks for reporting this warning @t-b.

We will plan to address this warning when we change the organization of the validation methods - https://github.com/NeurodataWithoutBorders/pynwb/issues/1808