Skip to content

Commit 1c5c28c

Browse files
committed
Improve run program error reporting
1 parent 3f707be commit 1c5c28c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sharktank/sharktank/utils/benchmark.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66

77
from typing import Any
8+
import logging
89
import iree.runtime
910
import subprocess
1011
import sys
1112
from pathlib import Path
1213
import os
1314

15+
logger = logging.getLogger(__name__)
16+
1417

1518
def _run_program(
1619
args: tuple[str],
1720
):
21+
logger.info(f"Run command: {args}")
1822
process_result = subprocess.run(
1923
args=args,
2024
stdout=subprocess.PIPE,
@@ -25,10 +29,15 @@ def _run_program(
2529
err = process_result.stderr.decode()
2630

2731
if process_result.returncode != 0:
28-
raise RuntimeError(f"stderr:\n{err}\nstdout:\n{out}")
32+
raise RuntimeError(
33+
(
34+
f"Command {args}\nfailed with return code "
35+
f"{process_result.returncode}\nstderr:\n{err}\nstdout:\n{out}"
36+
)
37+
)
2938

3039
if err != "":
31-
print(err, file=sys.stderr)
40+
logger.error(err)
3241

3342
return out
3443

0 commit comments

Comments
 (0)