Lifecycle Adapters

lifecycle.api.TaskReturnHook

qianmoQqianmoQ· 更新于 2026-10-09· 阅读 5 分钟· 0 次阅读

登录后可跨设备保存划线和私人笔记登录

lifecycle.api.TaskReturnHook

class hamilton.lifecycle.api.TaskReturnHook[source]

Implement this to hook into the task return process. Tasks are submitted to an executor, which executes the task and returns the results (or raises an error).

post_task_return(*, run_id: str, task_id: str, nodes: list[Node], result: Any, success: bool, error: Exception | None, spawning_task_id: str | None, purpose: None)[source]

Hook called immediately after a task returns from an executor. Note that this is only useful in dynamic execution, although we reserve the right to add this back into the standard hamilton execution pattern.

Parameters:

  • run_id – ID of the run, unique in scope of the driver.
  • task_id – ID of the task
  • result – Return value of the task.
  • success – Whether or not the task executed successfully
  • error – The error that was raised, if any
  • spawning_task_id – ID of the task that spawned this task
  • purpose – Purpose of the current task group

abstractmethod run_after_task_return(*, run_id: str, task_id: str, nodes: list[Node], result: Any, success: bool, error: Exception | None, spawning_task_id: str | None, purpose: None, **future_kwargs)[source]

Runs after a task has been returned from a executor. By definition this is run outside of the task executor, on the process that executed the driver.

Parameters:

  • run_id – ID of the run this is under.
  • task_id – ID of the task that was just executed.
  • nodes – Nodes that were part of this task
  • result – Result of the task
  • success – Whether the task was successful
  • error – The error the task threw, if any
  • spawning_task_id – ID of the task that spawned this task
  • purpose – Purpose of the current task group
  • future_kwargs – Reserved for backwards compatibility.

评论

登录后参与评论

正在加载评论…