ml_switcheroo.cli.handlers.audit¶

Audit Command Handler.

Performs static analysis on source files to identify unsupported operations and generate coverage reports.

Functions¶

resolve_roots(→ Set[str])

Expands framework keys (e.g. 'flax_nnx') to python module roots (e.g. 'flax', 'jax').

handle_audit(→ int)

Scans a directory/file to determine coverage against the Knowledge Base.

Module Contents¶

ml_switcheroo.cli.handlers.audit.resolve_roots(framework_keys: List[str]) → Set[str]¶

Expands framework keys (e.g. ‘flax_nnx’) to python module roots (e.g. ‘flax’, ‘jax’).

This ensures that querying for ‘flax_nnx’ correctly finds ‘import flax’. It consults the Adapter metadata for import aliases and search modules.

Parameters:

framework_keys – List of requested framework identifiers.

Returns:

A set of root module names (e.g. {‘torch’, ‘jax’, ‘flax’}).

ml_switcheroo.cli.handlers.audit.handle_audit(path: pathlib.Path, source_frameworks: List[str], json_mode: bool = False) → int¶

Scans a directory/file to determine coverage against the Knowledge Base.

Parameters:
  • path – Input source file or directory.

  • source_frameworks – List of framework keys to scan for.

  • json_mode – If True, output JSON to stdout and suppress Rich logs.

Returns:

Exit code (0 if audit reveals full coverage, 1 if missing ops).

Note: In audit mode, missing ops might be considered a ‘failure’.

Return type:

int