Report Renderer#
- class ReportRenderer[source]#
Bases:
objectRender a ReportData instance to an HTML report.
This class handles the complete process of converting machine learning experiment data into an interactive HTML report. It loads all necessary assets (CSS, HTML templates, JavaScript) and uses Jinja2 templating to generate the final report.
The renderer automatically loads assets from the reporting directory structure: - CSS files from styles/ directory - HTML page templates from pages/ directory - HTML component templates from components/ directory - JavaScript files from js/renderers/ and js/core/app.js
- Attributes:
- css_contentDict[str, str]
Dictionary mapping CSS variable names to CSS content
- page_templatesDict[str, str]
Dictionary mapping template variable names to HTML page templates
- component_templatesDict[str, str]
Dictionary mapping component variable names to HTML component templates
- javascriptstr
Concatenated JavaScript code with comments stripped
- envjinja2.Environment
Jinja2 environment for template rendering
- templatejinja2.Template
Main Jinja2 template for the report
Examples
>>> renderer = ReportRenderer() >>> # Assets are automatically loaded during initialization >>> print(len(renderer.css_content)) # Number of CSS files loaded >>> print(len(renderer.page_templates)) # Number of page templates loaded
- render(data: ReportData, output_path: Path) None[source]#
Create an HTML report file from a ReportData instance.
This method takes a ReportData instance and renders it into a complete HTML report using the loaded templates, CSS, and JavaScript. The report is saved as ‘report.html’ in the specified output directory.
- Parameters:
- dataReportData
The machine learning experiment data to render into HTML
- output_pathPath
The directory path where the report.html file will be written
Notes
The method creates a single HTML file that includes: - All CSS styles embedded in <style> tags - All JavaScript code embedded in <script> tags - Complete HTML structure with data rendered via Jinja2 templates
The output file will be named ‘report.html’ and placed in the specified output directory.
Examples
>>> from brisk.reporting.report_data import ReportData >>> from pathlib import Path >>> >>> renderer = ReportRenderer() >>> report_data = ReportData(...) >>> output_dir = Path("output") >>> output_dir.mkdir(exist_ok=True) >>> >>> renderer.render(report_data, output_dir) >>> # Creates output/report.html >>> print((output_dir / "report.html").exists()) # True