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.