Make doctor crash-proof and inspect tolerant of incomplete runs - #13
Merged
Conversation
End-to-end audit of the recently added features surfaced two robustness/UX bugs in the new diagnostics commands (rest verified OK): - doctor: collect_doctor_checks ran each check unguarded, so a throwing check (e.g. a broken PyBullet/headless env in _examples_check) crashed the command with a raw traceback — exactly when it should diagnose the failure. Each check now runs through a `_safe` guard that turns an exception into a `warn` row. - inspect: it called runs.load_run, which unconditionally reads creature.json (which inspect never uses), so a missing path or a run dir / trace.json without a sibling creature.json raised a raw FileNotFoundError. It now loads only the trace (+ optional task.json) via the friendly _load_spec / _load_task_for_trace helpers: missing path exits 2; a creature-less run dir still summarizes. Tests: doctor stays crash-free when a check raises (returns a warn row); inspect exits 2 on a missing path and summarizes a trace-only run dir. All green: ruff, ruff format --check, pytest (131). https://claude.ai/code/session_01EcH4uu86dMEDrd6TzyAExd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
End-to-end bug audit of the recently enabled features (reproducible run metadata, validation, normalization, viewer fidelity,
doctor,inspect/EpisodeSummary, stored warnings, duration/naming fixes). Found two real bugs — both robustness/UX in the new diagnostics commands — and fixed them minimally; everything else verified correct.B1 —
doctorcould crash instead of reporting a failed checkcollect_doctor_checksran each check unguarded._examples_checkconnects PyBullet and steps, so in a broken/headless environment it raised and the command died with a raw traceback — exactly when a user runsdoctorto diagnose a broken env. Now each check runs through a_safeguard that turns any exception into awarnrow.B2 —
inspectraw-tracebacked on a missing/incomplete runinspectcalledruns.load_run, which unconditionally readscreature.json(whichinspectnever uses), so a nonexistent path or a run dir /trace.jsonwithout a siblingcreature.json(a documented input) raisedFileNotFoundErrorinstead of the friendly exit-2 every other command gives. Now it loads only the trace (+ optionaltask.json) via the existing_load_spec/_load_task_for_tracehelpers.Verified OK (no change)
Hash idempotence under normalization,
summarize_episodesafety (≥1 part, strict zips), duration/metric-name consistency, stored-warnings correctness,save_run(task=...)threading, and the motor-limit boundary.Verification
ruff check,ruff format --check,pytestall green — 131 tests (+3).doctorwith a throwing check →warnrow, no crash;inspect /tmp/does-not-exist→ exit 2;inspecton a dir containing onlytrace.json→ summarizes (duration 3.00,final score).