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
5 changes: 3 additions & 2 deletions docs/FORMAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ A file claiming this convention must satisfy, in increasing strictness:
4. **Video constraints**: every `foxglove.CompressedVideo` message is one Annex B access unit beginning with an AUD; every IDR access unit contains SPS and PPS; no B-frames; `format="h264"`.
5. **Stamps**: `provenance/v1` present with `schema_version` and `pipeline_version`.

`hflow doctor <file.mcap>` executes these checks and exits with status 0 for
a conforming file or 1 when it reports violations.
`hflow doctor <file.mcap> [more.mcap ...]` executes these checks against every
file given, printing one report each, and exits with status 0 when all files
conform or 1 when any reports violations.

## References

Expand Down
24 changes: 15 additions & 9 deletions src/hflow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ def _build_parser() -> argparse.ArgumentParser:
description=(
"Validate container integrity, metadata stamps, chunk-group layout, "
"and in-band video constraints (docs/FORMAT.md, executable form). "
"Exit code 0 when conforming, 1 when not."
"Accepts multiple files; exit code 0 when all conform, 1 when any does not."
),
)
doctor_parser.add_argument("file", help="the local path or object-store URL to check")
doctor_parser.add_argument(
"file", nargs="+", help="the local paths or object-store URLs to check"
)

up_parser = subparsers.add_parser(
"up",
Expand Down Expand Up @@ -483,13 +485,17 @@ def _command_curate(arguments: argparse.Namespace) -> int:


def _command_doctor(arguments: argparse.Namespace) -> int:
try:
doctor_report = diagnose(arguments.file)
except (ValueError, FileNotFoundError) as error:
print(f"doctor: {error}", file=sys.stderr)
return 2
print(doctor_report.summary())
return 0 if doctor_report.conforming else 1
exit_code = 0
for file in arguments.file:
try:
doctor_report = diagnose(file)
except (ValueError, FileNotFoundError) as error:
print(f"doctor: {error}", file=sys.stderr)
return 2
print(doctor_report.summary())
if not doctor_report.conforming:
exit_code = 1
return exit_code


def main(argv: list[str] | None = None) -> int:
Expand Down
10 changes: 10 additions & 0 deletions tests/test_doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ def test_cli_doctor_exit_codes(
assert cli_main(["doctor", str(bogus)]) == 1
assert "NOT CONFORMING" in capsys.readouterr().out

assert cli_main(["doctor", str(canonical_episode), str(canonical_episode)]) == 0
both_conforming = capsys.readouterr().out
assert both_conforming.count(str(canonical_episode)) == 2
assert "NOT CONFORMING" not in both_conforming

assert cli_main(["doctor", str(canonical_episode), str(bogus)]) == 1
mixed = capsys.readouterr().out
assert str(canonical_episode) in mixed
assert str(bogus) in mixed


def test_cli_doctor_missing_file_prints_one_line(capsys: pytest.CaptureFixture[str]) -> None:
missing = "C:/definitely/not/here.mcap"
Expand Down