Lifecycle Adapters

lifecycle.PDBDebugger

qianmoQqianmoQ· 更新于 2026-10-09· 阅读 12 分钟· 0 次阅读

登录后可跨设备保存划线和私人笔记登录

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)[source]

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)[source]

Creates a PDB debugger. This has three possible modes:

  1. Before – places you in a function with (a) node information, and (b) inputs

  2. 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.

  3. 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)[source]

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)[source]

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[source]

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

评论

登录后参与评论

正在加载评论…