Add a structured issues model and emit findings from the filename validator

未关闭
#85 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

@karellopez 已经在做这个了。

开始于 2026年8月10日。

  • #86 来自 @karellopez —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

enhancement
Summary

Validation currently answers a yes/no question. BIDSValidator.is_bids() returns a
boolean, and the CLI prints one line per non-compliant file:

/sub-01/anat/oops.nii.gz is not a valid bids filename

That output carries no severity, no stable code, and no structure a program can consume.
It cannot be counted, filtered, serialised, or shown in a UI, and it cannot say why a
name is wrong.

context.py already anticipates this: ValidationError is a stub whose entire body is
"""TODO: Add issue structure.""".

Proposal

Two small pieces.

1. An issue model (bids_validator/issues.py). Pure data, no I/O, attrs to match
the convention already used by context.py, bidsignore.py and types/files.py:

  • Severity (error, warning)
  • Issue with code, severity, location, message, sub_code, rule
  • DatasetIssues, an ordered collection with add, extend, by_severity,
    has_errors, __len__, __iter__

Field names mirror the reference validator so output stays interchangeable.

2. Emit findings from filename validation. Rather than one blanket answer, report the
specific reason using the reference validator's codes: NOT_INCLUDED,
MISSING_REQUIRED_ENTITY, ENTITY_NOT_IN_RULE, ENTITY_WITH_NO_LABEL,
INVALID_ENTITY_LABEL, EXTENSION_MISMATCH, DATATYPE_MISMATCH, INVALID_LOCATION,
FILENAME_MISMATCH, ALL_FILENAME_RULES_HAVE_ISSUES.

Scope is names and paths only. No file contents are read.

BIDSValidator.is_bids() stays untouched, since pybids and mne-bids depend on it.

Why this first

Every later check needs somewhere to report to. Content validation (sidecar fields, NIfTI
headers, tabular columns) produces the same Issue type into the same DatasetIssues,
so the output contract is defined once and does not change as coverage grows.

Questions for maintainers
  1. Is the minimal field set above right, or do you want the reference validator's richer
    fields (rule provenance, machine-actionable fixes, an ignore severity, line spans)
    from the start? I kept them out to keep the first PR small.
  2. The CLI currently prints <path> is not a valid bids filename for each bad file.
    When these findings are wired into it, should that output change to show the
    specific code and reason, or should the current text stay the default with the
    structured output behind a flag? Changing it would be more useful but would break
    anyone parsing the current output.
  3. Any preference on module naming (issues.py / filename_checks.py)?

I have a working implementation with tests and am happy to open a PR, or to adjust the
shape first if you would prefer a different design.

主要语言
Python
星标
10
派生
7
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

bids-standard/python-validator 的其他 Issue

查看 bids-standard/python-validator 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。