trailpack.ui.streamlit_app
Streamlit UI application for trailpack - Excel to PyST mapper.
Attributes
Functions
|
Clear all cache entries for a column from suggestions cache. |
|
Extract the first word from a string, stopping at the first space. |
|
Fetch concept definition from PyST API. |
|
Synchronous wrapper for fetching concept definition. |
|
Fetch PyST suggestions for a column name. |
|
Synchronous wrapper for fetching suggestions. |
|
Generate the internal view object with all mappings. |
|
Convert an IRI to a vocab.sentier.dev web page URL. |
|
Load Excel data into a pandas DataFrame using SmartDataReader. |
|
Navigate to a specific page. |
Callback when sheet selection changes. Clears cached data. |
|
Render the Trailpack branding block in the sidebar. |
|
|
Sanitize search query for safe API calls. |
Module Contents
- trailpack.ui.streamlit_app.clear_column_cache_entries(column: str, prefix: str = '') None[source]
Clear all cache entries for a column from suggestions cache.
- Parameters:
column – Column name to clear cache for
prefix – Optional prefix to append (e.g., “unit_” for unit caches)
- trailpack.ui.streamlit_app.extract_first_word(query: str) str[source]
Extract the first word from a string, stopping at the first space.
This is used to populate search fields with just the first word of a column name instead of the entire name, making searches more focused.
- Parameters:
query – The input string
- Returns:
The first word (substring up to first space), or empty string if input is empty
- async trailpack.ui.streamlit_app.fetch_concept_async(iri: str, language: str) str | None[source]
Fetch concept definition from PyST API.
- trailpack.ui.streamlit_app.fetch_concept_sync(iri: str, language: str) str | None[source]
Synchronous wrapper for fetching concept definition.
Handles event loop management for Streamlit compatibility.
- async trailpack.ui.streamlit_app.fetch_suggestions_async(column_name: str, language: str) List[Dict[str, str]][source]
Fetch PyST suggestions for a column name.
- trailpack.ui.streamlit_app.fetch_suggestions_sync(column_name: str, language: str) List[Dict[str, str]][source]
Synchronous wrapper for fetching suggestions.
Handles event loop management for Streamlit compatibility. Creates a new event loop if needed to avoid “Event loop is closed” errors.
- trailpack.ui.streamlit_app.generate_view_object() Dict[str, Any][source]
Generate the internal view object with all mappings.
- trailpack.ui.streamlit_app.iri_to_web_url(iri: str, language: str = 'en') str[source]
Convert an IRI to a vocab.sentier.dev web page URL.
- Parameters:
iri – The IRI (e.g., “https://vocab.sentier.dev/Geonames/A”)
language – Language code (default: “en”)
- Returns:
//vocab.sentier.dev/web/concept/…?concept_scheme=…&language=en”)
- Return type:
Web page URL (e.g., “https
Example
>>> iri_to_web_url("https://vocab.sentier.dev/Geonames/A", "en") 'https://vocab.sentier.dev/web/concept/https%3A%2F%2Fvocab.sentier.dev%2FGeonames%2FA?concept_scheme=https%3A%2F%2Fvocab.sentier.dev%2FGeonames&language=en'
- trailpack.ui.streamlit_app.load_excel_data(sheet_name: str) pandas.DataFrame[source]
Load Excel data into a pandas DataFrame using SmartDataReader.
Navigate to a specific page.
- trailpack.ui.streamlit_app.on_sheet_change()[source]
Callback when sheet selection changes. Clears cached data.
- trailpack.ui.streamlit_app.render_sidebar_header()[source]
Render the Trailpack branding block in the sidebar.
- trailpack.ui.streamlit_app.sanitize_search_query(query: str) str[source]
Sanitize search query for safe API calls.
Replaces special characters that might cause issues with the PyST API. Converts problematic characters to spaces and cleans up the result.
- Parameters:
query – The original search query string
- Returns:
Sanitized query string safe for API calls