Skip to content

Exceptions

A module holding a decorator to wrap a function to add a traceback to any exception raised.

class IntegrationNotFoundError(name) #

Bases: Exception

An exception raised when no integration is found.

PARAMETER DESCRIPTION
name

The name of the integration that was not found.

TYPE: str

Source code in src/amltk/exceptions.py
def __init__(self, name: str) -> None:
    """Initialize the exception.

    Args:
        name: The name of the integration that was not found.
    """
    super().__init__(f"No integration found for {name}.")

class SchedulerNotRunningError #

Bases: RuntimeError

The scheduler is not running.

class EventNotKnownError #

Bases: ValueError

The event is not a known one.

class NoChoiceMadeError #

Bases: ValueError

No choice was made.

class NodeNotFoundError #

Bases: ValueError

The node was not found.

class RequestNotMetError #

Bases: ValueError

Raised when a request is not met.

class ComponentBuildError #

Bases: TypeError

Raised when failing to build a component.

class DuplicateNamesError(node) #

Bases: ValueError

Raised when duplicate names are found.

PARAMETER DESCRIPTION
node

The node that has children with duplicate names.

TYPE: Node

Source code in src/amltk/exceptions.py
def __init__(self, node: Node) -> None:
    """Initialize the exception.

    Args:
        node: The node that has children with duplicate names.
    """
    super().__init__(node)
    self.node = node

def safe_map(f, args) #

Map a function over an iterable, catching any exceptions.

PARAMETER DESCRIPTION
f

The function to map.

TYPE: Callable[..., R]

args

The iterable to map over.

TYPE: Iterable[Any]

YIELDS DESCRIPTION
R | tuple[Exception, str]

The return value of the function, or the exception raised.

Source code in src/amltk/exceptions.py
def safe_map(
    f: Callable[..., R],
    args: Iterable[Any],
) -> Iterator[R | tuple[Exception, str]]:
    """Map a function over an iterable, catching any exceptions.

    Args:
        f: The function to map.
        args: The iterable to map over.

    Yields:
        The return value of the function, or the exception raised.
    """
    for arg in args:
        try:
            yield f(arg)
        except Exception as e:  # noqa: BLE001
            yield e, traceback.format_exc()

def safe_starmap(f, args) #

Map a function over an iterable, catching any exceptions.

PARAMETER DESCRIPTION
f

The function to map.

TYPE: Callable[..., R]

args

The iterable to map over.

TYPE: Iterable[Iterable[Any]]

YIELDS DESCRIPTION
R | tuple[Exception, str]

The return value of the function, or the exception raised.

Source code in src/amltk/exceptions.py
def safe_starmap(
    f: Callable[..., R],
    args: Iterable[Iterable[Any]],
) -> Iterator[R | tuple[Exception, str]]:
    """Map a function over an iterable, catching any exceptions.

    Args:
        f: The function to map.
        args: The iterable to map over.

    Yields:
        The return value of the function, or the exception raised.
    """
    for arg in args:
        try:
            yield f(*arg)
        except Exception as e:  # noqa: BLE001
            yield e, traceback.format_exc()