Skip to content

Commit 3844271

Browse files
committed
Merge branch 'claude/validate-broken-symlink-path' into claude/brave-hamilton-ast647
The PR is now stacked on the broken-symlink fix, which carries its own copy of `ExistingPath` and its test; take that branch's docstring and extended test and keep this branch's streaming test alongside. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFhMPs6vF5zyeHDvPTvRcA
2 parents c5dc085 + 4f316f7 commit 3844271

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎dandi/cli/cmd_validate.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ class TruncationNotice:
3838
class ExistingPath(click.Path):
3939
"""
4040
Like ``click.Path(exists=True)``, but also accepting broken symbolic links,
41-
such as annexed files whose content is not present, which ``dandi validate``
42-
knows how to handle (see ``--missing-file-content``)
41+
such as the annexed files of a DataLad dataset whose content has not been
42+
fetched. ``click.Path(exists=True)`` follows the link and rejects those as
43+
nonexistent, which prevented the ``--missing-file-content`` policies
44+
(``error``, ``skip``, ``only-non-data``) from ever being applied to a file
45+
given directly on the command line rather than via its directory.
4346
"""
4447

4548
def convert(

‎dandi/cli/tests/test_cmd_validate.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,12 +1044,21 @@ def test_validate_missing_file_content_stream(
10441044

10451045
@pytest.mark.ai_generated
10461046
def test_validate_broken_symlink_path_argument(tmp_path: Path) -> None:
1047-
"""A broken symlink can be given directly as a path to validate."""
1047+
"""A broken symlink can be given directly as a path to validate.
1048+
1049+
The --missing-file-content policies then apply to it just as they do when
1050+
the containing directory is given.
1051+
"""
10481052
ds = _make_dandiset_with_broken_symlinks(tmp_path)
1049-
r = CliRunner().invoke(validate, [str(ds / "sub-001" / "sub-001.nwb")])
1053+
link = ds / "sub-001" / "sub-001.nwb"
1054+
r = CliRunner().invoke(validate, [str(link)])
10501055
assert r.exit_code == 1
10511056
assert "does not exist" not in r.output
10521057
assert "FILE_CONTENT_MISSING" in r.output
1058+
r = CliRunner().invoke(validate, ["--missing-file-content", "skip", str(link)])
1059+
assert r.exit_code == 0
1060+
assert "FILE_CONTENT_MISSING_SKIPPED" in r.output
1061+
# Paths that truly do not exist are still rejected
10531062
r = CliRunner().invoke(validate, [str(ds / "sub-001" / "nonexistent.nwb")])
10541063
assert r.exit_code == 2
10551064
assert "does not exist" in r.output

0 commit comments

Comments
 (0)