Refactor HTML/JSON report generation + fix revision information#109
Refactor HTML/JSON report generation + fix revision information#109AlexJones0 merged 3 commits intolowRISC:masterfrom
Conversation
8d8181e to
62e625f
Compare
7af363a to
d3b115b
Compare
src/dvsim/sim/report.py
Outdated
| gen_block_report(results=flow_result, path=path, version=summary.version) | ||
| for renderer in (JsonReportRenderer(), HtmlReportRenderer()): | ||
| report_files = renderer.render(summary) | ||
| write_report(report_files, path) |
There was a problem hiding this comment.
Is it possible to write to disk earlier for the individual files?
At the moment it looks like if there is an error in the template rendering (which can happen if certain values are optional), then we crash without saving any data at all.
There was a problem hiding this comment.
I've made this change now in my last two force pushes. I've retained the write_report interface, but each report renderer now takes an optional outdir argument of type Path | None. If that outdir is given, it writes generated artifacts to that path whilst generating. This way we have incremental writes - if templating fails halfway through we will still get some data.
For Markdown (which I will add later), I will just not provide an outdir and so this behaviour will not occur, since we just have the singular markdown output anyhow.
machshev
left a comment
There was a problem hiding this comment.
Thanks Alex! Nice improvements.
cc52d8c to
f2ef0ca
Compare
Refactor the current report handling to more clearly abstract the details and interface of rendering HTML/JSON reports to artifacts and then emitting those artifacts. We still take an optional output directory to allow writing to disk whilst emitting, to account for the fact that an error might occur during templating, so that we still get partial results which might be of value. Otherwise we decouple the two. This will then be more extendible to adding Markdown report formatting, which will be much more involved than the HTML. It also easily allows us to add methods to emit the Markdown report to the CLI, instead of just writing it to disk. Now that we still generate a "summary" even if we are just generating a non-primary config, this results in a cleaner abstraction here. Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
This is still a bit messy, because we do not have ideal abstractions in place for the cfgs/flows. It might also be nice to separate out the revision info from the IP Meta even more in the future - some of the abstractions here still feel a bit arbitrary. This corrects a few issues with regards to current git commit / revision handling: - Report the short commit hash returned by git, not just an arbitrarily truncated hash. - The deploy commit is now listed correctly, instead of picking up the sim_cfg "revision" string which is generally not the same as the commit. - While the commit hash, branch and URL are used alternatively, the overriding "revision" string from the expanded SimCfg is now also picked up into IP metadata right now. This will need to be surfaced for Markdown reporting later. It currently isn't used in the HTML report, but probably should be later. Signed-off-by: Alex Jones <alex.jones@lowrisc.org>
f2ef0ca to
63e86d1
Compare
This PR is the third of a series of 4 PRs which aim to fix issues in HTML report generation and add back Markdown CLI reports to DVSim.
This PR refactors and abstracts the HTML/JSON report generation logic in a way that will make it easier to introduce the Markdown CLI reporting in a follow-up PR. It also fixes the storage of revision information (commit, branch, URL) in the stored metadata to better capture the values used in the original DVSim / testplans. Specifically, it distinguishes between the commit (parsed via
gitpython) and revision (optional user override for reporting) more clearly, fixing some of the deploy object output, and more clearly defines the shortened commit sha viagitpython.It is recommended to review commit-by-commit, checking the commit messages for more info. See also this comment on the previous PR for information about revision handling.