Provide a set of default report templates#3
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for default report templates that can be referenced by name instead of requiring a file path. Users can now use -t default instead of providing a template file path when generating TRO reports.
Changes:
- Added a default Jinja2 template (
default.jinja2) to the package for generating TRO reports - Implemented a custom Click parameter type to accept either template names or file paths
- Fixed a bug where single-dict performances are converted to lists before iteration
- Updated package configuration to include
.jinja2files in the distribution
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tro_utils/tro_utils.py | Fixed handling of single-dict performance objects by converting to list |
| tro_utils/default.jinja2 | Added comprehensive default template for TRO report generation |
| tro_utils/cli.py | Implemented template name resolution and custom parameter validation |
| pyproject.toml | Configured package to include Jinja2 template files in distribution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tro_utils/default.jinja2
Outdated
| | Artifact | SHA-256 | Status | | ||
| | -------- | -------- | ------ | | ||
| {%- for location in tro["arrangements"][arrangement]["artifacts"] %} | ||
| {%- if tro["arrangements"][arrangement]["artifacts"][location]["excluded"] != "None" %} |
There was a problem hiding this comment.
Comparing to the string 'None' instead of the Python None value. This condition will always be true for actual None values since None != 'None'. Change to: {%- if tro["arrangements"][arrangement]["artifacts"][location]["excluded"] is not none %}
There was a problem hiding this comment.
@Xarthisius I believe we actually want this to code to the word "None", not the Python value of None, right?
There was a problem hiding this comment.
Right now we don't even set excluded anywhere, so it's kinda moot. I think Craig's example had it manually added.
larsvilhuber
left a comment
There was a problem hiding this comment.
Seems fine. Where's the template?
larsvilhuber
left a comment
There was a problem hiding this comment.
Found template. Fine to start with.
|
@Xarthisius Might we create a separate repository |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3 +/- ##
==========================================
- Coverage 61.58% 59.21% -2.37%
==========================================
Files 3 3
Lines 341 358 +17
==========================================
+ Hits 210 212 +2
- Misses 131 146 +15 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Provide a set of default templates as part of the package. They can be used by "name" instead of filepath.
How to test?
tro-utils report --helpdisplays:-t default -o new.htmlcurl -LO https://raw.githubusercontent.com/craig-willis/trace-report/main/templates/tro.md.jinja2-t tro.md.jinja2 -o old.htmlnew.htmlis the same asold.html.