ml_switcheroo.core.discovery¶
Core Discovery mechanism for Auto-Inference of APIs.
This module provides the SimulatedReflection engine, which enables the
system to dynamically locate API endpoints in a target framework based on
an abstract operation name. It is used by the define CLI command to
resolve api: “infer” placeholders in ODL (Operation Definition Language) files.
Attributes¶
Classes¶
Scans a target framework to infer the API path for a given operation name. |
Module Contents¶
- ml_switcheroo.core.discovery.logger¶
- class ml_switcheroo.core.discovery.SimulatedReflection(framework: str)¶
Scans a target framework to infer the API path for a given operation name.
It utilizes the
FrameworkAdapter.search_modulesto limit the search space and applies both exact normalization matching and fuzzy string matching to find the best candidate.- framework¶
- adapter¶
- discover(op_name: str) str | None¶
Attempts to locate the fully qualified API path for an operation.
Strategy: 1. Normalization: Converts input and candidates to lowercase, stripping underscores. 2. Exact Match: Iterates through search modules. If a normalized match is found, returns immediately. 3. Fuzzy Match: If no exact match is found, collects all candidates and uses difflib
to find the closest string match.
- Parameters:
op_name (str) – The abstract operation name (e.g. “LogSoftmax”, “abs”).
- Returns:
The fully qualified API path (e.g. “torch.nn.functional.log_softmax”) or None if no confident match is found.
- Return type:
Optional[str]