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

Warn if writing a file without the appropriate extension #1978

Merged
merged 5 commits into from
Nov 8, 2024

Conversation

stephprince
Copy link
Contributor

@stephprince stephprince commented Nov 7, 2024

Motivation

Fix #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

  • Did you update CHANGELOG.md with your changes?
  • Have you checked our Contributing document?
  • Have you ensured the PR clearly describes the problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running ruff check . && codespell from the source directory.
  • Have you checked to ensure that there aren't other open Pull Requests for the same change?
  • Have you included the relevant issue number using "Fix #XXX" notation where XXX is the issue number? By including "Fix #XXX" you allow GitHub to close issue #XXX when the PR is merged.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

Additional details and impacted files
@@           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 Coverage Δ
integration 72.71% <100.00%> (+0.02%) ⬆️
unit 83.27% <0.00%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stephprince stephprince marked this pull request as ready for review November 8, 2024 18:40
@stephprince stephprince requested a review from oruebel November 8, 2024 18:46
@oruebel oruebel merged commit e55de6c into dev Nov 8, 2024
24 of 25 checks passed
@oruebel oruebel deleted the warn-for-file-extension branch November 8, 2024 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Warn if writing a file does not end in appropriate extension
2 participants