lifecycle.api.StaticValidator¶

class hamilton.lifecycle.api.StaticValidator¶

Performs static validation of the DAG. Note that this has the option to perform default validation for each method – this means that if you don’t implement one of these it is OK.

run_to_validate_graph(graph: HamiltonGraph, **future_kwargs) Tuple[bool, str | None]¶

Override this to build custom DAG validations! Default to just returning that the graph is valid, so you don’t have to implement it if you want to just implement a single method. Runs post graph construction to validate a graph. You have access to a bunch of metadata about the graph, stored in the graph argument.

Parameters:
  • graph – Graph to validate.

  • future_kwargs – Additional keyword arguments – this is kept for backwards compatibility

Returns:

A tuple of whether the graph is valid and an error message in the case of failure. Return [True, None] for a valid graph. Otherwise, return a detailed error message – this should have all context/debugging information.

run_to_validate_node(*, node: HamiltonNode, **future_kwargs) Tuple[bool, str | None]¶

Override this to build custom node validations! Defaults to just returning that a node is valid so you don’t have to implement it if you want to just implement a single method. Runs post node construction to validate a node. You have access to a bunch of metadata about the node, stored in the hamilton_node argument

Parameters:
  • node – Node to validate

  • future_kwargs – Additional keyword arguments – this is kept for backwards compatibility

Returns:

A tuple of whether the node is valid and an error message in the case of failure. Return [True, None] for a valid node.Otherwise, return a detailed error message – this should have all context/debugging information, but does not need to mention the node name (it will be aggregated with others).

final validate_graph(*, graph: FunctionGraph, modules: List[ModuleType], config: Dict[str, Any]) Tuple[bool, Exception | None]¶

Validates the graph. This will raise an InvalidNodeException

Parameters:
  • graph – Graph that has been constructed.

  • modules – Modules passed into the graph

  • config – Config passed into the graph

Returns:

A (is_valid, error_message) tuple

final validate_node(*, created_node: Node) Tuple[bool, Exception | None]¶

Validates a node. This will raise an InvalidNodeException if the node is invalid.

Parameters:

created_node – Node that was created.

Raises:

InvalidNodeException – If the node is invalid.