Skip to content

action_factory

drunc.fsm.action_factory

Classes

FSMActionFactory()

Source code in drunc/fsm/action_factory.py
def __init__(self):
    raise DruncSetupException("Call get() instead")
Functions
get_action(action_name, action_configuration)

Construct the action interface for the given action name and configuration.

Parameters:

Name Type Description Default
action_name str

The name of the action to construct.

required
configuration FSMaction

The configuration for the action.

required

Returns:

Type Description

An instance of the action interface corresponding to the given action name.

Raises:

Type Description
UnknownAction

If the action name is not recognized.

InvalidAction

If the constructed action does not have valid pre/post transition methods.

Source code in drunc/fsm/action_factory.py
def get_action(
    self, action_name: str, action_configuration: "conffwk.dal.FSMaction"
):
    """
    Construct the action interface for the given action name and configuration.

    Args:
        action_name (str): The name of the action to construct.
        configuration (conffwk.dal.FSMaction): The configuration for the action.

    Returns:
        An instance of the action interface corresponding to the given action name.

    Raises:
        fsme.UnknownAction: If the action name is not recognized.
        fsme.InvalidAction: If the constructed action does not have valid pre/post
            transition methods.
    """
    iface = None
    match action_name:
        case "user-provided-run-number":
            iface = UserProvidedRunNumber(action_configuration)
        case "usvc-provided-run-number":
            iface = UsvcProvidedRunNumber(action_configuration)
        case "test-action":
            iface = SomeTestAction(action_configuration)
        case "file-logbook":
            iface = FileLogbook(action_configuration)
        case "elisa-logbook":
            iface = ElisaLogbook()
        case "file-run-registry":
            iface = FileRunRegistry(action_configuration)
        case "db-run-registry":
            iface = DBRunRegistry(action_configuration)
        case "thread-pinning":
            iface = ThreadPinning(action_configuration)
        case "master-send-fl-command":
            iface = MasterSendFLCommand(action_configuration)
        case "trigger-rate-specifier":
            iface = TriggerRateSpecifier(action_configuration)
        case _:
            raise fsme.UnknownAction(action_name)

    # Validate the constructed action interface to ensure it has valid pre/post
    # transition methods.
    if iface:
        self._validate_action(iface)

    return iface