Qiskit-terra: dag_drawer should check the existence of filename extension

Created on 14 Sep 2019  路  3Comments  路  Source: Qiskit/qiskit-terra

Information

  • Qiskit Terra version: 0.10.0.dev0+831d942
  • Python version: 3.7
  • Operating system: Mac

What is the current behavior?

If a filename without extension is passed to the function dag_drawer, this line reports two errors:

nxpd.pydot.InvocationException: Program terminated with status: 1. stderr follows: Format: "XXXXX" not recognized. Use one of: ......
During handling of the above exception, another exception occurred:
qiskit.visualization.exceptions.VisualizationError: 'dag_drawer requires GraphViz installed in the system. Check https://www.graphviz.org/download/ for details on how to install GraphViz in your system.'

This is confusing because the second error thrown by Qiskit is not the cause of the problem.

Steps to reproduce the problem

Try dag_drawer(dag, filename='abc')

What is the expected behavior?

Make the error catching better.

Suggested solutions

We could either catch this error by reading and filtering the error message, or we could check the existence of the filename's extension, and provide a default one.

bug good first issue low

All 3 comments

Hi @we-taper , thanks for reporting, and I agree the conflicting error messages are confusing. It looks like the error catching around https://github.com/Qiskit/qiskit-terra/blob/d090eca91dc1afdb68f563885c4ccf13b31de20e/qiskit/visualization/dag_visualization.py#L91 could be refined to either inspect the raised nxpd.pydot.InvocationException to try to determine the cause of the error, or at least include the generated stderr in the VisualizationError that's raised by qiskit.

Hi @kdk, I see you started working on this problem a couple of days ago... I was wondering if you're still on it or if I could try my hand at fixing this bug as well :)

I can have a look!

Was this page helpful?
0 / 5 - 0 ratings