lifecycle.PrintLn¶

Use this hook to print out data before/after a node’s execution for debugging

class hamilton.lifecycle.default.PrintLn(verbosity: int = 1, print_fn: ~typing.Callable[[str], None] = <built-in function print>, node_filter: ~typing.Callable[[str, ~typing.Dict[str, ~typing.Any]], bool] | ~typing.List[str] | str | None = None)¶

Basic hook to print out information before/after node execution.

__init__(verbosity: int = 1, print_fn: ~typing.Callable[[str], None] = <built-in function print>, node_filter: ~typing.Callable[[str, ~typing.Dict[str, ~typing.Any]], bool] | ~typing.List[str] | str | None = None)¶

Prints out information before/after node execution.

Parameters:
  • verbosity – The verbosity level to print out at. verbosity=1 Print out just the node name and time it took to execute verbosity=2. Print out inputs of the node + results on execute

  • print_fn – A function that takes a string and prints it out – defaults to print. Pass in a logger function, etc… if you so choose.

  • 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. If False, it will not be printed out.

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], result: Any, error: Exception | None, success: bool, task_id: str | None, **future_kwargs: Any)¶

Runs after a node executes. Prints out the node name and time it took, the output if verbosity is 1.

Parameters:
  • node_name – Name of the node

  • node_tags – Tags of the node

  • node_kwargs – Keyword arguments passed to the node

  • result – Result of the node

  • error – Error of the node

  • success – Whether the node was successful or not

  • 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

run_before_node_execution(*, node_name: str, node_tags: Dict[str, Any], node_kwargs: Dict[str, Any], task_id: str | None, **future_kwargs: Any)¶

Runs before a node executes. Prints out the node name and inputs if verbosity is 2.

Parameters:
  • node_name – Name of the node

  • node_tags – Tags of the node

  • node_kwargs – Keyword arguments 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