Skip to content

Commit 8ae4fab

Browse files
authored
Merge branch 'main' into annotations-extras
2 parents 7e06727 + ca7e494 commit 8ae4fab

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
3-
rev: v0.11.8
3+
rev: v0.11.12
44
hooks:
55
- id: ruff
66
name: ruff mne_bids/

mne_bids/tests/conftest.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# SPDX-License-Identifier: BSD-3-Clause
55

66
import platform
7+
import shutil
78

89
import pytest
910
from mne.utils import run_subprocess
@@ -19,9 +20,28 @@ def _bids_validate():
1920
else:
2021
shell = False
2122

22-
def _validate(bids_root):
23-
cmd = ["bids-validator", bids_root]
24-
run_subprocess(cmd, shell=shell)
23+
# If neither bids-validator nor npx are available, we cannot validate BIDS
24+
# datasets, so we raise an exception.
25+
# If both are available, we prefer bids-validator, but we can use npx as a fallback.
26+
27+
has_validator = shutil.which("bids-validator") is not None
28+
has_npx = shutil.which("npx") is not None
29+
30+
if not has_validator and not has_npx:
31+
raise FileNotFoundError(
32+
"⛔️ bids-validator or npx is required to run BIDS validation tests. "
33+
"Please install the BIDS validator or ensure npx is available."
34+
)
35+
elif not has_validator:
36+
37+
def _validate(bids_root):
38+
cmd = ["npx", "bids-validator@latest", bids_root]
39+
run_subprocess(cmd, shell=shell)
40+
else:
41+
42+
def _validate(bids_root):
43+
cmd = ["bids-validator", bids_root]
44+
run_subprocess(cmd, shell=shell)
2545

2646
return _validate
2747

mne_bids/tests/test_path.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ def test_path_benchmark(tmp_path_factory):
228228
number=1,
229229
)
230230

231-
# while this should be of same order, lets give it some space by a factor of 2
232-
target = 2 * timed_all / len(bids_subdirectories)
231+
# while this should be of same order, lets give it some space by a factor of 3
232+
target = 3 * timed_all / len(bids_subdirectories)
233233
assert timed_ignored_nosub < target
234234

235235
# apply include_match on get_entity_vals with root level bids directory should
@@ -245,8 +245,8 @@ def test_path_benchmark(tmp_path_factory):
245245
number=1,
246246
)
247247

248-
# while this should be of same order, lets give it some space by a factor of 2
249-
target = 2 * timed_entity / len(bids_subdirectories)
248+
# while this should be of same order, lets give it some space by a factor of 3
249+
target = 3 * timed_entity / len(bids_subdirectories)
250250
assert timed_entity_match < target
251251

252252
# and these should be equivalent

0 commit comments

Comments
 (0)