ml_switcheroo.cli.handlers¶
Submodules¶
Functions¶
|
Handles the 'scaffold' command. |
|
Handles the 'import-spec' command. |
|
Handles 'sync-standards' command. |
|
Handles the 'snapshot' command. |
|
Handles the 'sync' command. |
|
Handles the 'wizard' command for interactive mapping discovery. |
|
Handles the 'harvest' command to learn mappings from manual tests. |
|
Handles 'ci' command. |
|
Handles 'matrix' command. |
|
Handles 'gen-docs' command. |
|
Handles 'gen-tests' command. |
Package Contents¶
- ml_switcheroo.cli.handlers.handle_scaffold(frameworks: list[str], out_dir: pathlib.Path) int¶
Handles the ‘scaffold’ command.
Iterates through provided frameworks.
Uses FrameworkAdapter.discovery_heuristics regexes to fuzzy match framework APIs against known specs or structural conventions.
Populates semantic specs (Hub) and framework mappings (Spokes/Snapshots).
- Parameters:
frameworks (list[str]) – List of framework package names to scaffold (e.g., [‘torch’, ‘jax’]).
out_dir (Path) – The root directory for generating the knowledge base. Defaults to the package source if None.
- Returns:
Exit code.
- Return type:
int
- ml_switcheroo.cli.handlers.handle_import_spec(target: pathlib.Path) int¶
Handles the ‘import-spec’ command.
Parses upstream standards documentation or stubs and merges the definitions into the local semantics Hub.
- Parameters:
target (Path) – Code resource to import (‘internal’, .md file, or directory).
- Returns:
Exit code.
- Return type:
int
- ml_switcheroo.cli.handlers.handle_sync_standards(categories: List[str], frameworks: List[str] | None, dry_run: bool) int¶
Handles ‘sync-standards’ command.
Invokes the Consensus Engine to automatically discover new Abstract Operations by finding commonalities across multiple framework API surfaces. Writes the results to k_discovered.json (The Unofficial/Discovered Standard).
- Parameters:
categories (List[str]) – List of category strings (layer, loss, etc.) to scan.
frameworks (Optional[List[str]]) – List of framework keys to scan. Defaults to installed/registered frameworks.
dry_run (bool) – If True, prints results without saving.
- Returns:
Exit code.
- Return type:
int
- ml_switcheroo.cli.handlers.handle_snapshot(out_dir: pathlib.Path | None) int¶
Handles the ‘snapshot’ command.
Scans installed frameworks and dumps their API signatures to JSON files. These snapshots allow the engine to operate in “Ghost Mode” (e.g., in WebAssembly) without requiring the heavy frameworks to be installed.
- Parameters:
out_dir – Optional custom output directory. Defaults to package/snapshots.
- Returns:
Exit code.
- Return type:
int
- ml_switcheroo.cli.handlers.handle_sync(framework: str) int¶
Handles the ‘sync’ command.
Links the Abstract Standards (Hub) to the concrete implementation in a specific framework. This process involves: 1. Reading the Specs from semantics/. 2. Introspecting the installed framework to find matching APIs. 3. Merging Static Definitions from the Adapter (for Ghost support). 4. Applying Adapter-specific manual wiring (plugins, templates). 5. Persisting Test Configuration templates. 6. Writing the results to the Snapshot Overlay (snapshots/{fw}_mappings.json).
- Parameters:
framework – The framework key to sync (e.g. ‘torch’, ‘jax’).
- Returns:
Exit code.
- Return type:
int
- ml_switcheroo.cli.handlers.handle_wizard(package: str) int¶
Handles the ‘wizard’ command for interactive mapping discovery.
- Parameters:
package – The name of the python package to inspect (e.g., ‘torch’).
- Returns:
Exit code (0 for success).
- Return type:
int
- ml_switcheroo.cli.handlers.handle_harvest(path: pathlib.Path, target: str, dry_run: bool) int¶
Handles the ‘harvest’ command to learn mappings from manual tests.
- Parameters:
path – File or directory containing python test files.
target – The framework target used in the tests (e.g., ‘jax’).
dry_run – If True, prints changes without writing to disk.
- Returns:
Exit code (0 for success, 1 for path errors).
- Return type:
int
- ml_switcheroo.cli.handlers.handle_ci(update_readme: bool, readme_path: pathlib.Path, json_report: pathlib.Path | None) int¶
Handles ‘ci’ command.
- ml_switcheroo.cli.handlers.handle_matrix() int¶
Handles ‘matrix’ command.
- ml_switcheroo.cli.handlers.handle_docs(source: str, target: str, out_path: pathlib.Path) int¶
Handles ‘gen-docs’ command.
- ml_switcheroo.cli.handlers.handle_gen_tests(out: pathlib.Path) int¶
Handles ‘gen-tests’ command.