Skip to content

Commit

Permalink
Merge pull request #1513 from rly/enhance_pynwb_validation
Browse files Browse the repository at this point in the history
Enhance pynwb validation parsing to report the path within the file, fix pynwb typo
  • Loading branch information
yarikoptic authored Oct 14, 2024
2 parents 8ec8db5 + 2046eb8 commit 6aa414c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions dandi/pynwb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,18 +360,19 @@ def validate(path: str | Path, devel_debug: bool = False) -> list[ValidationResu
else: # Fallback if an older version
with pynwb.NWBHDF5IO(path=path, mode="r", load_namespaces=True) as reader:
error_outputs = pynwb.validate(io=reader)
for error_output in error_outputs:
for error in error_outputs:
errors.append(
ValidationResult(
origin=ValidationOrigin(
name="pynwb",
version=pynwb.__version__,
),
severity=Severity.WARNING,
id=f"pywnb.{error_output}",
severity=Severity.ERROR,
id=f"pynwb.{error}",
scope=Scope.FILE,
path=Path(path),
message="Failed to validate.",
message=f"Failed to validate. {error.reason}",
within_asset_paths={path: error.location},
)
)
except Exception as exc:
Expand All @@ -384,7 +385,7 @@ def validate(path: str | Path, devel_debug: bool = False) -> list[ValidationResu
version=pynwb.__version__,
),
severity=Severity.ERROR,
id="pywnb.GENERIC",
id="pynwb.GENERIC",
scope=Scope.FILE,
path=Path(path),
message=f"{exc}",
Expand Down Expand Up @@ -416,7 +417,7 @@ def validate(path: str | Path, devel_debug: bool = False) -> list[ValidationResu
version=pynwb.__version__,
),
severity=Severity.ERROR,
id="pywnb.GENERIC",
id="pynwb.GENERIC",
scope=Scope.FILE,
path=Path(path),
message=e,
Expand Down
2 changes: 1 addition & 1 deletion dandi/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def simple4_nwb(tmp_path_factory: pytest.TempPathFactory) -> Path:
def simple5_nwb(tmp_path_factory: pytest.TempPathFactory) -> Path:
"""
With subject, subject_id, species, but including data orientation ambiguity, and missing
the `pywnb.Timeseries` `unit` attribute.
the `pynwb.Timeseries` `unit` attribute.
Notes
-----
Expand Down

0 comments on commit 6aa414c

Please sign in to comment.