lifecycle.PDBDebuggerΒΆ
- class hamilton.lifecycle.default.PDBDebugger(node_filter: Callable[[str], Dict[str, Any]] | bool | List[str] | str | None, before: bool = False, during: bool = False, after: bool = False)ΒΆ
Class to inject a PDB debugger into a node execution. This is still somewhat experimental as it is a debugging utility. We reserve the right to change the API and the implementation of this class in the future.
- __init__(node_filter: Callable[[str], Dict[str, Any]] | bool | List[str] | str | None, before: bool = False, during: bool = False, after: bool = False)ΒΆ
- Creates a PDB debugger. This has three possible modes:
Before β places you in a function with (a) node information, and (b) inputs
- During β runs the node with pdb.run. Note this may not always work or give what you expect as
node functions are often wrapped in multiple levels of input modifications/whatnot. That said, it should give you something. Also note that this is not (currently) compatible with graph adapters.
After β places you in a function with (a) node information, (b) inputs, and (c) results
- Parameters:
node_filter β A function that takes a node name and a node tags dict and returns a boolean. If the boolean is True, the node will be printed out.
before β Whether to place you in a PDB debugger before a node executes
during β Whether to place you in a PDB debugger during a nodeβs execution
after β Whether to place you in a PDB debugger after a node executes
- do_node_execute(*, run_id: str, node_: Node, kwargs: Dict[str, Any], task_id: str | None = None) Any ΒΆ
Method that is called to implement node execution. This can replace the execution of a node with something all together, augment it, or delegate it.
- Parameters:
run_id β ID of the run, unique in scope of the driver.
node β Node that is being executed
kwargs β Keyword arguments that are being passed into the node
task_id β ID of the task, defaults to None if not in a task setting
- 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)ΒΆ
Wraps the after_execution method, providing a bridge to an external-facing API. Do not override this!
- pre_node_execute(*, run_id: str, node_: Node, kwargs: Dict[str, Any], task_id: str | None = None)ΒΆ
Wraps the before_execution method, providing a bridge to an external-facing API. Do not override this!
- 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, **future_kwargs: Any)ΒΆ
Executes after a node, whether or not it was successful. Does nothing, just runs pdb.set_trace().
- Parameters:
node_name β Name of the node
node_tags β Tags of the node
node_kwargs β Keyword arguments passed to the node
node_return_type β Return type of the node
result β Result of the node, None if there was an error
error β Error of the node, None if there was no error
success β Whether the node ran successful or not
task_id β Task ID of the node, if any
future_kwargs β Additional keyword arguments that may be passed to the hook yet are ignored for now
- 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, **future_kwargs: Any)ΒΆ
Executes before a node executes. Does nothing, just runs pdb.set_trace()
- Parameters:
node_name β Name of the node
node_tags β Tags of the node
node_kwargs β Keyword arguments passed to the node
node_return_type β Return type of the node
task_id β ID of the task that the node is in, if any
future_kwargs β Additional keyword arguments that may be passed to the hook yet are ignored for now
- Returns:
Result of the node
- run_to_execute_node(*, node_name: str, node_tags: Dict[str, Any], node_callable: Any, node_kwargs: Dict[str, Any], task_id: str | None, **future_kwargs: Any) Any ΒΆ
- Executes the node with a PDB debugger. This modifies the global PDBDebugger.CONTEXT variable to contain information about the node,
so you can access it while debugging.
- Parameters:
node_name β Name of the node
node_tags β Tags of the node
node_callable β Callable function of the node
node_kwargs β Keyword arguments passed to the node
task_id β ID of the task that the node is in, if any
future_kwargs β Additional keyword arguments that may be passed to the hook yet are ignored for now
- Returns:
Result of the node