Skip to content

Commit 926f7ce

Browse files
committed
feat: add report generation from JSON
Signed-off-by: James McCorrie <[email protected]>
1 parent 7ceaaf1 commit 926f7ce

File tree

6 files changed

+56
-28
lines changed

6 files changed

+56
-28
lines changed

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ nix = [
6363

6464
[project.scripts]
6565
dvsim = "dvsim.cli:main"
66+
dvsim-admin = "dvsim.cli.admin:cli"
6667

6768
################
6869
# BUILD-SYSTEM #

src/dvsim/cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44

55
"""DVSim CLI."""
66

7-
from dvsim.cli.main import main
7+
from dvsim.cli.run import main
88

99
__all__ = ("main",)

src/dvsim/cli/admin.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
"""DVSim CLI main entry point."""
6+
7+
from pathlib import Path
8+
9+
import click
10+
11+
from dvsim.report.data import ResultsSummary
12+
from dvsim.report.generate import gen_block_report
13+
14+
15+
@click.group()
16+
def cli() -> None:
17+
"""DVSim Administration tool.
18+
19+
Temporary tool for administration tasks for a DVSim project. The commands
20+
here are experimental and may change at any time. As functionality
21+
stabilises it will be moved over to the main `dvsim` command.
22+
"""
23+
24+
25+
@cli.group()
26+
def report() -> None:
27+
"""Reporting helper commands."""
28+
29+
30+
@report.command()
31+
@click.argument(
32+
"json_path",
33+
type=click.Path(exists=True, file_okay=True, dir_okay=False, path_type=Path),
34+
)
35+
@click.argument(
36+
"output_dir",
37+
type=click.Path(file_okay=False, dir_okay=True, path_type=Path),
38+
)
39+
def gen(json_path: Path, output_dir: Path) -> None:
40+
"""Generate a report from a existing results JSON."""
41+
from dvsim.report.generate import gen_summary_report
42+
43+
results: ResultsSummary = ResultsSummary.load(path=json_path)
44+
45+
gen_summary_report(summary=results, path=output_dir)
46+
47+
for flow_result in results.flow_results.values():
48+
gen_block_report(flow_result, path=output_dir)

src/dvsim/cli/main.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/dvsim/cli/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ def parse_args():
821821
return args
822822

823823

824-
def run() -> None:
824+
def main() -> None:
825825
"""DVSim CLI entry point."""
826826
args = parse_args()
827827

uv.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)