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

Fix handling of README files with extensions #1318

Merged
merged 11 commits into from
Oct 11, 2024
Merged

Conversation

thht
Copy link
Contributor

@thht thht commented Oct 10, 2024

PR Description

According to the BIDS specs, a README file can have no extension or one of the following: .txt, .md, .rst.

The current behavior of MNE-BIDS is to always assume an extensionless README to be present. A README file with one of the valid extensions is simply ignored, a new README file is written. This results in two README files being present in the BIDS root folder which violates the specs.

This PR fixes this by looking whether one of the valid extensions are present and uses the correct file.

Merge checklist

Maintainer, please confirm the following before merging.
If applicable:

  • All comments are resolved
  • This is not your own PR
  • All CIs are happy
  • PR title starts with [MRG]
  • whats_new.rst is updated
  • New contributors have been added to CITATION.cff
  • PR description includes phrase "closes <#issue-number>"

@sappelhoff
Copy link
Member

Thanks! Please ping me once this is ready for review/merge.

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.47%. Comparing base (420686e) to head (6935d1e).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1318   +/-   ##
=======================================
  Coverage   97.46%   97.47%           
=======================================
  Files          40       40           
  Lines        8840     8872   +32     
=======================================
+ Hits         8616     8648   +32     
  Misses        224      224           

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

@thht thht marked this pull request as ready for review October 10, 2024 13:20
@thht
Copy link
Contributor Author

thht commented Oct 10, 2024

pinging @sappelhoff. all checks green. looking forward to your thoughts and input!

doc/whats_new.rst Outdated Show resolved Hide resolved
mne_bids/tests/test_update.py Outdated Show resolved Hide resolved
mne_bids/write.py Outdated Show resolved Hide resolved
thht and others added 3 commits October 11, 2024 09:13
Copy link
Member

@sappelhoff sappelhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM in general, thanks for the contribution.

However I'd also like the behavior to be that when multiple READMEs are discovered, we throw an error, instead of what this PR currently implements (selecting one README, and potentially ignoring the presence of the others)

@thht
Copy link
Contributor Author

thht commented Oct 11, 2024

LGTM in general, thanks for the contribution.

However I'd also like the behavior to be that when multiple READMEs are discovered, we throw an error, instead of what this PR currently implements (selecting one README, and potentially ignoring the presence of the others)

Working on it right now ;-)

@thht
Copy link
Contributor Author

thht commented Oct 11, 2024

As you can see in my other reply, I added raising a RuntimeError when multiple READMEs are encounted including a test for this.

@sappelhoff sappelhoff added this to the 0.16 milestone Oct 11, 2024
@sappelhoff sappelhoff merged commit ed75468 into mne-tools:main Oct 11, 2024
23 checks passed
@sappelhoff
Copy link
Member

Thanks @thht!

@thht thht deleted the fix_readme branch October 11, 2024 12:03
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.

4 participants