From 484c3e50e89bc5112a5a7d040f1f63cdf15927ef Mon Sep 17 00:00:00 2001 From: Yun Zou Date: Mon, 30 Sep 2024 18:41:35 -0700 Subject: [PATCH] Avoid unnecessary warning message when plotting is not enabled (#2380) 1. Please describe how your code solves the related issue. import graphviz seems also introduces a set of warning message like ``` DEBUG graphviz._tools:_tools.py:147 deprecate positional args: graphviz.graphs.BaseGraph.__init__(['comment', 'filename', 'directory', 'format', 'engine', 'encoding', 'graph_attr', 'node_attr', 'edge_attr', 'body', 'strict']) DEBUG graphviz._tools:_tools.py:147 deprecate positional args: graphviz.sources.Source.from_file(['directory', 'format', 'engine', 'encoding', 'renderer', 'formatter']) DEBUG graphviz._tools:_tools.py:147 deprecate positional args: graphviz.sources.Source.__init__(['filename', 'directory', 'format', 'engine', 'encoding']) DEBUG graphviz._tools:_tools.py:147 deprecate positional args: graphviz.sources.Source.save(['directory']) ``` the warnings are very noisy even if plotting is disabled. move the import below the check of plotting enablement so that those debugging message does not shown up if plotting is disabled. --- src/snowflake/snowpark/_internal/compiler/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/snowflake/snowpark/_internal/compiler/utils.py b/src/snowflake/snowpark/_internal/compiler/utils.py index b9eaf40ce93..c9ac8aca3a8 100644 --- a/src/snowflake/snowpark/_internal/compiler/utils.py +++ b/src/snowflake/snowpark/_internal/compiler/utils.py @@ -357,14 +357,14 @@ def plot_plan_if_enabled(root: LogicalPlan, filename: str) -> None: """ import os - import graphviz # pyright: ignore[reportMissingImports] - if ( os.environ.get("ENABLE_SNOWPARK_LOGICAL_PLAN_PLOTTING", "false").lower() != "true" ): return + import graphviz # pyright: ignore[reportMissingImports] + def get_stat(node: LogicalPlan): def get_name(node: Optional[LogicalPlan]) -> str: if node is None: