ml_switcheroo.config¶
Runtime Configuration Store. Updated to support Framework Flavours (Hierarchical Selection).
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. |
Module Contents¶
- ml_switcheroo.config.tomllib = None¶
- ml_switcheroo.config.T¶
- ml_switcheroo.config.get_framework_priority_order() List[str]¶
Returns a list of framework keys sorted by UI Priority.
The sort order is determined by the ui_priority attribute of the registered FrameworkAdapter. Lower numbers appear first.
- Returns:
Sorted list of framework identifiers (e.g. [‘torch’, ‘jax’]).
- Return type:
List[str]
- class ml_switcheroo.config.RuntimeConfig(/, **data: Any)¶
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¶
- plugin_settings: Dict[str, Any] = None¶
- plugin_paths: List[pathlib.Path] = None¶
- validation_report: pathlib.Path | None = None¶
- classmethod validate_framework(v: str) str¶
Ensures the framework is registered in the system.
- Parameters:
v (str) – The framework key to validate.
- Returns:
The normalized (lowercase) framework key.
- Return type:
str
- Raises:
ValueError – If the framework is not found in the registry.
- property effective_source: str¶
Resolves the specific framework key to use for source logic.
If a flavour (e.g. ‘flax_nnx’) is provided, it overrides the general framework (‘jax’).
- Returns:
The active source framework key.
- Return type:
str
- property effective_target: str¶
Resolves the specific framework key to use for target logic.
- Returns:
The active target framework key.
- Return type:
str
- parse_plugin_settings(schema: Type[T]) T¶
Validates the raw plugin settings dictionary against a specific Pydantic model.
- Parameters:
schema (Type[T]) – The Pydantic model class defining expected settings.
- Returns:
An instance of the schema model populated with runtime values.
- Return type:
T
- 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, plugin_settings: Dict[str, Any] | None = None, validation_report: pathlib.Path | None = None, search_path: pathlib.Path | None = None) RuntimeConfig¶
Loads configuration from pyproject.toml and overrides with CLI arguments.
- Parameters:
source (Optional[str]) – Override for source framework.
target (Optional[str]) – Override for target framework.
source_flavour (Optional[str]) – Override for source flavour.
target_flavour (Optional[str]) – Override for target flavour.
strict_mode (Optional[bool]) – Override for strict mode setting.
plugin_settings (Optional[Dict]) – Additional CLI plugin settings.
validation_report (Optional[Path]) – Override for validation report path.
search_path (Optional[Path]) – Directory to start searching for TOML config.
- Returns:
The fully resolved configuration object.
- Return type:
- ml_switcheroo.config.parse_cli_key_values(items: List[str] | None) Dict[str, Any]¶
Parses a list of ‘key=value’ strings into a dictionary.
Types are inferred (int, float, bool, or string).
- Parameters:
items (Optional[List[str]]) – List of raw CLI strings directly from argparse.
- Returns:
Parsed dictionary.
- Return type:
Dict[str, Any]