Skip to content

Commit

Permalink
Incremental deprecation of direct upstream output format
Browse files Browse the repository at this point in the history
  • Loading branch information
TheChymera committed Sep 2, 2022
1 parent 7ff8a88 commit afa56ac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
33 changes: 17 additions & 16 deletions dandi/files/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,26 @@ def _validate(self) -> None:
# TODO gh-943: use RFed data structures, avoid duplicating logic
results = validate_bids(*bids_paths)
self._dataset_errors: list[str] = []
# TODO gh-943: Should we add valid files to Validation result?
# This specific check seems difficult to implement.
# if len(results["path_listing"]) == len(results["path_tracking"]):
# self._dataset_errors.append("No valid BIDS files were found")
for entry in results["schema_tracking"]:
if entry["mandatory"]:
self._asset_errors = defaultdict(list)
for i in results:
if i.id == "BIDS.NON_BIDS_PATH_PLACEHOLDER":
bids_path = Path(i.path).relative_to(self.bids_root).as_posix()
self._dataset_errors.append(
f"The `{bids_path}` file was not matched by any regex schema entry."
)
self._asset_errors[bids_path].append(
"File not matched by any regex schema entry"
)
elif i.id == "BIDS.MANDATORY_FILE_MISSING_PLACEHOLDER":
self._dataset_errors.append(
f"The `{entry['regex']}` regex pattern file"
f"The `{i.regex}` regex pattern file"
" required by BIDS was not found."
)
self._asset_errors = defaultdict(list)
for path in results["path_tracking"]:
bids_path = Path(path).relative_to(self.bids_root).as_posix()
self._dataset_errors.append(
f"The `{bids_path}` file was not matched by any regex schema entry."
)
self._asset_errors[bids_path].append(
"File not matched by any regex schema entry"
)

# TODO gh-943: Should we add valid files to Validation result?
# The following checks seem difficult to implement.
if len(results["path_listing"]) == len(results["path_tracking"]):
self._dataset_errors.append("No valid BIDS files were found")
self._asset_metadata = defaultdict(dict)
for meta in results["match_listing"]:
bids_path = (
Expand Down
2 changes: 2 additions & 0 deletions dandi/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ValidationResult:
# TODO gh-943: should this be relative to `dataset_path`?
# would make writing tests with tmp paths a lot easier :3
path: Optional[Path] = None
regex: Optional[str] = None
asset_paths: Optional[list[str]] = None


Expand Down Expand Up @@ -128,6 +129,7 @@ def validate_bids(
# https://github.com/bids-standard/bids-specification/issues/1262
id="BIDS.MANDATORY_FILE_MISSING_PLACEHOLDER",
scope=Scope.FILE,
regex=pattern["regex"],
message="BIDS-required file is not present.",
# TODO - discover dandiset or actually BIDS dataset
# might want separate the two
Expand Down

0 comments on commit afa56ac

Please sign in to comment.