ml_switcheroo.config¶
Runtime Configuration Store. Supports Dynamic Defaults, TOML loading, and Framework Flavours.
This module resolves default Source and Target frameworks by querying the
ui_priority of registered adapters, ensuring the logic is completely agnostic
to the specific libraries installed.
Attributes¶
Classes¶
Global configuration container for the translation engine. |
Functions¶
|
Returns a list of framework keys sorted by UI Priority. |
|
Parses a list of 'key=value' strings into a dictionary with type inference. |
Module Contents¶
- ml_switcheroo.config.tomllib = None¶
- ml_switcheroo.config.T¶
- ml_switcheroo.config.get_framework_priority_order() List[str][source]¶
Returns a list of framework keys sorted by UI Priority.
The sort order is determined by the
ui_priorityattribute of the registered FrameworkAdapter. Lower numbers appear first (Source default).If no priority is defined, defaults to 999.
- Returns:
Sorted list of framework identifiers (e.g. [‘torch’, ‘jax’]).
- Return type:
List[str]
- class ml_switcheroo.config.RuntimeConfig(/, **data: Any)[source]¶
Bases:
pydantic.BaseModelGlobal configuration container for the translation engine.
- source_framework: str = None¶
- target_framework: str = None¶
- source_flavour: str | None = None¶
- target_flavour: str | None = None¶
- strict_mode: bool = None¶
- intermediate: str | None = None¶
- enable_graph_optimization: bool = None¶
- enable_import_fixer: bool = None¶
- plugin_settings: Dict[str, Any] = None¶
- plugin_paths: List[pathlib.Path] = None¶
- validation_report: pathlib.Path | None = None¶
- classmethod validate_framework(v: str) str[source]¶
Ensures the framework is registered in the system.
- Parameters:
v (str) – The framework key to validate.
- Returns:
The normalized framework key.
- Return type:
str
- Raises:
ValueError – If the framework is not registered and not a placeholder.
- property effective_source: str¶
Returns the resolved source framework key.
Prioritizes
source_flavourif present, otherwise returnssource_framework.- Returns:
The active source framework key.
- Return type:
str
- property effective_target: str¶
Returns the resolved target framework key.
Prioritizes
target_flavourif present, otherwise returnstarget_framework.- Returns:
The active target framework key.
- Return type:
str
- parse_plugin_settings(schema: Type[T]) T[source]¶
Validates plugin settings against a Pydantic model.
- classmethod load(source: str | None = None, target: str | None = None, source_flavour: str | None = None, target_flavour: str | None = None, strict_mode: bool | None = None, intermediate: str | None = None, enable_graph_optimization: bool | None = None, plugin_settings: Dict[str, Any] | None = None, validation_report: pathlib.Path | None = None, search_path: pathlib.Path | None = None) RuntimeConfig[source]¶
Loads configuration from
pyproject.toml, overriding with CLI arguments. Defaults are calculated dynamically via factory methods if not found.- Parameters:
source (Optional[str]) – Override source framework.
target (Optional[str]) – Override target framework.
source_flavour (Optional[str]) – Override source flavour.
target_flavour (Optional[str]) – Override target flavour.
strict_mode (Optional[bool]) – Override strict mode setting.
intermediate (Optional[str]) – Override intermediate representation mode.
enable_graph_optimization (Optional[bool]) – Override fusion/optimization setting.
plugin_settings (Optional[Dict]) – Additional plugin settings.
validation_report (Optional[Path]) – Override validation report path.
search_path (Optional[Path]) – Directory path to search for config file.
- Returns:
The fully resolved configuration object.
- Return type:
- ml_switcheroo.config.parse_cli_key_values(items: List[str] | None) Dict[str, Any][source]¶
Parses a list of ‘key=value’ strings into a dictionary with type inference.
- Parameters:
items (Optional[List[str]]) – List of strings in “key=value” format.
- Returns:
Dictionary with parsed values (bool, int, float, or str).
- Return type:
Dict[str, Any]