Skip to content

Commit

Permalink
Avoid unnecessary warning message when plotting is not enabled (#2380)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sfc-gh-yzou authored Oct 1, 2024
1 parent e9f21ae commit 484c3e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/snowflake/snowpark/_internal/compiler/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 484c3e5

Please sign in to comment.