Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
18 changes: 18 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: pip
directory: /
schedule:
interval: monthly
groups:
production-dependencies:
dependency-type: production
development-dependencies:
dependency-type: development
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
28 changes: 17 additions & 11 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ name: CI

permissions:
contents: read
pull-requests: write

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
branches: [ "main" ]
branches: ["main"]

env:
UV_FROZEN: true
Expand All @@ -33,14 +32,15 @@ jobs:
needs: format
strategy:
matrix:
python-version: [ "3.11", "3.12", "3.13", "3.14" ]
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
with:
submodules: "true"
- uses: astral-sh/setup-uv@v8.1.0
with:
python-version: ${{ matrix.python-version }}
- run: uv sync --all-extras

- name: Run tests without cloudpathlib
run: |
Expand All @@ -53,7 +53,7 @@ jobs:

- name: Run tests with cloudpathlib
run: |
uv run --extra cloud pytest \
uv run pytest \
-m "cloud" \
--junitxml=pytest-cloud.xml \
--cov-report=xml:coverage.xml \
Expand All @@ -68,10 +68,16 @@ jobs:
pytest-cloud.xml \
pytest.xml

- name: Pytest coverage comment
if: github.event_name == 'pull_request' && matrix.python-version ==
env.COVERAGE_PYTHON
uses: MishaKav/pytest-coverage-comment@v1
- name: Record PR number
if: github.event_name == 'pull_request' && matrix.python-version == env.COVERAGE_PYTHON
run: echo "${{ github.event.number }}" > pr-number.txt

- uses: actions/upload-artifact@v7
if: github.event_name == 'pull_request' && matrix.python-version == env.COVERAGE_PYTHON
with:
pytest-xml-coverage-path: ./coverage.xml
junitxml-path: ./pytest.xml
name: coverage
retention-days: 1
path: |
coverage.xml
pytest.xml
pr-number.txt
33 changes: 33 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Coverage report

on:
workflow_run:
workflows: ["CI"]
types: [completed]

permissions:
pull-requests: write
actions: read

jobs:
coverage:
if: >-
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
name: coverage
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- id: pr
run: echo "number=$(cat pr-number.txt)" >> "$GITHUB_OUTPUT"

- name: Pytest coverage comment
uses: MishaKav/pytest-coverage-comment@v1
with:
issue-number: ${{ steps.pr.outputs.number }}
pytest-xml-coverage-path: ./coverage.xml
junitxml-path: ./pytest.xml
16 changes: 7 additions & 9 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: docs
name: docs

on:
workflow_run:
workflows: [CI]
types:
- completed
- completed
branches:
- main
- main

env:
UV_FROZEN: true
Expand All @@ -17,16 +17,14 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
pyproject-file: pyproject.toml
uses: astral-sh/setup-uv@v8.1.0
- name: Install the project
run: uv sync --all-extras
- name: Build docs
run: uv run pdoc -o docs/ -d google bids2table
- uses: actions/upload-pages-artifact@v3
- uses: actions/upload-pages-artifact@v5
with:
path: docs/

Expand All @@ -43,4 +41,4 @@ jobs:
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v5
6 changes: 2 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ jobs:
# IMPORTANT: this permission is mandatory for Trusted Publishing
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
pyproject-file: pyproject.toml
uses: astral-sh/setup-uv@v8.1.0
- name: Build project
run: |
uv sync --no-dev --no-install-project
Expand Down
4 changes: 4 additions & 0 deletions bids2table/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
"parse_bids_entities",
"validate_bids_entities",
"set_bids_schema",
"clear_schema_caches",
"get_bids_schema",
"get_bids_entity_arrow_schema",
"format_bids_path",
"load_bids_metadata",
"cloudpathlib_is_available",
"pybids",
]

from . import pybids
from ._entities import (
format_bids_path,
get_bids_entity_arrow_schema,
Expand All @@ -26,6 +29,7 @@
)
from ._indexing import (
batch_index_dataset,
clear_schema_caches,
find_bids_datasets,
get_arrow_schema,
get_column_names,
Expand Down
34 changes: 32 additions & 2 deletions bids2table/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,17 @@ def main():
nargs="+",
default=None,
help="List of subject names or glob patterns to only include in the index. "
"Only applies when indexing a single dataset.",
"Deprecated; use --filter instead.",
)
parser_index.add_argument(
"--filter",
"-f",
metavar="ENTITY=PATTERN",
type=str,
action="append",
default=None,
help="Filter indexed files by entity value (e.g. -f sub=sub-0* -f task=rest). "
"Can be specified multiple times.",
)
parser_index.add_argument(
"--workers",
Expand Down Expand Up @@ -114,10 +124,29 @@ def _index_command(args: argparse.Namespace):
else:
root.append(path)

# Build filters dict from --filter args
filters: dict[str, str | list[str]] | None = None
if args.filter:
filters = {}
for item in args.filter:
parts = item.split("=", maxsplit=1)
if len(parts) == 2:
filters[parts[0]] = parts[1]
else:
_logger.warning(
f"Ignoring malformed filter: '{item}' (expected ENTITY=PATTERN)"
)

# Merge deprecated --subjects into filters
if args.subjects:
if filters is None:
filters = {}
filters.setdefault("sub", args.subjects)

if len(root) == 1:
table = b2t2.index_dataset(
root[0],
include_subjects=args.subjects,
filters=filters,
show_progress=not args.no_progress,
)
pq.write_table(table, args.output)
Expand All @@ -135,6 +164,7 @@ def _index_command(args: argparse.Namespace):
max_workers=max_workers,
executor_cls=executor_cls,
show_progress=not args.no_progress,
filters=filters,
):
writer.write_table(table)

Expand Down
Loading