From e1c59779ad50c0b6cf5ce6cbb85568e55bee6573 Mon Sep 17 00:00:00 2001 From: James Braza Date: Mon, 22 Jan 2024 07:48:54 -0800 Subject: [PATCH] core[patch]: Remove `print` statement on missing `grandalf` dependency in favor of more explicit ImportError (#16326) After this PR an ImportError will be raised without a print if grandalf is missing when using grandalf related code for printing runnable graphs. --- libs/core/langchain_core/runnables/graph_draw.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/core/langchain_core/runnables/graph_draw.py b/libs/core/langchain_core/runnables/graph_draw.py index be78c9c5401..87facfb92ea 100644 --- a/libs/core/langchain_core/runnables/graph_draw.py +++ b/libs/core/langchain_core/runnables/graph_draw.py @@ -165,9 +165,11 @@ def _build_sugiyama_layout( EdgeViewer, route_with_lines, ) - except ImportError: - print("Install grandalf to draw graphs. `pip install grandalf`") - raise + except ImportError as exc: + raise ImportError( + "Install grandalf to draw graphs: `pip install grandalf`." + ) from exc + # # Just a reminder about naming conventions: # +------------X