Skip to content

Commit d3476d0

Browse files
Merge branch 'master' into enh-lad-errors-api
2 parents 30450c9 + 2d10167 commit d3476d0

4 files changed

Lines changed: 34 additions & 5 deletions

File tree

dandi/dandiset.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ def __init__(
4242
if not allow_empty and not os.path.lexists(
4343
self.path_obj / dandiset_metadata_file
4444
):
45-
raise ValueError(f"No dandiset at {path}")
45+
raise ValueError(
46+
f"No dandiset at {path}. "
47+
f"The directory does not contain a '{dandiset_metadata_file}' file. "
48+
"Use 'dandi download' to download a dandiset or check the path."
49+
)
4650
self.metadata: dict | None = None
4751
self._metadata_file_obj = self.path_obj / dandiset_metadata_file
4852
self._load_metadata()
@@ -139,11 +143,17 @@ def _get_identifier(metadata: dict) -> str | None:
139143
@property
140144
def identifier(self) -> str:
141145
if self.metadata is None:
142-
raise ValueError("No metadata record found in Dandiset")
146+
raise ValueError(
147+
f"No metadata record found in Dandiset at {self.path}. "
148+
f"The '{dandiset_metadata_file}' file may be empty or corrupted. "
149+
"Use 'dandi download' to re-download the dandiset metadata."
150+
)
143151
id_ = self._get_identifier(self.metadata)
144152
if not id_:
145153
raise ValueError(
146-
f"Found no dandiset.identifier in metadata record: {self.metadata}"
154+
f"Found no dandiset.identifier in metadata record. "
155+
f"The '{dandiset_metadata_file}' file must contain an 'identifier' field. "
156+
f"Metadata: {self.metadata}"
147157
)
148158
return id_
149159

dandi/pynwb_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
"""Utilities for working with NWB (Neurodata Without Borders) files.
2+
3+
This module provides helper functions for reading, validating, and extracting
4+
metadata from NWB files using PyNWB. Features include:
5+
- NWB file I/O with caching
6+
- Metadata extraction for DANDI schema
7+
- Version compatibility checking
8+
- External link detection
9+
- Validation against NWB standards
10+
"""
11+
112
from __future__ import annotations
213

314
from collections import Counter

dandi/upload.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from collections.abc import Iterator, Sequence
55
from contextlib import ExitStack
66
from enum import Enum
7-
from functools import reduce
87
import io
98
import os.path
109
from pathlib import Path
@@ -493,7 +492,7 @@ def upload_agg(*ignored: Any) -> str:
493492
for p in paths:
494493
rp = os.path.relpath(p, dandiset.path)
495494
relpaths.append("" if rp == "." else rp)
496-
path_prefix = reduce(os.path.commonprefix, relpaths) # type: ignore[arg-type]
495+
path_prefix = os.path.commonprefix(relpaths)
497496
to_delete = []
498497
for asset in remote_dandiset.get_assets_with_path_prefix(path_prefix):
499498
if any(

dandi/validate.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
"""Validation of DANDI datasets against schemas and standards.
2+
3+
This module provides validation functionality for dandisets, including:
4+
- DANDI schema validation
5+
- BIDS standard validation
6+
- File layout and organization validation
7+
- Metadata completeness checking
8+
"""
9+
110
from __future__ import annotations
211

312
from collections.abc import Iterator

0 commit comments

Comments
 (0)