lifecycle.api.GraphExecutionHookΒΆ
- class hamilton.lifecycle.api.GraphExecutionHookΒΆ
Implement this to execute code before and after graph execution. This is useful for logging, etcβ¦
- final post_graph_execute(*, run_id: str, graph: FunctionGraph, success: bool, error: Exception | None, results: Dict[str, Any] | None)ΒΆ
Just delegates to the interface method, passing in the right data.
- final pre_graph_execute(*, run_id: str, graph: FunctionGraph, final_vars: List[str], inputs: Dict[str, Any], overrides: Dict[str, Any])ΒΆ
Implementation of the pre_graph_execute hook. This just converts the inputs to the format the user-facing hook is expecting β performing a walk of the DAG to pass in the set of nodes to execute. Delegates to the interface method.
- abstract run_after_graph_execution(*, graph: HamiltonGraph, success: bool, error: Exception | None, results: Dict[str, Any] | None, run_id: str, **future_kwargs: Any)ΒΆ
This is run after graph execution. This allows you to do anything you want after the graph executes, knowing the results of the execution/any errors.
- Parameters:
graph β Graph that is being executed
results β Results of the graph execution
error β Error that occurred, None if no error occurred
success β Whether the graph executed successfully
run_id β Run ID (unique in process scope) of the current run. Use this to track state.
future_kwargs β Additional keyword arguments β this is kept for backwards compatibility
- abstract run_before_graph_execution(*, graph: HamiltonGraph, final_vars: List[str], inputs: Dict[str, Any], overrides: Dict[str, Any], execution_path: Collection[str], run_id: str, **future_kwargs: Any)ΒΆ
This is run prior to graph execution. This allows you to do anything you want before the graph executes, knowing the basic information that was passed in.
- Parameters:
graph β Graph that is being executed
final_vars β Output variables of the graph
inputs β Input variables passed to the graph
overrides β Overrides passed to the graph
execution_path β Collection of nodes that will be executed β these are just the nodes (not input nodes) that will be run during the course of execution.
run_id β Run ID (unique in process scope) of the current run. Use this to track state.
future_kwargs β Additional keyword arguments β this is kept for backwards compatibility