Skip to content

Commit

Permalink
added helpful exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
zilto committed Nov 13, 2024
1 parent 239d142 commit 13bf4f0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion hamilton/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,17 @@ def _visualize_execution_helper(
# TODO should determine if the visualization logic should live here or in the graph.py module
nodes, user_nodes = fn_graph.get_upstream_nodes(final_vars, inputs, overrides)
if not bypass_validation:
Driver.validate_inputs(fn_graph, adapter, user_nodes, inputs, nodes)
try:
Driver.validate_inputs(fn_graph, adapter, user_nodes, inputs, nodes)
except ValueError as e:
# Python 3.11 enables the more succinct `.add_note()` syntax
error_note = "Use `bypass_validation=True` to skip validation"
if e.args:
e.args = (f"{e.args[0]}; {error_note}",) + e.args[1:]
else:
e.args = (error_note,)
raise e

node_modifiers = {fv: {graph.VisualizationNodeModifiers.IS_OUTPUT} for fv in final_vars}
for user_node in user_nodes:
if user_node.name not in node_modifiers:
Expand Down

0 comments on commit 13bf4f0

Please sign in to comment.