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