Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions dandi/files/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ def find_dandi_files(
they are of a type represented by a `LocalDirectoryAsset` subclass, in
which case they are not recursed into.

All requested paths are checked before any files are yielded. A missing
path raises `FileNotFoundError`; a broken symlink is still discovered so
that the caller can apply its missing-content policy.
All requested paths are checked before any files are yielded. Because this
function is a generator, a missing path raises `FileNotFoundError` when
the iterator is first advanced, not when the function is called. A broken
symlink is still discovered so that the caller can apply its
missing-content policy.

.. versionchanged:: 0.82.0
Missing requested paths now raise `FileNotFoundError` on iteration.

:param dandiset_path:
The path to the root of the Dandiset in which the paths are located.
Expand Down
12 changes: 12 additions & 0 deletions dandi/validate/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ def test_validate_empty(tmp_path: Path) -> None:
]


@pytest.mark.ai_generated
@pytest.mark.parametrize("use_path", [False, True])
def test_validate_missing_path(tmp_path: Path, use_path: bool) -> None:
(tmp_path / dandiset_metadata_file).write_text("identifier: 123456\n")
missing = tmp_path / "missing.nwb"
requested_path = missing if use_path else str(missing)

with pytest.raises(FileNotFoundError) as exc:
list(validate(requested_path))
assert exc.value.filename == str(missing)


def test_validate_just_dandiset_yaml(tmp_path: Path) -> None:
(tmp_path / dandiset_metadata_file).write_text(
"identifier: 12346\nname: Foo\ndescription: Dandiset Foo\n"
Expand Down
Loading