Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Docs](https://github.com/childmindresearch/bids2table/actions/workflows/docs.yaml/badge.svg?branch=main)](https://childmindresearch.github.io/bids2table/bids2table)
[![codecov](https://codecov.io/gh/childmindresearch/bids2table/branch/main/graph/badge.svg?token=22HWWFWPW5)](https://codecov.io/gh/childmindresearch/bids2table)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![Python3](https://img.shields.io/badge/python->=3.12-blue.svg)
![Python3](https://img.shields.io/badge/python->=3.11-blue.svg)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Index [BIDS](https://bids-specification.readthedocs.io/en/stable/) datasets fast, locally or in the cloud.
Expand Down Expand Up @@ -54,6 +54,8 @@ bids-examples/ds003
bids-examples/eeg_cbm
```

> Note: `b2t2 find` requires python>=3.12.

### Indexing datasets from the command line

Indexing datasets is done with `b2t2 index`. Here we index a single example dataset, saving the output as a parquet file.
Expand Down
4 changes: 3 additions & 1 deletion bids2table/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Docs](https://github.com/childmindresearch/bids2table/actions/workflows/docs.yaml/badge.svg?branch=main)](https://childmindresearch.github.io/bids2table/bids2table)
[![codecov](https://codecov.io/gh/childmindresearch/bids2table/branch/main/graph/badge.svg?token=22HWWFWPW5)](https://codecov.io/gh/childmindresearch/bids2table)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
![Python3](https://img.shields.io/badge/python->=3.12-blue.svg)
![Python3](https://img.shields.io/badge/python->=3.11-blue.svg)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

Index [BIDS](https://bids-specification.readthedocs.io/en/stable/) datasets fast, locally or in the cloud.
Expand Down Expand Up @@ -55,6 +55,8 @@
bids-examples/eeg_cbm
```

> Note: `b2t2 find` requires python>=3.12.
Copy link

Copilot AI May 12, 2025

Choose a reason for hiding this comment

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

[nitpick] While the project’s minimum Python version is now 3.11, the note implies that the find command requires Python >=3.12. Clarify in the documentation that only the find functionality is gated on Python 3.12, while the rest of the project supports Python 3.11.

Suggested change
> Note: `b2t2 find` requires python>=3.12.
> Note: While the overall project supports Python >=3.11, the `b2t2 find` command specifically requires Python >=3.12.

Copilot uses AI. Check for mistakes.

### Indexing datasets from the command line

Indexing datasets is done with `b2t2 index`. Here we index a single example dataset, saving the output as a parquet file.
Expand Down
4 changes: 4 additions & 0 deletions bids2table/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@


def _find_command(args: argparse.Namespace):
if sys.version_info < (3, 12):
_logger.error("bids2table find requires Python 3.12 or higher.")
sys.exit(1)

Check warning on line 157 in bids2table/__main__.py

View check run for this annotation

Codecov / codecov/patch

bids2table/__main__.py#L156-L157

Added lines #L156 - L157 were not covered by tests

_check_path(args.root)

for dataset in b2t2.find_bids_datasets(
Expand Down
7 changes: 7 additions & 0 deletions bids2table/_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import fnmatch
import importlib.metadata
import re
import sys
from concurrent.futures import Executor, ProcessPoolExecutor
from functools import partial
from typing import Any, Callable, Generator, Iterable, Sequence
Expand Down Expand Up @@ -142,7 +143,13 @@

Yields:
Root paths of all BIDS datasets under `root`.

.. note::
Requires Python >= 3.12.
"""
if sys.version_info < (3, 12):
raise RuntimeError("find_bids_datasets requires Python 3.12 or higher.")

Check warning on line 151 in bids2table/_indexing.py

View check run for this annotation

Codecov / codecov/patch

bids2table/_indexing.py#L151

Added line #L151 was not covered by tests

root = as_path(root)

dir_count = 0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
]
description = "Index BIDS datasets fast, locally or in the cloud."
readme = "README.md"
requires-python = ">=3.12"
requires-python = ">=3.11"
license = {text = "MIT License"}
classifiers = [
"Development Status :: 3 - Alpha",
Expand Down
6 changes: 4 additions & 2 deletions tests/test_indexing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import sys
from pathlib import Path

import pyarrow as pa
Expand All @@ -24,6 +25,7 @@ def test_get_column_names():
assert BIDSColumn.dataset == "dataset"


@pytest.mark.skipif(sys.version_info < (3, 12), reason="Python < 3.12.")
def test_find_bids_datasets():
datasets = sorted(indexing.find_bids_datasets(BIDS_EXAMPLES, log_frequency=100))
expected_datasets = sorted(
Expand Down Expand Up @@ -92,12 +94,12 @@ def test_index_dataset_warns(path: str, msg: str, caplog: LogCaptureFixture):

@pytest.mark.parametrize("max_workers", [0, 2])
def test_batch_index_dataset(max_workers: int):
datasets = list(indexing.find_bids_datasets(BIDS_EXAMPLES))
datasets = list(BIDS_EXAMPLES.glob("*"))
tables = indexing.batch_index_dataset(
datasets, max_workers=max_workers, show_progress=False
)
table = pa.concat_tables(tables)
assert len(table) == 10133
assert len(table) == 9727


@pytest.mark.parametrize(
Expand Down
20 changes: 11 additions & 9 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@

BIDS_EXAMPLES = Path(__file__).parents[1] / "bids-examples"

COMMANDS = [
"find {examples}",
"index -o {out_dir}/ds102.parquet {examples}/ds102",
"index -o {out_dir}/ds101_ds102.parquet {examples}/ds101 {examples}/ds102",
"index -o {out_dir}/ds10N.parquet '{examples}/ds10?'",
]


@contextmanager
def patch_argv(argv: List[str]):
Expand All @@ -31,7 +24,6 @@ def patch_argv(argv: List[str]):
@pytest.mark.parametrize(
"cmd,output",
[
("find {examples}", None),
("index -o {out_dir}/ds102.parquet {examples}/ds102", "ds102.parquet"),
(
"index -o {out_dir}/ds101_ds102.parquet {examples}/ds101 {examples}/ds102",
Expand All @@ -40,7 +32,7 @@ def patch_argv(argv: List[str]):
("index -o {out_dir}/ds10N.parquet '{examples}/ds10?'", "ds10N.parquet"),
],
)
def test_main(cmd: str, output: str | None, tmp_path: Path):
def test_main_index(cmd: str, output: str | None, tmp_path: Path):
cmd_fmt = cmd.format(out_dir=tmp_path, examples=BIDS_EXAMPLES)
prog = str(Path(cli.__file__).absolute())
argv = [prog] + shlex.split(cmd_fmt)
Expand All @@ -49,3 +41,13 @@ def test_main(cmd: str, output: str | None, tmp_path: Path):

if output:
assert (tmp_path / output).exists()


@pytest.mark.skipif(sys.version_info < (3, 12), reason="Python < 3.12.")
@pytest.mark.parametrize("cmd", ["find {examples}"])
def test_main_find(cmd: str):
cmd_fmt = cmd.format(examples=BIDS_EXAMPLES)
prog = str(Path(cli.__file__).absolute())
argv = [prog] + shlex.split(cmd_fmt)
with patch_argv(argv):
cli.main()
Loading
Loading