Skip to content

Conversation

@astewartau
Copy link

This is my first PR as a BIDS maintainer. Appreciate any feedback! This attempts to address #818.

Summary

  • Implement schema-driven BIDSLayout configuration loading
  • Enables version-specific schema loading via bidsschematools
  • Existing JSON-based config is unchanged

Implementation

  • Added Config._from_schema() method that loads schema via bidsschematools.schema.load_schema()
  • Support remote schema loading from versioned URLs (e.g., https://bids-specification.readthedocs.io/en/v1.9.0/schema.json)
  • Extract entity names from schema file rules across raw/deriv/common sections using rules.regexify_filename_rules()
  • Generate Entity objects with regex patterns derived from schema format definitions (bids_schema.objects.formats)
  • Combine BIDS entity prefixes with schema format patterns (e.g., sub- + [0-9a-zA-Z]+ for subjects)
  • Special entities (suffix, extension, datatype) still require some special handling logic

Usage

# Load from current schema
config = Config.load('bids-schema')

# Load specific BIDS version
config = Config.load({'schema_version': '1.9.0'})

@astewartau astewartau closed this Sep 9, 2025
@astewartau astewartau deleted the schema-integration branch September 9, 2025 06:35
@codecov
Copy link

codecov bot commented Sep 9, 2025

Codecov Report

❌ Patch coverage is 90.97345% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.48%. Comparing base (5e6a949) to head (3526710).

Files with missing lines Patch % Lines
...ids/layout/tests/test_schema_pattern_validation.py 77.55% 10 Missing and 12 partials ⚠️
...rc/bids/layout/tests/test_schema_vs_json_config.py 88.19% 8 Missing and 11 partials ⚠️
src/bids/layout/layout.py 93.93% 0 Missing and 4 partials ⚠️
src/bids/layout/tests/test_schema_config.py 94.52% 1 Missing and 3 partials ⚠️
src/bids/layout/models.py 97.93% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1163      +/-   ##
==========================================
+ Coverage   89.37%   89.48%   +0.11%     
==========================================
  Files          66       70       +4     
  Lines        7276     7828     +552     
  Branches      854      951      +97     
==========================================
+ Hits         6503     7005     +502     
- Misses        565      584      +19     
- Partials      208      239      +31     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@astewartau astewartau reopened this Sep 9, 2025
@astewartau astewartau closed this Sep 9, 2025
@astewartau astewartau reopened this Sep 9, 2025
@astewartau astewartau marked this pull request as draft September 9, 2025 06:52
@astewartau astewartau marked this pull request as ready for review September 9, 2025 06:53
@bendhouseart
Copy link

Awesome, will start with trying the notebook!

Copy link

@bendhouseart bendhouseart left a comment

Choose a reason for hiding this comment

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

Sold!

Legacy initialization: 1.531 seconds
Schema initialization: 1.282 seconds

Difference: 0.249 seconds
Schema is faster by 16.3%

Get the CI passing and will approve, although I think folks will want to increase coverage, so maybe that too?

astewartau and others added 7 commits September 23, 2025 13:06
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "uv lock",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [
  "pyproject.toml"
 ],
 "outputs": [
  "uv.lock"
 ],
 "pwd": "."
}
^^^ Do not change lines above ^^^
@astewartau
Copy link
Author

Hi @bendhouseart, I've improved code coverage, and CI looks to be passing. :)

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.

3 participants