Skip to content

operations

Attributes

OPERATION_TYPE_DETAILS = TypeVar('OPERATION_TYPE_DETAILS', bound=OperationDetails) module-attribute

Classes

OperationType

Bases: abc.ABC, Generic[OPERATION_TYPE_DETAILS]

Source code in kiara/operations/__init__.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class OperationType(abc.ABC, Generic[OPERATION_TYPE_DETAILS]):
    def __init__(self, kiara: "Kiara", op_type_name: str):
        self._kiara: Kiara = kiara
        self._op_type_name: str = op_type_name

    @property
    def operations(self) -> Mapping[str, Operation]:
        return {
            op_id: self._kiara.operation_registry.get_operation(op_id)
            for op_id in self._kiara.operation_registry.operations_by_type[
                self._op_type_name
            ]
        }

    def retrieve_included_operation_configs(
        self,
    ) -> Iterable[Union[Mapping, OperationConfig]]:
        return []

    @abc.abstractmethod
    def check_matching_operation(
        self, module: "KiaraModule"
    ) -> Union[OPERATION_TYPE_DETAILS, None]:
        """Check whether the provided module is a valid operation for this type."""

    def retrieve_operation_details(
        self, operation: Union[Operation, str]
    ) -> OPERATION_TYPE_DETAILS:
        """
        Retrieve operation details for provided operation.

        This is really just a utility method, to make the type checker happy.
        """
        if isinstance(operation, str):
            operation = self.operations[operation]

        return operation.operation_details  # type: ignore

    def create_renderable(self, **config):

        info = OperationTypeInfo.create_from_type_class(
            kiara=None, type_cls=self.__class__
        )
        return info.create_renderable(**config)

Attributes

operations: Mapping[str, Operation] property

Functions

retrieve_included_operation_configs() -> Iterable[Union[Mapping, OperationConfig]]
Source code in kiara/operations/__init__.py
36
37
38
39
def retrieve_included_operation_configs(
    self,
) -> Iterable[Union[Mapping, OperationConfig]]:
    return []
check_matching_operation(module: KiaraModule) -> Union[OPERATION_TYPE_DETAILS, None] abstractmethod

Check whether the provided module is a valid operation for this type.

Source code in kiara/operations/__init__.py
41
42
43
44
45
@abc.abstractmethod
def check_matching_operation(
    self, module: "KiaraModule"
) -> Union[OPERATION_TYPE_DETAILS, None]:
    """Check whether the provided module is a valid operation for this type."""
retrieve_operation_details(operation: Union[Operation, str]) -> OPERATION_TYPE_DETAILS

Retrieve operation details for provided operation.

This is really just a utility method, to make the type checker happy.

Source code in kiara/operations/__init__.py
47
48
49
50
51
52
53
54
55
56
57
58
def retrieve_operation_details(
    self, operation: Union[Operation, str]
) -> OPERATION_TYPE_DETAILS:
    """
    Retrieve operation details for provided operation.

    This is really just a utility method, to make the type checker happy.
    """
    if isinstance(operation, str):
        operation = self.operations[operation]

    return operation.operation_details  # type: ignore
create_renderable(**config)
Source code in kiara/operations/__init__.py
60
61
62
63
64
65
def create_renderable(self, **config):

    info = OperationTypeInfo.create_from_type_class(
        kiara=None, type_cls=self.__class__
    )
    return info.create_renderable(**config)