MCPcopy Create free account
hub / github.com/Drakkar-Software/OctoBot / trigger_task

Function trigger_task

packages/node/octobot_node/scheduler/tasks.py:70–96  ·  view source on GitHub ↗
(
    task: octobot_node.models.Task, target_workflow_id: typing.Optional[str] = None
)

Source from the content-addressed store, hash-verified

68
69
70async def trigger_task(
71 task: octobot_node.models.Task, target_workflow_id: typing.Optional[str] = None
72) -> str:
73 import octobot_node.scheduler # avoid circular import
74 if not octobot_node.scheduler.is_initialized():
75 raise RuntimeError("Scheduler is not initialized")
76 import octobot_node.scheduler.workflows.automation_workflow as automation_workflow
77 handle = None
78 # enqueue workflow instead of starting it to dispatch them to multiple workers if possible
79 if task.type == octobot_node.models.TaskType.EXECUTE_ACTIONS.value:
80 inputs = params.AutomationWorkflowInputs(task=task).to_dict(include_default_values=False)
81 if target_workflow_id:
82 with octobot_node.scheduler.SCHEDULER.SetWorkflowID(target_workflow_id):
83 handle = await octobot_node.scheduler.SCHEDULER.INSTANCE.enqueue_workflow_async(
84 octobot_node.enums.SchedulerQueues.AUTOMATION_WORKFLOW_QUEUE.value,
85 automation_workflow.AutomationWorkflow.execute_automation,
86 inputs=inputs,
87 )
88 else:
89 handle = await octobot_node.scheduler.SCHEDULER.INSTANCE.enqueue_workflow_async(
90 octobot_node.enums.SchedulerQueues.AUTOMATION_WORKFLOW_QUEUE.value,
91 automation_workflow.AutomationWorkflow.execute_automation,
92 inputs=inputs,
93 )
94 else:
95 raise ValueError(f"Unsupported task type: {task.type}")
96 return handle.workflow_id
97
98
99async def send_actions_to_automation(actions: list[dict], automation_id: str):

Callers

nothing calls this directly

Calls 3

SetWorkflowIDMethod · 0.80
is_initializedMethod · 0.45
to_dictMethod · 0.45

Tested by

no test coverage detected