ml_switcheroo.cli.handlers.convert¶

Convert Command Handler.

This module implements the logic for the ml_switcheroo convert command. It orchestrates: 1. Configuration loading (including external plugin discovery). 2. Semantics initialization. 3. AST transformation via the Engine. 4. Verification harness generation (optional). 5. Output writing and trace logging.

Functions¶

handle_convert(→ int)

Handles the 'convert' command execution.

Module Contents¶

ml_switcheroo.cli.handlers.convert.handle_convert(input_path: pathlib.Path, output_path: pathlib.Path | None, source: str | None, target: str | None, verify: bool, strict: bool | None, plugin_settings: Dict[str, Any], json_trace_path: pathlib.Path | None = None) → int¶

Handles the ‘convert’ command execution.

Orchestrates the loading of configuration, initialization of the semantic knowledge base, and the execution of the transpilation engine on files or directories.

Parameters:
  • input_path – Path to the source file or directory to convert.

  • output_path – Path where generated code should be saved.

  • source – Override for source framework (e.g. ‘torch’).

  • target – Override for target framework (e.g. ‘jax’).

  • verify – If True, generates and runs a verification harness test immediately.

  • strict – If True, enforces strict strict_mode on the Engine.

  • plugin_settings – Dictionary of specific plugin configuration flags.

  • json_trace_path – Optional path to dump execution trace JSON.

Returns:

Exit code (0 for success, 1 for failure).

Return type:

int