ml_switcheroo.frameworks.base ============================= .. py:module:: ml_switcheroo.frameworks.base .. autoapi-nested-parse:: Base Protocol and Registry for Framework Adapters. This module defines the interface that all Framework Adapters must implement. It acts as the primary contact point between the `ASTEngine` and the specific ML library implementations (plugins). Key Capabilities (Hybrid Loading): - Adapters possess an `init_mode` (LIVE or GHOST). - In LIVE mode, they introspect installed packages. - In GHOST mode, they load cached JSON snapshots. Update: Enhanced StandardMap schema and import definitions. Attributes ---------- .. autoapisummary:: ml_switcheroo.frameworks.base.SNAPSHOT_DIR Classes ------- .. autoapisummary:: ml_switcheroo.frameworks.base.StandardCategory ml_switcheroo.frameworks.base.InitMode ml_switcheroo.frameworks.base.StandardMap ml_switcheroo.frameworks.base.FrameworkAdapter Functions --------- .. autoapisummary:: ml_switcheroo.frameworks.base.load_snapshot_for_adapter ml_switcheroo.frameworks.base.register_framework ml_switcheroo.frameworks.base.get_adapter Module Contents --------------- .. py:data:: SNAPSHOT_DIR .. py:class:: StandardCategory Bases: :py:obj:`str`, :py:obj:`enum.Enum` str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'. .. py:attribute:: LOSS :value: 'loss' .. py:attribute:: OPTIMIZER :value: 'optimizer' .. py:attribute:: LAYER :value: 'layer' .. py:attribute:: ACTIVATION :value: 'activation' .. py:class:: InitMode Bases: :py:obj:`str`, :py:obj:`enum.Enum` str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'. .. py:attribute:: LIVE :value: 'live' .. py:attribute:: GHOST :value: 'ghost' .. py:class:: StandardMap(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` Defines how a Framework implements a Middle Layer standard. Used for declaring static definitions in adapters. .. py:attribute:: api :type: str :value: None .. py:attribute:: args :type: Optional[Dict[str, str]] :value: None .. py:attribute:: inject_args :type: Optional[Dict[str, Union[str, int, float, bool]]] :value: None .. py:attribute:: requires_plugin :type: Optional[str] :value: None .. py:attribute:: output_adapter :type: Optional[str] :value: None .. py:attribute:: transformation_type :type: Optional[str] :value: None .. py:attribute:: operator :type: Optional[str] :value: None .. py:attribute:: pack_to_tuple :type: Optional[str] :value: None .. py:attribute:: macro_template :type: Optional[str] :value: None .. py:attribute:: output_cast :type: Optional[str] :value: None .. py:class:: FrameworkAdapter Bases: :py:obj:`Protocol` Protocol definition for a Framework Adapter. .. py:method:: convert(data: Any) -> Any .. py:property:: test_config :type: Dict[str, str] .. py:property:: search_modules :type: List[str] .. py:property:: display_name :type: str .. py:property:: ui_priority :type: int .. py:property:: discovery_heuristics :type: Dict[str, List[str]] .. py:property:: supported_tiers :type: List[ml_switcheroo.enums.SemanticTier] .. py:property:: import_alias :type: Tuple[str, str] .. py:property:: inherits_from :type: Optional[str] .. py:property:: structural_traits :type: ml_switcheroo.semantics.schema.StructuralTraits .. py:property:: rng_seed_methods :type: List[str] .. py:method:: get_device_syntax(device_type: str, device_index: Optional[str] = None) -> str .. py:method:: get_serialization_syntax(op: str, file_arg: str, object_arg: Optional[str] = None) -> str .. py:method:: get_serialization_imports() -> List[str] .. py:method:: get_example_code() -> str :classmethod: .. py:method:: get_tiered_examples() -> Dict[str, str] .. py:property:: definitions :type: Dict[str, StandardMap] Returns the framework's static implementation of Middle Layer Operations. .. py:property:: import_namespaces :type: Dict[str, Dict[str, str]] Returns import path remapping rules. Format: {"source.mod": {"root": "target", "sub": "mod", "alias": "alias"}} .. py:method:: collect_api(category: StandardCategory) -> List[ml_switcheroo.core.ghost.GhostRef] .. py:method:: apply_wiring(snapshot: Dict[str, Any]) -> None .. py:function:: load_snapshot_for_adapter(fw_key: str) -> Dict[str, Any] Locates the most recent snapshot for a given framework key. .. py:function:: register_framework(name: str) .. py:function:: get_adapter(name: str) -> Optional[FrameworkAdapter]