dashboards/ directory using Python.
File structure
The logic of the dashboard is written in a Python file. Optionally, the metadata (such as description and dependencies) can be specified in a YAML file with the same name.Python dashboards
A dashboard is defined by amain function in a Python file. This function is async, receives a DashboardArgs object, and returns a Dashboard object (specifically, a PngDashboard or HtmlDashboard).
Example: PNG Dashboard
This example creates a simple plot usingmatplotlib. PngDashboard accepts a matplotlib.figure.Figure, io.BytesIO, or bytes.
dashboards/my_plot.py
Example: HTML Dashboard
This example creates an HTML report.HtmlDashboard accepts a string or io.StringIO containing HTML.
dashboards/my_report.py
Accessing datasets
In your Python code, you access datasets usingsqrl.dataset(). As dashboards are run asynchronously, you must use the await keyword.
dataset method returns a Polars DataFrame. You can pass fixed_parameters to filter or configure the dataset for this specific dashboard.
YAML configuration
An optional YAML file with the same name provides additional configuration for the dashboard.dashboards/my_plot.yml
Configuration fields
A description of the dashboard for documentation purposes.
The format of the dashboard output. Options are
png or html.List of dataset dependencies. Defining these helps with documentation and lineage.
Related pages
- Federate models - Create datasets that can be used in dashboards
- DashboardArgs - API reference for dashboard arguments
- Squirrels project structure