(
task: octobot_node.models.Task, target_workflow_id: typing.Optional[str] = None
)
| 68 | |
| 69 | |
| 70 | async 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 | |
| 99 | async def send_actions_to_automation(actions: list[dict], automation_id: str): |
nothing calls this directly
no test coverage detected