From 2046eb830f820f9f0bbb6617aec9992a8b68ebc2 Mon Sep 17 00:00:00 2001 From: Ryan Ly Date: Thu, 3 Oct 2024 18:38:07 -0700 Subject: [PATCH] Enhance pynwb validation parsing, fix pynwb typo --- dandi/pynwb_utils.py | 13 +++++++------ dandi/tests/fixtures.py | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dandi/pynwb_utils.py b/dandi/pynwb_utils.py index e280c6ab7..f93b736ea 100644 --- a/dandi/pynwb_utils.py +++ b/dandi/pynwb_utils.py @@ -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: @@ -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}", @@ -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, diff --git a/dandi/tests/fixtures.py b/dandi/tests/fixtures.py index d8bb91062..7e16ce3b1 100644 --- a/dandi/tests/fixtures.py +++ b/dandi/tests/fixtures.py @@ -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 -----