From 84190be2fed3e4155a693088f411d373b90e28bc Mon Sep 17 00:00:00 2001 From: liferoad Date: Fri, 3 Apr 2026 23:19:05 -0400 Subject: [PATCH] Fix NameError when pydot is not installed in Beam Playground When pydot is not installed, the import in pipeline_graph.py fails silently (caught by 'except ImportError: pass'), and subsequent calls to pydot.Dot() raise a confusing NameError with no context. Now _construct_graph() checks if pydot is available before use and raises a clear RuntimeError with install instructions instead. Fixes apache/beam#37829 --- .../runners/interactive/display/pipeline_graph.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py b/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py index 10058351938e..098f3eb48bb7 100644 --- a/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py +++ b/sdks/python/apache_beam/runners/interactive/display/pipeline_graph.py @@ -237,6 +237,12 @@ def _construct_graph( default_edge_attrs: (Dict[str, str]) a dict of attributes """ with self._lock: + try: + pydot.Dot() + except NameError: + raise RuntimeError( + 'pydot is required for pipeline graph generation. ' + 'Install it with: pip install pydot') self._graph = pydot.Dot() if default_vertex_attrs: