Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

When BIDS validator encounters dandiset.yaml (not part of BIDS spec), users now receive both the ERROR and a HINT suggesting to add the file to .bidsignore.

Changes

dandi/validate.py

  • After yielding dandiset.yaml ERROR, now yields additional HINT ValidationResult
  • HINT ID: DANDI.BIDSIGNORE_DANDISET_YAML, severity: Severity.HINT, scope: DATASET
  • Provides actionable message with exact line to add to .bidsignore

dandi/tests/test_validate.py

  • Enhanced test_validate_bids() to verify both ERROR and HINT are generated
  • Validates HINT properties and message content

Example Output

# ERROR (unchanged) ValidationResult( id="BIDS.NON_BIDS_PATH_PLACEHOLDER", severity=Severity.ERROR, message="The dandiset metadata file, `dandiset.yaml`, is not a part of BIDS specification..." ) # HINT (new) ValidationResult( id="DANDI.BIDSIGNORE_DANDISET_YAML", severity=Severity.HINT, message="Consider creating or updating a `.bidsignore` file in the root of your BIDS dataset to ignore `dandiset.yaml`. Add the following line to `.bidsignore`:\ndandiset.yaml" )
Original prompt

This section details on the original issue you should resolve

<issue_title>Hint user to create .bidsignore listing dandiset.yaml</issue_title>
<issue_description>Inspired by

When processing validation errors from bids-validator, seeing the error about dandiset.yaml being not part of BIDS specification, follow it with a HINT level validation result which would suggest to add dandiset.yaml into .bidsignore file. Solution should be accompanied with the unit test so we maintain consistent operation happen generation of validation messages changes for some reason</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add hint for user to create .bidsignore for dandiset.yaml Add HINT validation result suggesting .bidsignore for dandiset.yaml Nov 12, 2025
Copilot AI requested a review from yarikoptic November 12, 2025 21:08
@codecov
Copy link

codecov bot commented Nov 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.05%. Comparing base (3501190) to head (957da04).

Additional details and impacted files
@@ Coverage Diff @@ ## master #1741 +/- ## ========================================== + Coverage 75.02% 75.05% +0.02%  ========================================== Files 84 84 Lines 11889 11900 +11 ========================================== + Hits 8920 8931 +11  Misses 2969 2969 
Flag Coverage Δ
unittests 75.05% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.
@yarikoptic yarikoptic added the patch Increment the patch version when merged label Dec 4, 2025
@yarikoptic yarikoptic marked this pull request as ready for review December 11, 2025 12:10
When BIDS validator encounters dandiset.yaml (not part of BIDS spec), now: - Keeps the existing ERROR about the file not matching BIDS patterns - Adds a new HINT level validation result suggesting to create/update .bidsignore Includes test to verify both ERROR and HINT are generated Co-authored-by: yarikoptic <39889+yarikoptic@users.noreply.github.com>
@yarikoptic yarikoptic force-pushed the copilot/add-hint-for-dandiset-yaml branch from 5d5dd81 to 957da04 Compare December 11, 2025 12:10
@candleindark
Copy link
Member

@yarikoptic I don't get the point of this or #1740. If we don't want the problem with dandiset.yaml to show up as an error to the user, you can just modify the error originated from deno BIDS validator into a hint (we have already modified its message). Why add this additionally hint, which is a duplication and makes the structure of the code a bit awkward? If the reason for this duplication is that you want to preserve some information about the origin of the validation result, this is still unnecessary because we have the origin attribute in a ValidationResult object.

@yarikoptic
Copy link
Member

We don't want to "cheat" bids validator, so if people run it directly they get the same result. AI we want to instruct for to mitigate that error consistently

@asmacdo
Copy link
Member

asmacdo commented Dec 12, 2025

Tested against dandiset 001442 (chosen because it is a smallish BIDS dataset, though lots of validation noise).

The PR works as described - the [DANDI.BIDSIGNORE_DANDISET_YAML] HINT now appears after the [BIDS.NOT_INCLUDED] error:

[BIDS.NOT_INCLUDED] .../dandiset.yaml — The dandiset metadata file... [DANDI.BIDSIGNORE_DANDISET_YAML] ... — Consider creating or updating a `.bidsignore`... 

IMO this is fine, the HINT probably will be easier to understand for unfamiliar users, even though the duplication and extra noise are somewhat undesirable.

trimmed raw output: master branch
2025-12-12 12:57:53,797 [ WARNING] No BIDS reference root provided. 2025-12-12 12:57:53,797 [ INFO] No schema path specified, defaulting to the bundled schema, `/home/austin/devel/dandi-cli/venvs/dev3/lib/python3.13/site-packages/bidsschematools/data/schema.json`. 2025-12-12 12:57:53,889 [ INFO] SUCCESS: All files are BIDS valid and no BIDS-required files are missing. 2025-12-12 12:57:53,889 [ INFO] No schema path specified, defaulting to the bundled schema, `/home/austin/devel/dandi-cli/venvs/dev3/lib/python3.13/site-packages/bidsschematools/data/schema.json`. [BIDS.NOT_INCLUDED] /home/austin/devel/dandi-cli/001442/dandiset.yaml — The dandiset metadata file, `dandiset.yaml`, is not a part of BIDS specification. Please include a `.bidsignore` file with specification to ignore the metadata file in your dataset. For more details, see https://github.com/bids-standard/bids-specification/issues/131#issuecomment-461060166. [BIDS.JSON_KEY_RECOMMENDED] /home/austin/devel/dandi-cli/001442/dataset_description.json — A JSON file is missing a key listed as recommended. subCode: GeneratedBy issueMessage: Field description: Used to specify provenance of the dataset. [BIDS.JSON_KEY_RECOMMENDED] /home/austin/devel/dandi-cli/001442/dataset_description.json — A JSON file is missing a key listed as recommended. subCode: SourceDatasets issueMessage: Field description: Used to specify the locations and relevant attributes of all source datasets. Valid keys in each object include `"URL"`, `"DOI"` (see [URI](SPEC_ROOT/common-principles.md#uniform-resource-indicator)), and `"Version"` with [string](https://www.w3schools.com/js/js_json_datatypes.asp) values. [BIDS.SIDECAR_KEY_RECOMMENDED] /home/austin/devel/dandi-cli/001442/sub-rat1/micr/sub-rat1_sample-data1_SEM.png — A data file's JSON sidecar is missing a key listed as recommended. subCode: Manufacturer issueMessage: Field description: Manufacturer of the equipment that produced the measurements. [BIDS.SIDECAR_KEY_RECOMMENDED] /home/austin/devel/dandi-cli/001442/sub-rat1/micr/sub-rat1_sample-data1_SEM.png — A data file's JSON sidecar is missing a key listed as recommended. subCode: ManufacturersModelName issueMessage: Field description: Manufacturer's model name of the equipment that produced the measurements. [... 600+ more BIDS.SIDECAR_KEY_RECOMMENDED warnings ...] 2025-12-12 12:57:54,386 [ INFO] Logs saved in /home/austin/.local/state/dandi-cli/log/2025.12.12-18.57.53Z-217494.log 
trimmed output: PR branch
2025-12-12 12:58:27,284 [ WARNING] No BIDS reference root provided. 2025-12-12 12:58:27,284 [ INFO] No schema path specified, defaulting to the bundled schema, `/home/austin/devel/dandi-cli/venvs/dev3/lib/python3.13/site-packages/bidsschematools/data/schema.json`. 2025-12-12 12:58:27,375 [ INFO] SUCCESS: All files are BIDS valid and no BIDS-required files are missing. 2025-12-12 12:58:27,375 [ INFO] No schema path specified, defaulting to the bundled schema, `/home/austin/devel/dandi-cli/venvs/dev3/lib/python3.13/site-packages/bidsschematools/data/schema.json`. [BIDS.NOT_INCLUDED] /home/austin/devel/dandi-cli/001442/dandiset.yaml — The dandiset metadata file, `dandiset.yaml`, is not a part of BIDS specification. Please include a `.bidsignore` file with specification to ignore the metadata file in your dataset. For more details, see https://github.com/bids-standard/bids-specification/issues/131#issuecomment-461060166. [DANDI.BIDSIGNORE_DANDISET_YAML] /home/austin/devel/dandi-cli/001442 — Consider creating or updating a `.bidsignore` file in the root of your BIDS dataset to ignore `dandiset.yaml`. Add the following line to `.bidsignore`: dandiset.yaml [BIDS.JSON_KEY_RECOMMENDED] /home/austin/devel/dandi-cli/001442/dataset_description.json — A JSON file is missing a key listed as recommended. subCode: GeneratedBy issueMessage: Field description: Used to specify provenance of the dataset. [BIDS.JSON_KEY_RECOMMENDED] /home/austin/devel/dandi-cli/001442/dataset_description.json — A JSON file is missing a key listed as recommended. subCode: SourceDatasets issueMessage: Field description: Used to specify the locations and relevant attributes of all source datasets. Valid keys in each object include `"URL"`, `"DOI"` (see [URI](SPEC_ROOT/common-principles.md#uniform-resource-indicator)), and `"Version"` with [string](https://www.w3schools.com/js/js_json_datatypes.asp) values. [BIDS.SIDECAR_KEY_RECOMMENDED] /home/austin/devel/dandi-cli/001442/sub-rat1/micr/sub-rat1_sample-data1_SEM.png — A data file's JSON sidecar is missing a key listed as recommended. subCode: Manufacturer issueMessage: Field description: Manufacturer of the equipment that produced the measurements. [BIDS.SIDECAR_KEY_RECOMMENDED] /home/austin/devel/dandi-cli/001442/sub-rat1/micr/sub-rat1_sample-data1_SEM.png — A data file's JSON sidecar is missing a key listed as recommended. subCode: ManufacturersModelName issueMessage: Field description: Manufacturer's model name of the equipment that produced the measurements. [... 600+ more BIDS.SIDECAR_KEY_RECOMMENDED warnings ...] 2025-12-12 12:58:27,857 [ INFO] Logs saved in /home/austin/.local/state/dandi-cli/log/2025.12.12-18.58.26Z-217682.log 
Diff between master and branch
5a6,7 > [DANDI.BIDSIGNORE_DANDISET_YAML] /home/austin/devel/dandi-cli/001442 — Consider creating or updating a `.bidsignore` file in the root of your BIDS dataset to ignore `dandiset.yaml`. Add the following line to `.bidsignore`: > dandiset.yaml
Copy link
Member

@candleindark candleindark left a comment

Choose a reason for hiding this comment

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

Proposed some changes.

Additionally, if we want this custom validation hint to show up in the dandi upload command as well, we need to move this logic to an earlier point the in the calling process. The current setup only affect dandi validate not dandi upload where the issue was originally reported at #1734 (comment).

Comment on lines 198 to 206
if is_dandiset_yaml_error:
r.message = (
f"The dandiset metadata file, `{dandiset_metadata_file}`, "
f"is not a part of BIDS specification. Please include a "
f"`.bidsignore` file with specification to ignore the "
f"metadata file in your dataset. For more details, see "
f"https://github.com/bids-standard/bids-specification/"
f"issues/131#issuecomment-461060166."
)
Copy link
Member

Choose a reason for hiding this comment

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

Since we now have a separate hind for to suggest for modifying .bidsignore, and we want to preserve the original error from BIDS deno validator as much as possible, we can remove this modification of the original error message.

Comment on lines +213 to +228
hint = ValidationResult(
id="DANDI.BIDSIGNORE_DANDISET_YAML",
origin=ORIGIN_VALIDATION_DANDI_LAYOUT,
severity=Severity.HINT,
scope=Scope.DATASET,
path=r.dataset_path,
dataset_path=r.dataset_path,
dandiset_path=dandiset_path,
message=(
f"Consider creating or updating a `.bidsignore` file "
f"in the root of your BIDS dataset to ignore "
f"`{dandiset_metadata_file}`. "
f"Add the following line to `.bidsignore`:\n"
f"{dandiset_metadata_file}"
),
)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
hint = ValidationResult(
id="DANDI.BIDSIGNORE_DANDISET_YAML",
origin=ORIGIN_VALIDATION_DANDI_LAYOUT,
severity=Severity.HINT,
scope=Scope.DATASET,
path=r.dataset_path,
dataset_path=r.dataset_path,
dandiset_path=dandiset_path,
message=(
f"Consider creating or updating a `.bidsignore` file "
f"in the root of your BIDS dataset to ignore "
f"`{dandiset_metadata_file}`. "
f"Add the following line to `.bidsignore`:\n"
f"{dandiset_metadata_file}"
),
)
hint = ValidationResult(
id="DANDI.BIDSIGNORE_DANDISET_YAML",
origin=ORIGIN_VALIDATION_DANDI_LAYOUT,
scope=Scope.DATASET,
origin_result=r,
severity=Severity.HINT,
dandiset_path=r.dandiset_path,
dataset_path=r.dataset_path,
path=r.path,
message=(
f"Consider creating or updating a `.bidsignore` file "
f"in the root of your BIDS dataset to ignore "
f"`{dandiset_metadata_file}`. "
f"Add the following line to `.bidsignore`:\n"
f"{dandiset_metadata_file}"
),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

4 participants