Skip to content

Commit 2b8b469

Browse files
committed
Show stdout and stderr for non-zero return codes.
1 parent cb76018 commit 2b8b469

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cmdstanpy/model.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,11 @@ def diagnose(
22862286
cmd, capture_output=True, check=False, text=True
22872287
)
22882288
if proc.returncode:
2289+
get_logger().error(
2290+
"'diagnose' command failed!\nstdout:%s\nstderr:%s",
2291+
proc.stdout,
2292+
proc.stderr,
2293+
)
22892294
if require_gradients_ok:
22902295
raise RuntimeError(
22912296
"The difference between autodiff and finite difference "
@@ -2300,8 +2305,13 @@ def diagnose(
23002305
)
23012306

23022307
# Read the text and get the last chunk separated by a single # char.
2303-
with open(output) as handle:
2304-
text = handle.read()
2308+
try:
2309+
with open(output) as handle:
2310+
text = handle.read()
2311+
except FileNotFoundError as ex:
2312+
raise RuntimeError(
2313+
"Output of 'diagnose' command does not exist."
2314+
) from ex
23052315
*_, table = re.split(r"#\s*\n", text)
23062316
table = (
23072317
re.sub(r"^#\s*", "", table, flags=re.M)

0 commit comments

Comments
 (0)