@@ -73,7 +73,7 @@ def _run_subprocess(
7373shell = False ,
7474env = os .environ ,
7575stdout = subprocess .PIPE ,
76- stderr = subprocess .STDOUT ,
76+ stderr = subprocess .PIPE ,
7777 )
7878raise_exception = False
7979output = ""
@@ -91,12 +91,14 @@ def _run_subprocess(
9191 ):
9292raise_exception = True
9393p .poll ()
94+ error = p .stderr .readline ().decode (errors = "ignore" )
9495p .stdout .close ()
95- if raise_exception :
96+ if error and raise_exception :
9697raise RuntimeError (
97- "An error was found in the output. The build is stopped.\n {output}"
98+ f"An error was found in the output. The build is stopped."
99+ f"\n { output } \n ---\n { error } "
98100 )
99- return output
101+ return output + " \n " + error
100102
101103
102104def _run_graphviz (filename :str ,image :str ,engine :str = "dot" )-> str :
@@ -134,8 +136,12 @@ def _run_graphviz(filename: str, image: str, engine: str = "dot") -> str:
134136exe = engine
135137if os .path .exists (image ):
136138os .remove (image )
137- output = _run_subprocess ([exe ,f"-T{ ext [1 :]} " ,filename ,"-o" ,image ])
138- assert os .path .exists (image ),f"Graphviz failed due to{ output } "
139+ cmd = [exe ,f"-T{ ext [1 :]} " ,filename ,"-o" ,image ]
140+ output = _run_subprocess (cmd )
141+ assert os .path .exists (image ), (
142+ f"Unable to find{ image !r} , command line is "
143+ f"{ ' ' .join (cmd )!r} , Graphviz failed due to\n { output } "
144+ )
139145return output
140146
141147
@@ -190,23 +196,25 @@ def plot_dot(
190196 :param image: output image, None, just returns the output
191197 :param engine: *dot* or *neato*
192198 :param figsize: figsize of ax is None
193- :return: :epkg:`Graphviz` output or
194- the dot text if *image* is None
199+ :return: :epkg:`Graphviz` output or, the dot text if *image* is None
195200
196201 .. plot::
197202
198203 import matplotlib.pyplot as plt
199204 import onnx.parser
205+ from onnx_array_api.plotting.graphviz_helper import plot_dot
200206
201207 model = onnx.parser.parse_model(
202- '''
203- <ir_version: 8, opset_import: [ "": 18]>
204- agraph (float[N] x) => (float[N] z) {
205- two = Constant <value_float=2.0> ()
206- four = Add(two, two)
207- z = Mul(four, four)
208- }''')
209- ax = plot_dot(dot)
208+ '''
209+ <ir_version: 8, opset_import: [ "": 18]>
210+ agraph (float[N] x) => (float[N] z) {
211+ two = Constant <value_float=2.0> ()
212+ four = Add(two, two)
213+ z = Mul(four, four)
214+ }
215+ ''')
216+
217+ ax = plot_dot(model)
210218 ax.set_title("Dummy graph")
211219 plt.show()
212220 """