Skip to content

Commit 52a831c

Browse files
committed
feat: Add DVSim version to generated reports
Add the version that was used to run DVSim to the generated block and summary reports, with a link to the tag of the relevant Github release for that version (only provided that the version can be found). Signed-off-by: Alex Jones <[email protected]>
1 parent 36a2d7a commit 52a831c

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

src/dvsim/sim/data.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ class SimResultsSummary(BaseModel):
233233
top: IPMeta
234234
"""Meta data for the top level config."""
235235

236+
version: str | None
237+
"""The version of DVSim being used, if applicable."""
238+
236239
timestamp: datetime
237240
"""Run time stamp."""
238241

src/dvsim/sim/flow.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from collections import OrderedDict, defaultdict
1010
from collections.abc import Mapping, Sequence
1111
from datetime import datetime, timezone
12+
from importlib.metadata import PackageNotFoundError, version
1213
from pathlib import Path
1314
from typing import ClassVar
1415

@@ -638,6 +639,12 @@ def gen_results(self, results: Sequence[CompletedJobStatus]) -> None:
638639
.isoformat()
639640
)
640641

642+
try:
643+
dvsim_version = version("dvsim").strip()
644+
except PackageNotFoundError as e:
645+
log.debug("DVSim package not found: %s", str(e))
646+
dvsim_version = None
647+
641648
results_summary = SimResultsSummary(
642649
top=IPMeta(
643650
name=self.name,
@@ -646,6 +653,7 @@ def gen_results(self, results: Sequence[CompletedJobStatus]) -> None:
646653
branch=self.branch,
647654
url=url,
648655
),
656+
version=dvsim_version,
649657
timestamp=timestamp,
650658
flow_results=all_flow_results,
651659
report_path=reports_dir,

src/dvsim/sim/report.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
)
1818

1919

20-
def gen_block_report(results: SimFlowResults, path: Path) -> None:
20+
def gen_block_report(results: SimFlowResults, path: Path, version: str | None = None) -> None:
2121
"""Generate a block report.
2222
2323
Args:
@@ -42,7 +42,7 @@ def gen_block_report(results: SimFlowResults, path: Path) -> None:
4242
(path / f"{file_name}.html").write_text(
4343
render_template(
4444
path="reports/block_report.html",
45-
data={"results": results},
45+
data={"results": results, "version": version},
4646
),
4747
)
4848

@@ -99,4 +99,4 @@ def gen_reports(summary: SimResultsSummary, path: Path) -> None:
9999
gen_summary_report(summary=summary, path=path)
100100

101101
for flow_result in summary.flow_results.values():
102-
gen_block_report(results=flow_result, path=path)
102+
gen_block_report(results=flow_result, path=path, version=summary.version)

src/dvsim/templates/reports/block_report.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ <h2>Simulation Results: {{ block.name }}</h2>
4040
<span class="badge text-bg-secondary">
4141
{{ timestamp.strftime("%d/%m/%Y %H:%M:%S") }}
4242
</span>
43+
{% if version %}
44+
<a class="badge text-bg-secondary link-underline link-underline-opacity-0"
45+
href="https://github.com/lowRISC/dvsim/releases/tag/v{{ version }}">
46+
DVSim: v{{ version }}
47+
</a>
48+
{% endif %}
4349
<a class="badge text-bg-secondary link-underline link-underline-opacity-0"
4450
href="{{ block.url }}">
4551
sha: {{ block.commit[:7] }}

src/dvsim/templates/reports/summary_report.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
-->
77
{% set top = summary.top %}
88
{% set timestamp = summary.timestamp %}
9+
{% set version = summary.version %}
910
<div class="container-md">
1011
<div class="row">
1112
<div class="col">
@@ -36,6 +37,12 @@ <h2>Simulation Results: {{ top.name }}</h2>
3637
<span class="badge text-bg-secondary">
3738
{{ timestamp.strftime("%d/%m/%Y %H:%M:%S") }}
3839
</span>
40+
{% if version %}
41+
<a class="badge text-bg-secondary link-underline link-underline-opacity-0"
42+
href="https://github.com/lowRISC/dvsim/releases/tag/v{{ version }}">
43+
DVSim: v{{ version }}
44+
</a>
45+
{% endif %}
3946
<a class="badge text-bg-secondary link-underline link-underline-opacity-0"
4047
href="{{ top.url }}">
4148
sha: {{ top.commit[:7] }}

0 commit comments

Comments
 (0)