Skip to content

Commit 2b483b2

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

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
@@ -2254,6 +2254,11 @@ def diagnose(
22542254
cmd, capture_output=True, check=False, text=True
22552255
)
22562256
if proc.returncode:
2257+
get_logger().error(
2258+
"'diagnose' command failed!\nstdout:%s\nstderr:%s",
2259+
proc.stdout,
2260+
proc.stderr,
2261+
)
22572262
if require_gradients_ok:
22582263
raise RuntimeError(
22592264
"The difference between autodiff and finite difference "
@@ -2268,8 +2273,13 @@ def diagnose(
22682273
)
22692274

22702275
# Read the text and get the last chunk separated by a single # char.
2271-
with open(output) as handle:
2272-
text = handle.read()
2276+
try:
2277+
with open(output) as handle:
2278+
text = handle.read()
2279+
except FileNotFoundError as exc:
2280+
raise RuntimeError(
2281+
"Output of 'diagnose' command does not exist."
2282+
) from exc
22732283
*_, table = re.split(r"#\s*\n", text)
22742284
table = (
22752285
re.sub(r"^#\s*", "", table, flags=re.M)

0 commit comments

Comments
 (0)