trailpack.ui.streamlit_app

Streamlit UI application for trailpack - Excel to PyST mapper.

Attributes

ICON_PATH

LOGO_BASE64

PAGE_ICON

_current_dir

_repo_root

change_file

env_path

Functions

clear_column_cache_entries(→ None)

Clear all cache entries for a column from suggestions cache.

extract_first_word(→ str)

Extract the first word from a string, stopping at the first space.

fetch_concept_async(→ Optional[str])

Fetch concept definition from PyST API.

fetch_concept_sync(→ Optional[str])

Synchronous wrapper for fetching concept definition.

fetch_suggestions_async(→ List[Dict[str, str]])

Fetch PyST suggestions for a column name.

fetch_suggestions_sync(→ List[Dict[str, str]])

Synchronous wrapper for fetching suggestions.

generate_view_object(→ Dict[str, Any])

Generate the internal view object with all mappings.

iri_to_web_url(→ str)

Convert an IRI to a vocab.sentier.dev web page URL.

load_excel_data(→ pandas.DataFrame)

Load Excel data into a pandas DataFrame using SmartDataReader.

navigate_to(page)

Navigate to a specific page.

on_sheet_change()

Callback when sheet selection changes. Clears cached data.

render_sidebar_header()

Render the Trailpack branding block in the sidebar.

sanitize_search_query(→ str)

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:
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.

trailpack.ui.streamlit_app.navigate_to(page: int)[source]

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

trailpack.ui.streamlit_app.ICON_PATH[source]
trailpack.ui.streamlit_app.LOGO_BASE64[source]
trailpack.ui.streamlit_app.PAGE_ICON = ''[source]
trailpack.ui.streamlit_app._current_dir[source]
trailpack.ui.streamlit_app._repo_root[source]
trailpack.ui.streamlit_app.change_file[source]
trailpack.ui.streamlit_app.env_path[source]