|
13 | 13 |
|
14 | 14 | from .bases import GenericAsset, LocalFileAsset, NWBAsset |
15 | 15 | from .zarr import ZarrAsset |
16 | | -from ..consts import ZARR_MIME_TYPE |
| 16 | +from ..consts import ZARR_MIME_TYPE, dandiset_metadata_file |
17 | 17 | from ..metadata.core import add_common_metadata, prepare_metadata |
18 | 18 | from ..misctypes import Digest |
19 | | -from ..validate_types import ValidationResult |
| 19 | +from ..validate_types import ( |
| 20 | + ORIGIN_VALIDATION_DANDI_LAYOUT, |
| 21 | + Scope, |
| 22 | + Severity, |
| 23 | + ValidationResult, |
| 24 | +) |
20 | 25 |
|
21 | 26 | BIDS_ASSET_ERRORS = ("BIDS.NON_BIDS_PATH_PLACEHOLDER",) |
22 | 27 | BIDS_DATASET_ERRORS = ("BIDS.MANDATORY_FILE_MISSING_PLACEHOLDER",) |
@@ -112,7 +117,42 @@ def _validate(self) -> None: |
112 | 117 |
|
113 | 118 | # Obtain BIDS validation results of the entire dataset through the |
114 | 119 | # deno-compiled BIDS validator |
115 | | - self._dataset_errors = bids_validate(self.bids_root) |
| 120 | + v_results = bids_validate(self.bids_root) |
| 121 | + |
| 122 | + # Validation results from the deno BIDS validator with an additional |
| 123 | + # hint, represented as a `ValidationResult` object, following |
| 124 | + # each `dandiset.yaml` error, suggesting to add the `dandiset.yaml` file |
| 125 | + # to `.bidsignore`. |
| 126 | + v_results_extended: list[ValidationResult] = [] |
| 127 | + |
| 128 | + for result in v_results: |
| 129 | + v_results_extended.append(result) |
| 130 | + if ( |
| 131 | + result.path is not None |
| 132 | + and result.dataset_path is not None |
| 133 | + and result.path.relative_to(result.dataset_path).as_posix() |
| 134 | + == dandiset_metadata_file |
| 135 | + ): |
| 136 | + hint = ValidationResult( |
| 137 | + id="DANDI.BIDSIGNORE_DANDISET_YAML", |
| 138 | + origin=ORIGIN_VALIDATION_DANDI_LAYOUT, |
| 139 | + scope=Scope.DATASET, |
| 140 | + origin_result=result, |
| 141 | + severity=Severity.HINT, |
| 142 | + dandiset_path=result.dandiset_path, |
| 143 | + dataset_path=result.dataset_path, |
| 144 | + path=result.path, |
| 145 | + message=( |
| 146 | + f"Consider creating or updating a `.bidsignore` file " |
| 147 | + f"in the root of your BIDS dataset to ignore " |
| 148 | + f"`{dandiset_metadata_file}`. " |
| 149 | + f"Add the following line to `.bidsignore`:\n" |
| 150 | + f"{dandiset_metadata_file}" |
| 151 | + ), |
| 152 | + ) |
| 153 | + v_results_extended.append(hint) |
| 154 | + |
| 155 | + self._dataset_errors = v_results_extended |
116 | 156 |
|
117 | 157 | # Categorized validation results related to individual assets by the |
118 | 158 | # path of the asset in the BIDS dataset |
|
0 commit comments