lifecycle.NodeExecutionHook
lifecycle.NodeExecutionHook
class hamilton.lifecycle.api.NodeExecutionHook[source]
Implement this to hook into the node execution lifecycle. You can call anything before and after the driver
final post_node_execute(*, run_id: str, node_: Node, kwargs: dict[str, Any], success: bool, error: Exception | None, result: Any | None, task_id: str | None = None)[source]
Wraps the after_execution method, providing a bridge to an external-facing API. Do not override this!
final pre_node_execute(*, run_id: str, node_: Node, kwargs: dict[str, Any], task_id: str | None = None)[source]
Wraps the before_execution method, providing a bridge to an external-facing API. Do not override this!
abstractmethod run_after_node_execution(*, node_name: str, node_tags: dict[str, Any], node_kwargs: dict[str, Any], node_return_type: type, result: Any, error: Exception | None, success: bool, task_id: str | None, run_id: str, **future_kwargs: Any)[source]
Hook that is executed post node execution.
Parameters:
- node_name – Name of the node in question
- node_tags – Tags of the node
- node_kwargs – Keyword arguments passed to the node
- node_return_type – Return type of the node
- result – Output of the node, None if an error occurred
- error – Error that occurred, None if no error occurred
- success – Whether the node executed successfully
- task_id – The ID of the task, none if not in a task-based environment
- 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_node_execution(*, node_name: str, node_tags: dict[str, Any], node_kwargs: dict[str, Any], node_return_type: type, task_id: str | None, run_id: str, node_input_types: dict[str, Any], **future_kwargs: Any)[source]
Hook that is executed prior to node execution.
Parameters:
- node_name – Name of the node.
- node_tags – Tags of the node
- node_kwargs – Keyword arguments to pass to the node
- node_return_type – Return type of the node
- task_id – The ID of the task, none if not in a task-based environment
- run_id – Run ID (unique in process scope) of the current run. Use this to track state.
- node_input_types – the input types to the node and what it is expecting
- future_kwargs – Additional keyword arguments – this is kept for backwards compatibility
评论
登录后参与评论
KnowForge