lifecycle.api.TaskExecutionHookΒΆ
- class hamilton.lifecycle.api.TaskExecutionHookΒΆ
Implement this to hook into the task execution process. Tasks consist of a group of one or more nodes that are run on a task executor.
- 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)ΒΆ
Runs after all of the nodes associated with a task have been executed. By definition this is run inside of the executor and therefore may be run on separate or distributed processes.
- 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)ΒΆ
Runs prior to any of the nodes associated with a task. By definition this is run inside of the executor and therefore may be run on separate or distributed processes.
- 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