Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Detailed list of changes

- Fixed a bug that modified the name and help message of some of the available commands, by `Alex Lopez Marquez`_ (:gh:`1441`)
- Updated MEG/iEEG writers to satisfy the stricter checks in the latest BIDS validator releases: BTi/4D run folders now retain their ``.pdf`` suffix (falling back to the legacy naming when an older validator is detected), KIT marker files encode the run via the ``acq`` entity instead of ``run``, datasets lacking iEEG montages receive placeholder ``electrodes.tsv``/``coordsystem.json`` files, and the ``AssociatedEmptyRoom`` entry stores dataset-relative paths by `Bruno Aristimunha`_ (:gh:`1449`)
- Made the lock helpers skip reference counting when the optional ``filelock`` dependency is missing, preventing spurious ``AttributeError`` crashes during reads, by `Bruno Aristimunha`_ (:gh:`1469`)
- Fixed a bug in :func:`mne_bids.read_raw_bids` that caused it to fail when reading BIDS datasets where the acquisition time was specified in local time rather than UTC only in Windows, by `Bruno Aristimunha`_ (:gh:`1452`)

⚕️ Code health
Expand Down
4 changes: 2 additions & 2 deletions mne_bids/_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def _increment_lock_refcount(file_path):
refcount_lock_path = Path(f"{refcount_path}.lock")

filelock = _soft_import("filelock", purpose="lock refcounting", strict=False)
if filelock is None:
if not filelock:
return

refcount_lock = filelock.FileLock(str(refcount_lock_path), timeout=5.0)
Expand Down Expand Up @@ -254,7 +254,7 @@ def _decrement_and_cleanup_lock_file(file_path):
return

filelock = _soft_import("filelock", purpose="lock refcounting", strict=False)
if filelock is None:
if not filelock:
return

refcount_lock = filelock.FileLock(str(refcount_lock_path), timeout=5.0)
Expand Down
18 changes: 18 additions & 0 deletions mne_bids/tests/test_tsv_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import pytest

import mne_bids._fileio as _fileio
from mne_bids.tsv_handler import (
_combine_rows,
_contains_row,
Expand Down Expand Up @@ -75,6 +76,23 @@ def test_tsv_handler(tmp_path):
d = _drop(d, "n/a", "trial_type")


def test_to_tsv_without_filelock(monkeypatch, tmp_path):
"""Ensure TSV writes succeed when filelock is unavailable."""
data = odict(a=[1, 2], b=["five", "six"])
tsv_path = tmp_path / "file.tsv"
lock_path = tsv_path.parent / f"{tsv_path.name}.lock"
refcount_path = tsv_path.parent / f"{tsv_path.name}.lock.refcount"

monkeypatch.setattr(_fileio, "_soft_import", lambda *args, **kwargs: None)

_to_tsv(data, tsv_path)

assert tsv_path.exists()
assert tsv_path.read_text().strip()
assert not lock_path.exists()
assert not refcount_path.exists()


def test_contains_row_different_types():
"""Test that _contains_row() can handle different dtypes without warning.

Expand Down
Loading