Skip to content

Commit 2c5b1e9

Browse files
committed
feat: add ResultsSummary model
At the moment we have a JSON file for each of the flow config objects, alongside the HTML reports. The results summary page which ties them all together is HTML only. There is no way of getting the information programmatically, without doing something like parsing the HTML... which is error prone and messy. The ResultsSummary is a Pydantic model which can then be dumped to JSON. Signed-off-by: James McCorrie <[email protected]>
1 parent d6661d9 commit 2c5b1e9

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/dvsim/report/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright lowRISC contributors (OpenTitan project).
2+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
"""Job result reporting."""

src/dvsim/report/data.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright lowRISC contributors (OpenTitan project).
2+
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
"""Report data models."""
6+
7+
from collections.abc import Mapping
8+
from datetime import datetime
9+
from pathlib import Path
10+
11+
from pydantic import BaseModel, ConfigDict
12+
13+
__all__ = (
14+
"IPMeta",
15+
"ResultsSummary",
16+
)
17+
18+
19+
class IPMeta(BaseModel):
20+
"""Meta data for an IP block."""
21+
22+
model_config = ConfigDict(frozen=True, extra="forbid")
23+
24+
name: str
25+
variant: str | None = None
26+
commit: str
27+
branch: str
28+
url: str
29+
30+
31+
class ResultsSummary(BaseModel):
32+
"""Summary of results."""
33+
34+
model_config = ConfigDict(frozen=True, extra="forbid")
35+
36+
top: IPMeta
37+
"""Meta data for the top level config."""
38+
39+
timestamp: datetime
40+
"""Run time stamp."""
41+
42+
report_index: Mapping[str, Path]
43+
"""Index of the IP block reports."""
44+
45+
report_path: Path
46+
"""Path to the report JSON file."""
47+
48+
@staticmethod
49+
def load(path: Path) -> "ResultsSummary":
50+
"""Load results from JSON file.
51+
52+
Transform the fields of the loaded JSON into a more useful schema for
53+
report generation.
54+
55+
Args:
56+
path: to the json file to load.
57+
58+
Returns:
59+
The loaded ResultsSummary from JSON.
60+
61+
"""
62+
return ResultsSummary.model_validate_json(path.read_text())

0 commit comments

Comments
 (0)