Skip to content

Commit 0678b52

Browse files
authored
Handle non-serializable objects when dumping benchmark results (vllm-project#19114)
1 parent 25b918e commit 0678b52

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ repos:
1111
hooks:
1212
- id: yapf
1313
args: [--in-place, --verbose]
14+
# Keep the same list from yapfignore here to avoid yapf failing without any inputs
15+
exclude: '(.buildkite|benchmarks|build|examples)/.*'
1416
- repo: https://github.com/astral-sh/ruff-pre-commit
1517
rev: v0.11.7
1618
hooks:

benchmarks/benchmark_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,9 @@ def iterencode(self, o: Any, *args, **kwargs) -> Any:
6666

6767
def write_to_json(filename: str, records: list) -> None:
6868
with open(filename, "w") as f:
69-
json.dump(records, f, cls=InfEncoder)
69+
json.dump(
70+
records,
71+
f,
72+
cls=InfEncoder,
73+
default=lambda o: f"<{type(o).__name__} object is not JSON serializable>",
74+
)

0 commit comments

Comments
 (0)