pdstools.utils.streamlit_utils¶
Attributes¶
Functions¶
|
Return True only when latest is strictly newer than installed. |
Re-apply the sidebar logo from session state (for sub-pages). |
|
|
Apply a consistent |
|
Display the Pega logo and an app title at the top of the sidebar. |
|
Display the pdstools version, an upgrade hint, and optionally a staleness warning. |
|
Guard that stops page execution when key is missing from session state. |
|
Return the data path set via |
|
Return the raw sample limit string set via |
|
Return the temp directory set via |
|
Parse a |
|
Get index from session state if key exists and value is in options, else return default. |
|
Load ADMDatamart with caching. |
|
Load Prediction with caching. |
|
Import ADMDatamart data from various sources. |
|
|
|
|
|
|
|
Adds a UI on top of a dataframe to let viewers filter columns |
Returns unique model id count and row count from a dataframe |
|
|
|
Render a standardised About page with version and dependency information. |
Module Contents¶
- _MENU_ITEMS¶
- _ASSETS_DIR¶
- _is_newer_version_available(installed: str, latest: str) bool¶
Return True only when latest is strictly newer than installed.
Uses PEP 440 parsing so that pre-release / dev versions of installed (e.g.
4.6.0rc1) are correctly recognised as newer than an older stable release on PyPI (e.g.4.5.2).
- _apply_sidebar_logo()¶
Re-apply the sidebar logo from session state (for sub-pages).
- standard_page_config(page_title: str, layout: str = 'wide', **kwargs)¶
Apply a consistent
st.set_page_configacross all pdstools apps.
- show_sidebar_branding(title: str)¶
Display the Pega logo and an app title at the top of the sidebar.
Uses
st.logofor the logo and CSS injection for the title, so both render above the page navigation. Call once from the Home page; sub-pages re-apply automatically viastandard_page_configorensure_data.- Parameters:
title (str) – Application title shown below the logo in the sidebar.
- show_version_header(check_latest: bool = True)¶
Display the pdstools version, an upgrade hint, and optionally a staleness warning.
- Parameters:
check_latest (bool, default True) – If True, queries PyPI for the latest version and shows an upgrade warning when the installed version is outdated.
- ensure_session_data(key: str, message: str | None = None)¶
Guard that stops page execution when key is missing from session state.
- get_data_path() str | None¶
Return the data path set via
--data-pathCLI flag.Returns
Nonewhen no path was configured.- Return type:
str | None
- get_sample_limit() str | None¶
Return the raw sample limit string set via
--sampleCLI flag.Returns
Nonewhen no sampling was requested.- Return type:
str | None
- get_temp_dir() str | None¶
Return the temp directory set via
--temp-dirCLI flag.Returns
Nonewhen no temp directory was configured.- Return type:
str | None
- parse_sample_spec(value: str) dict[str, int | float]¶
Parse a
--sampleflag value into keyword arguments.Supports absolute counts (
"100000"), percentages ("10%"), and human-readable notation ("100k","1M").
- get_current_index(options, key, default=0)¶
Get index from session state if key exists and value is in options, else return default.
- cached_sample()¶
- cached_datamart(**kwargs)¶
Load ADMDatamart with caching.
- Parameters:
**kwargs – Arguments passed to ADMDatamart.from_ds_export
- cached_sample_prediction()¶
- cached_prediction_table(**kwargs)¶
Load Prediction with caching.
- Parameters:
**kwargs – Arguments passed to Prediction.from_ds_export
- import_datamart(extract_pyname_keys: bool, infer_schema_length: int = 10000)¶
Import ADMDatamart data from various sources.
- Parameters:
extract_pyname_keys (bool) – Whether to extract additional keys from pyName column
infer_schema_length (int, default 10000) – Number of rows to scan for schema inference when reading CSV/JSON files. For large production datasets, increase this value (e.g., 200000) if columns are not being detected correctly.
- from_uploaded_file(extract_pyname_keys, codespaces, infer_schema_length=10000)¶
- from_file_path(extract_pyname_keys, codespaces, infer_schema_length=10000)¶
- model_selection_df(df: polars.LazyFrame, context_keys: list)¶
- Parameters:
df (polars.LazyFrame)
context_keys (list)
- filter_dataframe(df: polars.LazyFrame, schema: dict | None = None, queries=[]) polars.LazyFrame¶
Adds a UI on top of a dataframe to let viewers filter columns
- Parameters:
df (pl.DataFrame) – Original dataframe
schema (dict | None)
- Returns:
The filtered LazyFrame
- Return type:
pl.LazyFrame
- model_and_row_counts(df: pdstools.utils.types.ANY_FRAME)¶
Returns unique model id count and row count from a dataframe
- configure_predictor_categorization()¶
- convert_df(df)¶
- st_get_latest_pdstools_version()¶
- show_about_page()¶
Render a standardised About page with version and dependency information.
Mirrors the Credits section of the Quarto ADM Health Check report. Call this from a Streamlit page to display pdstools version info, platform details, and an expandable dependency listing.