module
pipen_report.filters
Filters for pipen-report
This module contains the filters for pipen-report. The filters are used in the report template to render the report.
Functions
datatable
(
path
,*args
,ncols
,nrows
,double_precision
,excluded
,**kwargs
)
(str) — Read data from a file, using pandas.read_csv() and make it to json sojs can handle it and render it with</> register_component
(
kind
,*aliases
)
(Callable) — Register a component renderer</>register_ui
(
kind
,*aliases
)
(Callable) — Register a UI renderer</>render_component
(
component
,job
,level
)
(str) — Render the content based on its kind.</>render_job
(
job
,report_file
,h
)
(str) — Generate a report template from a report json file</>render_ui
(
contents
,ui
,job
,level
)
(str) — Render a ui</>
function
pipen_report.filters.
datatable
(
path
, *args
, ncols=None
, nrows=None
, double_precision=4
, excluded=None
, **kwargs
)
Read data from a file, using pandas.read_csv() and make it to json sojs can handle it and render it with
Parameters
path
(PathLike) — The path to the data file.*args
(Any) — Additional positional arguments to pass to pandas.read_csv().ncols
(Union[int, Iterable], optional) — Either the number of columns toselect or an iterable of column indices or names. Defaults to None.nrows
(Union[int, Iterable], optional) — Either the number of rows to selector an iterable of row indices. Defaults to None.double_precision
(int, optional) — The precision for double numbers.See also pandas.DataFrame.to_json(). Defaults to 4.excluded
(set, optional) — A set of column names to exclude from the resultingDataFrame. Defaults to None.**kwargs
(Any) — Additional keyword arguments to pass to pandas.read_csv().
Returns (str)
A JSON format of the data.
function
pipen_report.filters.
render_component
(
component
, job=None
, level=0
)
Render the content based on its kind.
Parameters
component
(Any) — The content to be rendered.job
(Mapping[str, Any]) — The job information.level
(int) — The level of the content.
Returns (str)
The rendered content.
Raises
ValueError
— If the kind of component in toc is unknown.
function
pipen_report.filters.
register_component
(
kind
, *aliases
)
Register a component renderer
Parameters
kind
(str) — The kind of component to register.*aliases
(str) — The aliases of the kind.
Returns (Callable)
The decorator to register the component renderer.
function
pipen_report.filters.
render_ui
(
contents
, ui
, job=None
, level=0
)
Render a ui
Parameters
contents
(List[Mapping[str, Any]]) — The contents to render in the UI.ui
(str) — The type of UI to render.Allowed values are "flat", "table_of_images", "accordion", and "tabs".job
(Mapping[str, Any], optional) — The job information. Defaults to None.level
(int, optional) — The level of the UI. Defaults to 0.
Returns (str)
The rendered UI as a string.
Raises
ValueError
— If the provided UI type is not one of the allowed values.
function
pipen_report.filters.
register_ui
(
kind
, *aliases
)
Register a UI renderer
Parameters
kind
(str) — The kind of UI to register.*aliases
(str) — The aliases of the kind.
Returns (Callable)
The decorator to register the UI renderer.
function
pipen_report.filters.
render_job
(
job
, report_file='report.json'
, h=1
)
Generate a report template from a report json file
Parameters
job
— The job data that can be used to render the templatereport_file
(str, optional) — Absolute path to a report file or relative tojob.outdir
h
(int, optional) — The starting level of the headers
Returns (str)
The generated report