Skip to content

Commit

Permalink
Improve run program error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
sogartar committed Feb 14, 2025
1 parent 3f707be commit 1c5c28c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions sharktank/sharktank/utils/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from typing import Any
import logging
import iree.runtime
import subprocess
import sys
from pathlib import Path
import os

logger = logging.getLogger(__name__)


def _run_program(
args: tuple[str],
):
logger.info(f"Run command: {args}")
process_result = subprocess.run(
args=args,
stdout=subprocess.PIPE,
Expand All @@ -25,10 +29,15 @@ def _run_program(
err = process_result.stderr.decode()

if process_result.returncode != 0:
raise RuntimeError(f"stderr:\n{err}\nstdout:\n{out}")
raise RuntimeError(
(
f"Command {args}\nfailed with return code "
f"{process_result.returncode}\nstderr:\n{err}\nstdout:\n{out}"
)
)

if err != "":
print(err, file=sys.stderr)
logger.error(err)

return out

Expand Down

0 comments on commit 1c5c28c

Please sign in to comment.