NatLabRockies / NatLabRockies/r2x-cli
Add pytest-like --pdb post-mortem debugging to r2x run
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 4
- Forks
- 2
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 12
Description
Summary
Add an opt-in --pdb option to r2x run that enters Python's post-mortem debugger when plugin execution fails, similar to pytest --pdb.
Proposed behavior
r2x run plugin <plugin-name> --pdb --input input.json
r2x run pipeline.yaml <pipeline-name> --pdb
- Enter
pdbon uncaught Python exceptions, includingAssertionErrorandKeyboardInterrupt. - For pipelines, stop in the failing plugin rather than starting a debugger for every plugin.
- Preserve the original error and nonzero exit status after
continueorquit. - Do not trigger for exceptions caught by plugin code.
- Require an interactive terminal and fail clearly instead of hanging in CI or piped execution.
- Keep debugger prompts on stderr so JSON/plugin output on stdout remains usable.
- Ensure
--no-stdoutdoes not hide the debugger prompt.
Implementation notes
Use Python's standard-library pdb.post_mortem(traceback) through the existing PyO3 bridge; no new Python dependency is needed. PyO3 0.27 exposes PyErr::traceback(py), which should be called before the existing format_python_error conversion.
The bridge should also support plugin-returned Err values when their exception object has a __traceback__. The existing format_err_result path already inspects that attribute.
Avoid relying on pdb.pm()/sys.last_*; passing the traceback directly is compatible with the project's Python 3.11+ target and avoids mutating interpreter-global error state.
Acceptance criteria
--pdbis accepted for direct plugin and pipeline run modes.- A fixture plugin raising
AssertionErroropens an interactive PDB session at the failing frame. - Continuing or quitting PDB returns the normal plugin failure with the expected exit status.
- Noninteractive invocation produces a clear diagnostic and does not block.
- Existing non-
--pdbbehavior and stdout/JSON contracts remain unchanged. - CLI help and documentation describe the option and the
--input FILErecommendation for interactive debugging.
References: Python pdb.post_mortem, PyO3 PyErr, pytest --pdb.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the r2x run option handling and existing PyO3 bridge, especially format_python_error and format_err_result; verify how direct plugin and pipeline failures are propagated. Add fixture coverage for AssertionError, interactive and noninteractive execution, stdout behavior, and exit status, then confirm CLI help documents --pdb and the --input FILE recommendation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- cli, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100