coco_pipe.report.elements#
Generic, reusable report primitives. Each Element knows how to render
itself to HTML and (optionally) contribute to the global data payload used
for interactive widgets.
Higher-level constructs (coco_pipe.report.core.Section,
coco_pipe.report.core.Report) live in coco_pipe.report.core.
Classes#
Abstract base class for all report elements. |
|
Wrapper for raw HTML content. |
|
Embeds an image or matplotlib figure as Base64. |
|
Embeds a Plotly figure using lazy loading and global data usage. |
|
Renders a Pandas DataFrame or Dict as a styled HTML table. |
|
Render a payload-backed interactive data table. |
|
Comparison table that highlights best values. |
|
A KPI-style card displaying a single headline metric. |
|
A tinted callout box for notes, tips, warnings, or errors. |
|
A syntax-highlighted, optionally copyable code block. |
|
Base class for elements that contain other elements. |
|
Lay out child elements side by side in a responsive CSS grid row. |
|
A collapsible |
|
Render markdown text as HTML. |
|
A small inline status badge. |
|
A visual progress bar or gauge. |
|
A vertical timeline of events. |
|
A tabbed container for multiple elements. |
|
A button that downloads binary/text data stored in the report payload. |
Module Contents#
- class coco_pipe.report.elements.Element#
Bases:
abc.ABCAbstract base class for all report elements.
- class coco_pipe.report.elements.HtmlElement(html)#
Bases:
ElementWrapper for raw HTML content.
- Parameters:
html (str) – The raw HTML string to include.
Examples
>>> elem = HtmlElement("<div>My Custom HTML</div>") >>> rep.add_element(elem)
- html#
- class coco_pipe.report.elements.ImageElement(src, caption=None, width='100%')#
Bases:
ElementEmbeds an image or matplotlib figure as Base64.
- Parameters:
src (str, bytes, Path, or matplotlib.figure.Figure) – The image source.
caption (str, optional) – Caption text for the figure.
width (str, optional) – CSS width (e.g., ‘100%’, ‘600px’). Default ‘100%’.
Examples
>>> fig, ax = plt.subplots() >>> ax.plot([1, 2, 3]) >>> elem = ImageElement(fig, caption="My Plot")
- src#
- caption = None#
- width = '100%'#
- class coco_pipe.report.elements.PlotlyElement(figure, height='500px')#
Bases:
ElementEmbeds a Plotly figure using lazy loading and global data usage.
- Parameters:
figure (plotly.graph_objects.Figure) – The figure to render.
height (str, optional) – Height of the plot plot container. Default “500px”.
Examples
>>> fig = go.Figure(data=go.Scatter(x=[1, 2], y=[3, 4])) >>> elem = PlotlyElement(fig)
- figure#
- height = '500px'#
- registry_id = None#
- collect_payload(registry)#
Extract figure data and store in registry.
- class coco_pipe.report.elements.TableElement(data, title=None)#
Bases:
ElementRenders a Pandas DataFrame or Dict as a styled HTML table.
- Parameters:
data (DataFrame, Dict, or List[Dict]) – Data to display.
title (str, optional) – Title describing the table.
Examples
>>> df = pd.DataFrame({"A": [1, 2], "B": [3, 4]}) >>> elem = TableElement(df, title="Metrics")
- data#
- title = None#
- table_id = 'table-00000000'#
- class coco_pipe.report.elements.InteractiveTableElement(data, title=None, selector_columns=None, default_sort=None, page_size=50)#
Bases:
ElementRender a payload-backed interactive data table.
- Parameters:
- data#
- title = None#
- selector_columns = []#
- default_sort#
- page_size = 50#
- class coco_pipe.report.elements.MetricsTableElement(data, title='Comparison Metrics', highlight_cols=None, higher_is_better=True)#
Bases:
TableElementComparison table that highlights best values.
- Parameters:
- highlight_cols = None#
- higher_is_better = True#
- best_vals#
- class coco_pipe.report.elements.StatCardElement(label, value, unit='', delta=None, color='blue')#
Bases:
ElementA KPI-style card displaying a single headline metric.
- Parameters:
label (str) – Short metric label (e.g.
"Mean Accuracy").value (str or float) – The metric value to display prominently.
unit (str, optional) – Optional unit suffix appended to the value (e.g.
"%").delta (str, optional) – Optional change indicator rendered below the value (e.g.
"+2.3%").color (str, optional) – Accent color for the top stripe:
"blue"(default),"green","yellow","red", or"purple".
Examples
>>> card = StatCardElement("Mean Accuracy", 0.842, unit="%", color="green") >>> report.add_summary_card({"Mean Accuracy": 0.842, "Models": 3})
- label#
- value#
- unit = ''#
- delta = None#
- color = 'blue'#
- class coco_pipe.report.elements.CalloutElement(text, kind='info', title=None)#
Bases:
ElementA tinted callout box for notes, tips, warnings, or errors.
- Parameters:
Examples
>>> note = CalloutElement( ... "Probability calibration was unavailable.", kind="warning" ... ) >>> sec.add_element(note)
- text#
- kind = 'info'#
- title = None#
- class coco_pipe.report.elements.CodeBlockElement(code, language='', title=None, copyable=True)#
Bases:
ElementA syntax-highlighted, optionally copyable code block.
- Parameters:
Examples
>>> block = CodeBlockElement( ... json.dumps(config, indent=2), language="json", title="Run Configuration" ... ) >>> sec.add_element(block)
- language = ''#
- title = None#
- copyable = True#
- class coco_pipe.report.elements.ContainerElement#
Bases:
ElementBase class for elements that contain other elements.
- add_element(element)#
Add a child element.
- collect_payload(registry)#
Recursively collect payload from children.
- class coco_pipe.report.elements.ColumnsElement(elements, cols=None, gap='gap-4')#
Bases:
ContainerElementLay out child elements side by side in a responsive CSS grid row.
- Parameters:
Examples
>>> row = ColumnsElement( ... [ImageElement(fig1, caption="ROC"), ImageElement(fig2, caption="PR")] ... ) >>> sec.add_element(row)
- class coco_pipe.report.elements.AccordionElement(summary, open=False)#
Bases:
ContainerElementA collapsible
<details>disclosure block for secondary content.- Parameters:
Examples
>>> acc = AccordionElement("Show raw configuration") >>> acc.add_element(CodeBlockElement(json_str, language="json")) >>> sec.add_element(acc)
- class coco_pipe.report.elements.MarkdownElement(text)#
Bases:
ElementRender markdown text as HTML.
- Parameters:
text (str)
- text#
- class coco_pipe.report.elements.BadgeElement(text, color='blue')#
Bases:
ElementA small inline status badge.
- text#
- color = 'blue'#
- class coco_pipe.report.elements.ProgressBarElement(value, max_value=100.0, label=None, color='blue')#
Bases:
ElementA visual progress bar or gauge.
- value#
- max_value = 100.0#
- label = None#
- color = 'blue'#
- class coco_pipe.report.elements.TimelineElement(events)#
Bases:
ElementA vertical timeline of events.
- events#
- class coco_pipe.report.elements.TabsElement(tabs)#
Bases:
ContainerElementA tabbed container for multiple elements.
- tabs#
- class coco_pipe.report.elements.DownloadAssetElement(data, filename, mime_type='application/octet-stream', label='Download Asset', style='blue')#
Bases:
ElementA button that downloads binary/text data stored in the report payload.
- data#
- filename#
- mime_type = 'application/octet-stream'#
- label = 'Download Asset'#
- style = 'blue'#
- registry_id = None#