Skip to content

kiara_modules.core.logic

AndModule

Returns 'True' if both inputs are 'True'.

create_input_schema(self)

Abstract method to implement by child classes, returns a description of the input schema of this module.

If returning a dictionary of dictionaries, the format of the return value is as follows (items with '*' are optional):

{ "[input_field_name]: { "type": "[value_type]", "doc*": "[a description of this input]", "optional*': [boolean whether this input is optional or required (defaults to 'False')] "[other_input_field_name]: { "type: ... ... }

Source code in core/logic.py
def create_input_schema(
    self,
) -> typing.Mapping[
    str, typing.Union[ValueSchema, typing.Mapping[str, typing.Any]]
]:

    return {
        "a": {"type": "boolean", "doc": "A boolean describing this input state."},
        "b": {"type": "boolean", "doc": "A boolean describing this input state."},
    }

create_output_schema(self)

Abstract method to implement by child classes, returns a description of the output schema of this module.

If returning a dictionary of dictionaries, the format of the return value is as follows (items with '*' are optional):

{ "[output_field_name]: { "type": "[value_type]", "doc*": "[a description of this output]" "[other_input_field_name]: { "type: ... ... }

Source code in core/logic.py
def create_output_schema(
    self,
) -> typing.Mapping[
    str, typing.Union[ValueSchema, typing.Mapping[str, typing.Any]]
]:

    return {
        "y": {
            "type": "boolean",
            "doc": "A boolean describing the module output state.",
        }
    }

LogicProcessingModuleConfig pydantic-model

Config class for all the 'logic'-related modules.

delay: float pydantic-field

the delay in seconds from processing start to when the output is returned.

NotModule

Negates the input.

create_input_schema(self)

The not module only has one input, a boolean that will be negated by the module.

Source code in core/logic.py
def create_input_schema(
    self,
) -> typing.Mapping[
    str, typing.Union[ValueSchema, typing.Mapping[str, typing.Any]]
]:
    """The not module only has one input, a boolean that will be negated by the module."""

    return {
        "a": {"type": "boolean", "doc": "A boolean describing this input state."}
    }

create_output_schema(self)

The output of this module is a single boolean, the negated input.

Source code in core/logic.py
def create_output_schema(
    self,
) -> typing.Mapping[
    str, typing.Union[ValueSchema, typing.Mapping[str, typing.Any]]
]:

    """The output of this module is a single boolean, the negated input."""

    return {
        "y": {
            "type": "boolean",
            "doc": "A boolean describing the module output state.",
        }
    }

process(self, inputs, outputs)

Negates the input boolean.

Source code in core/logic.py
def process(self, inputs: ValueSet, outputs: ValueSet) -> None:
    """Negates the input boolean."""

    time.sleep(self.config.get("delay"))  # type: ignore

    outputs.set_value("y", not inputs.get_value_data("a"))

OrModule

Returns 'True' if one of the inputs is 'True'.

create_input_schema(self)

Abstract method to implement by child classes, returns a description of the input schema of this module.

If returning a dictionary of dictionaries, the format of the return value is as follows (items with '*' are optional):

{ "[input_field_name]: { "type": "[value_type]", "doc*": "[a description of this input]", "optional*': [boolean whether this input is optional or required (defaults to 'False')] "[other_input_field_name]: { "type: ... ... }

Source code in core/logic.py
def create_input_schema(
    self,
) -> typing.Mapping[
    str, typing.Union[ValueSchema, typing.Mapping[str, typing.Any]]
]:

    return {
        "a": {"type": "boolean", "doc": "A boolean describing this input state."},
        "b": {"type": "boolean", "doc": "A boolean describing this input state."},
    }

create_output_schema(self)

Abstract method to implement by child classes, returns a description of the output schema of this module.

If returning a dictionary of dictionaries, the format of the return value is as follows (items with '*' are optional):

{ "[output_field_name]: { "type": "[value_type]", "doc*": "[a description of this output]" "[other_input_field_name]: { "type: ... ... }

Source code in core/logic.py
def create_output_schema(
    self,
) -> typing.Mapping[
    str, typing.Union[ValueSchema, typing.Mapping[str, typing.Any]]
]:

    return {
        "y": {
            "type": "boolean",
            "doc": "A boolean describing the module output state.",
        }
    }