lifecycle.api.GraphExecutionHook
lifecycle.api.GraphExecutionHook
class hamilton.lifecycle.api.GraphExecutionHook[source]
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)[source]
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])[source]
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.
abstractmethod run_after_graph_execution(*, graph: HamiltonGraph, success: bool, error: Exception | None, results: dict[str, Any] | None, run_id: str, **future_kwargs: Any)[source]
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
abstractmethod 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)[source]
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
评论
登录后参与评论
KnowForge