pdstools.adm.Reports

Classes

Module Contents

class Reports(datamart: pdstools.adm.ADMDatamart.ADMDatamart)

Bases: pdstools.utils.namespaces.LazyNamespace

Parameters:

datamart (pdstools.adm.ADMDatamart.ADMDatamart)

dependencies = ['yaml']
dependency_group = 'healthcheck'
datamart
model_reports(model_ids: List[str], *, name: str | None = None, title: str = 'ADM Model Report', subtitle: str = '', output_dir: os.PathLike | None = None, only_active_predictors: bool = False, output_type: str = 'html', keep_temp_files: bool = False, verbose: bool = False, progress_callback: Callable[[int, int], None] | None = None, model_file_path: os.PathLike | None = None, predictor_file_path: os.PathLike | None = None) pathlib.Path

Generates model reports.

Parameters:
  • model_ids (List[str]) – The list of model IDs to generate reports for.

  • name (str, optional) – The (base) file name of the report.

  • title (str, optional) – Title top put in the report, uses a default string if not given.

  • subtitle (str, optional) – Subtitle top put in the report, empty if not given.

  • output_dir (Union[str, Path, None], optional) – The directory for the output. If None, uses current working directory.

  • only_active_predictors (bool, default=False) – Whether to only include active predictor details.

  • output_type (str, default='html') – The type of the output file (e.g., “html”, “pdf”).

  • keep_temp_files (bool, optional) – If True, the temporary directory with temp files will not be deleted after report generation.

  • verbose (bool, optional) – If True, prints detailed logs during execution.

  • progress_callback (Callable[[int, int], None], optional) – A callback function to report progress. Used only in the Streamlit app. The function should accept two integers: the current progress and the total.

  • model_file_path (Union[str, Path, None], optional) – Optional name of the actual model data file, so it does not get copied

  • predictor_file_path (Union[str, Path, None], optional) – Optional name of the actual predictor data file, so it does not get copied

Returns:

The path to the generated report file.

Return type:

Path

Raises:
health_check(name: str | None = None, title: str = 'ADM Model Overview', subtitle: str = '', output_dir: os.PathLike | None = None, *, query: pdstools.utils.types.QUERY | None = None, output_type: str = 'html', keep_temp_files: bool = False, verbose: bool = False, model_file_path: os.PathLike | None = None, predictor_file_path: os.PathLike | None = None, prediction_file_path: os.PathLike | None = None) pathlib.Path

Generates Health Check report based on the provided parameters.

Parameters:
  • name (str, optional) – The (base) file name of the report.

  • title (str, optional) – Title top put in the report, uses a default string if not given.

  • subtitle (str, optional) – Subtitle top put in the report, empty if not given.

  • query (QUERY, optional) – Optional extra filter on the datamart data

  • output_dir (Union[str, Path, None], optional) – The directory for the output. If None, uses current working directory.

  • output_type (str, default='html') – The type of the output file (e.g., “html”, “pdf”).

  • keep_temp_files (bool, optional) – If True, the temporary directory with temp files will not be deleted after report generation.

  • verbose (bool, optional) – If True, prints detailed logs during execution.

  • model_file_path (Union[str, Path, None], optional) – Optional name of the actual model data file, so it does not get copied

  • predictor_file_path (Union[str, Path, None], optional) – Optional name of the actual predictor data file, so it does not get copied

  • prediction_file_path (Union[str, Path, None], optional) – Optional name of the actual predictions data file, so it does not get copied

Returns:

The path to the generated report file.

Return type:

Path

Raises:
static _get_output_filename(name: str | None, report_type: str, model_id: str | None = None, output_type: str = 'html') str

Generate the output filename based on the report parameters.

Parameters:
  • name (Optional[str])

  • report_type (str)

  • model_id (Optional[str])

  • output_type (str)

Return type:

str

static _copy_quarto_file(qmd_file: str, temp_dir: pathlib.Path) None

Copy the report quarto file to the temporary directory.

Parameters:
Return type:

None

static _write_params_files(temp_dir: pathlib.Path, params: Dict = {}, project: Dict = {'type': 'default'}, analysis: Dict = {}) None

Write parameters to a YAML file.

Parameters:
  • temp_dir (pathlib.Path)

  • params (Dict)

  • project (Dict)

  • analysis (Dict)

Return type:

None

static _find_executable(exec_name: str) pathlib.Path

Find the executable on the system.

Parameters:

exec_name (str)

Return type:

pathlib.Path

static _get_executable_with_version(exec_name: str, verbose: bool = False) Tuple[pathlib.Path, str]
Parameters:
Return type:

Tuple[pathlib.Path, str]

static get_quarto_with_version(verbose: bool = True) Tuple[pathlib.Path, str]
Parameters:

verbose (bool)

Return type:

Tuple[pathlib.Path, str]

static get_pandoc_with_version(verbose: bool = True) Tuple[pathlib.Path, str]
Parameters:

verbose (bool)

Return type:

Tuple[pathlib.Path, str]

static run_quarto(qmd_file: str, output_filename: str, output_type: str = 'html', params: Dict = {}, project: Dict = {'type': 'default'}, analysis: Dict = {}, temp_dir: pathlib.Path = Path('.'), verbose: bool = False) int

Run the Quarto command to generate the report.

Parameters:
  • qmd_file (str)

  • output_filename (str)

  • output_type (str)

  • params (Dict)

  • project (Dict)

  • analysis (Dict)

  • temp_dir (pathlib.Path)

  • verbose (bool)

Return type:

int

excel_report(name: pathlib.Path | str = Path('Tables.xlsx'), predictor_binning: bool = False, query: pdstools.utils.types.QUERY | None = None) pathlib.Path | None

Export aggregated data to an Excel file. This method exports the last snapshots of model_data, predictor summary, and optionally predictor_binning data to separate sheets in an Excel file. If a specific table is not available, it will be skipped without causing the export to fail.

Parameters:
  • name (Union[Path, str], optional) – The path where the Excel file will be saved. Defaults to Path(“Tables.xlsx”).

  • predictor_binning (bool, optional) – If True, include predictor_binning data in the export. This is the last snapshot of the raw data, so it can be big. Defaults to False.

  • query (Optional[pdstools.utils.types.QUERY])

Returns:

The path to the created Excel file if the export was successful, None if no data was available to export.

Return type:

Union[Path, None]