NatLabRockies / NatLabRockies/r2x-cli

Add pytest-like --pdb post-mortem debugging to r2x run

Open
#177 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement rust
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 pdb on uncaught Python exceptions, including AssertionError and KeyboardInterrupt.
  • For pipelines, stop in the failing plugin rather than starting a debugger for every plugin.
  • Preserve the original error and nonzero exit status after continue or quit.
  • 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-stdout does 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

  • --pdb is accepted for direct plugin and pipeline run modes.
  • A fixture plugin raising AssertionError opens 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---pdb behavior and stdout/JSON contracts remain unchanged.
  • CLI help and documentation describe the option and the --input FILE recommendation for interactive debugging.

References: Python pdb.post_mortem, PyO3 PyErr, pytest --pdb.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.