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

Warn if writing a file without the appropriate extension #1978

Closed stephprince closed 2 weeks ago

stephprince commented 2 weeks ago

Motivation

Fix https://github.com/NeurodataWithoutBorders/pynwb/issues/1976 for NWBHDF5IO.

How to test the behavior?

from datetime import datetime
from dateutil.tz import tzutc
from pynwb import NWBFile, NWBHDF5IO

nwbfile = NWBFile(session_description='a test NWB File',
                             identifier='TEST123',
                             session_start_time=datetime(1970, 1, 1, 12, tzinfo=tzutc()))
with NWBHDF5IO("path.h5", 'w') as io:
    io.write(nwbfile)

Warns:

UserWarning: The file path provided: path.h5 does not end in '.nwb'. It is recommended that NWB files using the HDF5 backend use the '.nwb' extension

Checklist

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.87%. Comparing base (2f2a494) to head (0f1de82). Report is 1 commits behind head on dev.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## dev #1978 +/- ## ======================================= Coverage 91.87% 91.87% ======================================= Files 27 27 Lines 2695 2697 +2 Branches 703 704 +1 ======================================= + Hits 2476 2478 +2 Misses 145 145 Partials 74 74 ``` | [Flag](https://app.codecov.io/gh/NeurodataWithoutBorders/pynwb/pull/1978/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NeurodataWithoutBorders) | Coverage Δ | | |---|---|---| | [integration](https://app.codecov.io/gh/NeurodataWithoutBorders/pynwb/pull/1978/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NeurodataWithoutBorders) | `72.71% <100.00%> (+0.02%)` | :arrow_up: | | [unit](https://app.codecov.io/gh/NeurodataWithoutBorders/pynwb/pull/1978/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NeurodataWithoutBorders) | `83.27% <0.00%> (-0.07%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=NeurodataWithoutBorders#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.