lifecycle.api.TaskExecutionHookΒΆ

class hamilton.lifecycle.api.TaskExecutionHookΒΆ

Implement this to run something after task execution. Tasks are tols used to group nodes. Note that this is currently run inside the task, although we do not guarantee where it will be run (it could easily move to outside the task).

post_task_execute(*, run_id: str, task_id: str, nodes: List[Node], results: Dict[str, Any] | None, success: bool, error: Exception, spawning_task_id: str | None, purpose: None)ΒΆ

Hook called immediately after task execution. 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

  • nodes – Nodes that were executed

  • results – Results 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

pre_task_execute(*, run_id: str, task_id: str, nodes: List[Node], inputs: Dict[str, Any], overrides: Dict[str, Any], spawning_task_id: str | None, purpose: None)ΒΆ

Hook that is called immediately prior to task execution. 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, unique in scope of the driver.

  • nodes – Nodes that are being executed

  • inputs – Inputs to the task

  • overrides – Overrides to task execution

  • spawning_task_id – ID of the task that spawned this task

  • purpose – Purpose of the current task group

abstractmethod run_after_task_execution(*, task_id: str, run_id: str, nodes: List[HamiltonNode], results: Dict[str, Any] | None, success: bool, error: Exception, spawning_task_id: str | None, purpose: None, **future_kwargs)ΒΆ

Implement this to run something after task execution. See note in run_before_task_execution.

Parameters:
  • task_id – ID of the task that was just executed

  • run_id – ID of the run this was under.

  • nodes – Nodes that were part of this task

  • results – Results of the task, per-node

  • success – Whether the task was successful

  • error – The error the task threw, if any

  • future_kwargs – Reserved for backwards compatibility.

  • spawning_task_id – ID of the task that spawned this task

  • purpose – Purpose of the current task group

abstractmethod run_before_task_execution(*, task_id: str, run_id: str, nodes: List[HamiltonNode], inputs: Dict[str, Any], overrides: Dict[str, Any], spawning_task_id: str | None, purpose: None, **future_kwargs)ΒΆ

Implement this to run something after task execution. Tasks are tols used to group nodes. Note that this is currently run inside the task, although we do not guarantee where it will be run (it could easily move to outside the task).

Parameters:
  • task_id – ID of the task we’re launching.

  • run_id – ID of the run this is under.

  • nodes – Nodes that are part of this task

  • inputs – Inputs to the task

  • overrides – Overrides passed to the task

  • future_kwargs – Reserved for backwards compatibility.

  • spawning_task_id – ID of the task that spawned this task

  • purpose – Purpose of the current task group