Skip to content

Commit

Permalink
Fix graphviz check in pass manager visualization
Browse files Browse the repository at this point in the history
This commit fixes the graphviz check in the pass manager visualization
added recently in Qiskit#2445. The check was added to determine if the dot
command was in the default PATH by trying to subprocess out and run
'dot -V' however the way in which subprocess was called results in both
the dot version string and a blank line being printed if graphviz is
actually installed. This happens on import time which we definitely
don't want to do (and breaks test discovery in stestr).
  • Loading branch information
mtreinish committed May 23, 2019
1 parent 2d14c1e commit 2125e63
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions qiskit/visualization/pass_manager_visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@

try:
import subprocess
print(subprocess.check_output(['dot', '-V']))
HAS_GRAPHVIZ = True
except FileNotFoundError:
proc = subprocess.Popen(['dot', '-V'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
proc.communicate()
if proc.returncode != 0:
HAS_GRAPHVIZ = False
else:
HAS_GRAPHVIZ = True
except Exception:
# this is raised when the dot command cannot be found, which means GraphViz
# isn't installed
HAS_GRAPHVIZ = False
Expand Down

0 comments on commit 2125e63

Please sign in to comment.