Skip to content

Feature/refactor cli magics#4

Merged
reiase merged 2 commits intomasterfrom
feature/refactor_cli_magics
Nov 2, 2025
Merged

Feature/refactor cli magics#4
reiase merged 2 commits intomasterfrom
feature/refactor_cli_magics

Conversation

@reiase
Copy link
Copy Markdown
Contributor

@reiase reiase commented Nov 2, 2025

This pull request introduces a registry system and auto-discovery for IPython magic commands, refactors the DebugMagic class to provide unified and user-friendly magic commands for debugging and function tracing, and improves error handling and robustness in the console and magic command registration. The most significant changes are the introduction of a magic class registry, automatic registration of magic commands, and a major overhaul of the DebugMagic command interface.

Magic command registry and auto-discovery:

  • Added a decorator-based registry system for magic classes (register_magic) and utility functions for registering, listing, and unregistering magics in python/probing/magics/__init__.py. This allows magic commands to be auto-discovered and registered without manual imports.
  • Changed magic registration in the main kernel manager to dynamically import all magic modules and register any discovered magic classes, with error handling for failed imports or registrations.

DebugMagic command refactor and enhancements:

  • Refactored DebugMagic to use unified %debug and %trace commands with subcommands (e.g., %debug remote, %trace start), improved help messages, argument parsing, and added a cell magic %%probe for code execution with tracing. This makes the interface more consistent and easier to use.
  • Added comprehensive help messages and argument parsing for both debug and trace commands, including support for variable watching, depth specification, and listing traceable functions.

Robustness and error handling improvements:

  • Improved error handling in the DebugConsole class to allow fallback operation if the code executor fails to initialize, and added fallback execution logic in the push method. [1] [2]
  • Enhanced logging and warnings throughout magic registration and debugging utilities to better inform users of issues, such as failed imports, registrations, or debugger installation. [1] [2]

Remote debugging utilities:

  • Added and documented utility methods for remote debugging in DebugMagic, including improved status reporting, installation, and activation of debugpy, with clearer output and error messages. [1] [2] [3] [4]

These changes significantly improve the extensibility, usability, and reliability of the magic command system for probing and debugging in the project.

- Introduced a decorator `register_magic` to facilitate the registration of magic classes.
- Implemented a magic class registry to manage registered magic commands.
- Enhanced `CodeExecutor` to automatically discover and register magic commands from modules in the `magics` package.
- Updated existing magic classes (e.g., DebugMagic, HandleMagic, HelpMagic, etc.) to use the new registration mechanism.
- Improved error handling during module import and registration processes.
- Added fallback behavior in `DebugConsole` for cases where `CodeExecutor` initialization fails.
- Refactored DebugMagic to consolidate remote debugging and tracing functionalities under a unified command structure.
- Introduced subcommands for debugging: `remote`, `status`, and `help`, along with detailed usage instructions.
- Added trace commands with subcommands for starting, stopping, and showing currently traced functions.
- Implemented argument parsing for commands and improved error handling.
- Removed deprecated HandleMagic and TraceMagic modules to streamline the codebase.
@reiase reiase merged commit 23edd7c into master Nov 2, 2025
6 checks passed
@reiase reiase deleted the feature/refactor_cli_magics branch November 15, 2025 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant