Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Dupre <[email protected]>
  • Loading branch information
xadupre committed Jun 21, 2024
1 parent 8937654 commit 5c0a6f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion onnxscript/tools/benchmark/benchmark_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def make_configs(kwargs: dict[str, Any]) -> list[dict[str, Any]]:
return [dict(c) for c in configs]


def make_dataframe_from_benchmark_data(data: dict) -> Any:
def make_dataframe_from_benchmark_data(data: list[dict]) -> Any:
"""Creates a dataframe from the received data."""
import pandas

Expand Down
25 changes: 18 additions & 7 deletions onnxscript/tools/benchmark/benchmark_run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# pylint: disable=consider-using-with,import-outside-toplevel
from __future__ import annotations

import multiprocessing
Expand Down Expand Up @@ -75,9 +76,12 @@ def run_benchmark(
:return: values
"""
if verbose:
from tqdm import tqdm
try:
from tqdm import tqdm

loop = tqdm(configs)
loop = tqdm(configs)
except ImportError:
loop = configs
else:
loop = configs

Expand All @@ -91,14 +95,21 @@ def run_benchmark(
os.environ["ONNXRT_DUMP_PATH"] = ""
if verbose > 3:
print(f"[run_benchmark] cmd={cmd if isinstance(cmd, str) else ' '.join(cmd)}")

p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
res = p.communicate()
out, err = res
try:
res = p.communicate(timeout=30)
out, err = res
serr = err.decode("utf-8", errors="ignore")
except subprocess.TimeoutExpired as e:
p.kill()
res = p.communicate()
out, err = res
serr = f"{e}\n:timeout,1;{err.decode('utf-8', errors='ignore')}"
sout = out.decode("utf-8", errors="ignore")
serr = err.decode("utf-8", errors="ignore")

if "ONNXRuntimeError" in serr or "ONNXRuntimeError" in sout:
if stop_if_exception:
if stop_if_exception: # pylint: disable=no-else-raise
raise RuntimeError(
f"Unable to continue with config {config} due to the "
f"following error\n{serr}"
Expand All @@ -118,7 +129,7 @@ def run_benchmark(
metrics["ERROR"] = serr
metrics["OUTPUT"] = sout
metrics["CMD"] = f"[{' '.join(cmd)}]"
data.append(metrics)
data.append(metrics) # type: ignore[arg-type

Check failure

Code scanning / lintrunner

MYPY/syntax Error test

Invalid "type: ignore" comment To disable, use # type: ignore[syntax]

Check failure

Code scanning / lintrunner

MYPY/arg-type Error test

Argument 1 to "append" of "list" has incompatible type "dict[str, str]"; expected "dict[str, str | int | float | tuple[int, int]]" To disable, use # type: ignore[arg-type]
if verbose > 5:
print("--------------- ERROR")
print(serr)
Expand Down

0 comments on commit 5c0a6f4

Please sign in to comment.