How to write a Custom Action¶
Write a class inherited from
mistral_lib.actions.Action
from mistral_lib import actions class RunnerAction(actions.Action): def __init__(self, param): # store the incoming params self.param = param def run(self, action_ctx=None): # return your results here return {'status': 0}
Publish the class in a namespace (in your
setup.cfg)
[entry_points] mistral.actions = example.runner = my.mistral_plugins.somefile:RunnerAction
Install the Python package containing the action. If this was added to Mistral itself it will need to be reinstalled.
Restart Mistral services (API, engine and executor) so they load the new action. Actions plugged in with the
mistral.actionsentry point are discovered when a service starts, there is no need to populate the database.Now you can call the action
example.runner
my_workflow: tasks: my_action_task: action: example.runner input: param: avalue_to_pass_in