Skip to content

device_converter_manager

DeviceConverterAlreadyRegisteredError

Raised when attempting to register a device converter that already exists.

invalid_backend_type classmethod

invalid_backend_type(backend_type: object | None = None) -> DeviceConverterError

Create an error for invalid backend type.

Returns:

DeviceConverterError

Base exception for device converter-related errors.

invalid_backend_type classmethod

invalid_backend_type(backend_type: object | None = None) -> DeviceConverterError

Create an error for invalid backend type.

Returns:

DeviceConverterManager

DeviceConverterManager()

Manages conversions between devices.

Provides methods to register, retrieve, and check converters between devices. Converters are used to perform conversions from a specific source device to a target device.

fetch_converter

fetch_converter(from_lib: str, to_lib: str) -> DeviceConverter

Retrieve a converter from the specified device to another device.

Parameters:

  • from_lib (str) –

    The name of the source device

  • to_lib (str) –

    The name of the target device

Returns:

  • DeviceConverter ( DeviceConverter ) –

    An instance of the converter corresponding to the specified source and target devices. If the source and target are the same, it returns an instance of PassThroughDeviceConverter.

Raises:

has_converter

has_converter(from_lib: str, to_lib: str) -> bool

Check if a converter exists between the specified devices.

Parameters:

  • from_lib (str) –

    The name of the source device

  • to_lib (str) –

    The name of the target device

Returns:

  • bool ( bool ) –

    True if a converter exists, False otherwise

register_converter

register_converter(from_lib: str, to_lib: str, converter: DeviceConverter, *, allow_override: bool = False) -> None

Register a converter between the specified devices.

Parameters:

  • from_lib (str) –

    The name of the source device

  • to_lib (str) –

    The name of the target device

  • converter (DeviceConverter) –

    The converter instance to register

  • allow_override (bool, default: False ) –

    When False, prevents overwriting existing registrations. Defaults to False.

Raises:

DeviceConverterNotFoundError

Raised when the requested converter is not found.

invalid_backend_type classmethod

invalid_backend_type(backend_type: object | None = None) -> DeviceConverterError

Create an error for invalid backend type.

Returns: