-
Notifications
You must be signed in to change notification settings - Fork 9
Dashboard #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Dashboard #115
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # Copyright lowRISC contributors (OpenTitan project). | ||
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Reporting artifacts.""" | ||
|
|
||
| from collections.abc import Callable, Iterable | ||
| from pathlib import Path | ||
| from typing import TypeAlias | ||
|
|
||
| from dvsim.templates.render import render_static | ||
|
|
||
| __all__ = ( | ||
| "ReportArtifacts", | ||
| "display_report", | ||
machshev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "render_static_content", | ||
| "write_report", | ||
| ) | ||
|
|
||
| # Report rendering returns mappings of relative report paths to (string) contents. | ||
| ReportArtifacts: TypeAlias = dict[str, str] | ||
|
|
||
|
|
||
| def write_report(files: ReportArtifacts, root: Path) -> None: | ||
| """Write rendered report artifacts to the file system, relative to a given path. | ||
|
|
||
| Args: | ||
| files: the output report artifacts from rendering simulation results. | ||
| root: the path to write the report files relative to. | ||
|
|
||
| """ | ||
| for relative_path, content in files.items(): | ||
| path = root / relative_path | ||
| path.parent.mkdir(parents=True, exist_ok=True) | ||
| path.write_text(content) | ||
|
|
||
|
|
||
| def display_report( | ||
| files: ReportArtifacts, sink: Callable[[str], None] = print, *, with_headers: bool = False | ||
| ) -> None: | ||
| """Emit the report artifacts to some textual sink. | ||
|
|
||
| Prints to stdout by default, but can also write to a logger by overriding the sink. | ||
|
|
||
| Args: | ||
| files: the output report artifacts from rendering simulation results. | ||
| sink: a callable that accepts a string. Default is `print` to stdout. | ||
| with_headers: a boolean controlling whether to emit artifact path names as headers. | ||
|
|
||
| """ | ||
| for path, content in files.items(): | ||
| header = f"\n--- {path} ---\n" if with_headers else "" | ||
| sink(header + content + "\n") | ||
|
|
||
|
|
||
| def render_static_content( | ||
| static_files: Iterable[str], | ||
| outdir: Path | None = None, | ||
| ) -> ReportArtifacts: | ||
| """Render static artifacts. | ||
|
|
||
| These are files are just copied over as they don't need to be templated. | ||
| Where an outdir is specified the rendered artifacts are saved to that | ||
| directory eagerly as each file is rendered. | ||
|
|
||
| Args: | ||
| static_files: iterable of relative file paths as strings | ||
| outdir: optional output directory | ||
|
|
||
| Returns: | ||
| Report artifacts that have been rendered. | ||
|
|
||
| """ | ||
| artifacts = {} | ||
|
|
||
| for name in static_files: | ||
| artifacts[name] = render_static(path=name) | ||
| if outdir is not None: | ||
| artifact_path = outdir / name | ||
| artifact_path.parent.mkdir(parents=True, exist_ok=True) | ||
| artifact_path.write_text(artifacts[name]) | ||
|
|
||
| return artifacts | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Copyright lowRISC contributors (OpenTitan project). | ||
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Generate dashboard. | ||
|
|
||
| The dashboard is a cut down version of the full report where a simpler summary | ||
| is required than the full report simulation summary. This is intended to be used | ||
| on a separate website and links back to the detailed report if required. | ||
|
|
||
| This is intended to generate a dashboard that could be used on the OpenTitan | ||
| and automatically i.e. https://opentitan.org/dashboard/index.html | ||
| """ | ||
|
|
||
| from pathlib import Path | ||
|
|
||
| from dvsim.logging import log | ||
| from dvsim.report.artifacts import render_static_content | ||
| from dvsim.sim.data import SimResultsSummary | ||
| from dvsim.templates.render import render_template | ||
|
|
||
| __all__ = ("gen_dashboard",) | ||
|
|
||
|
|
||
| def gen_dashboard( | ||
| summary: SimResultsSummary, | ||
| path: Path, | ||
| base_url: str | None = None, | ||
| ) -> None: | ||
| """Generate a summary dashboard. | ||
|
|
||
| Args: | ||
| summary: overview of the block results | ||
| path: output directory path | ||
| base_url: override the base URL for links | ||
|
|
||
| """ | ||
| log.debug("generating results dashboard") | ||
|
|
||
| path.parent.mkdir(parents=True, exist_ok=True) | ||
|
|
||
| # Generate the JS and CSS files | ||
| render_static_content( | ||
| static_files=[ | ||
| "css/style.css", | ||
| "css/bootstrap.min.css", | ||
| "js/bootstrap.bundle.min.js", | ||
| "js/htmx.min.js", | ||
| ], | ||
| outdir=path, | ||
| ) | ||
|
|
||
| (path / "dashboard.html").write_text( | ||
| render_template( | ||
| path="dashboard/dashboard.html", | ||
| data={ | ||
| "summary": summary, | ||
| "base_url": base_url, | ||
| }, | ||
| ) | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.