trailpack.ui.streamlit_app ========================== .. py:module:: trailpack.ui.streamlit_app .. autoapi-nested-parse:: Streamlit UI application for trailpack - Excel to PyST mapper. Attributes ---------- .. autoapisummary:: trailpack.ui.streamlit_app.ICON_PATH trailpack.ui.streamlit_app.LOGO_BASE64 trailpack.ui.streamlit_app.PAGE_ICON trailpack.ui.streamlit_app._current_dir trailpack.ui.streamlit_app._repo_root trailpack.ui.streamlit_app.change_file trailpack.ui.streamlit_app.env_path Functions --------- .. autoapisummary:: trailpack.ui.streamlit_app.clear_column_cache_entries trailpack.ui.streamlit_app.extract_first_word trailpack.ui.streamlit_app.fetch_concept_async trailpack.ui.streamlit_app.fetch_concept_sync trailpack.ui.streamlit_app.fetch_suggestions_async trailpack.ui.streamlit_app.fetch_suggestions_sync trailpack.ui.streamlit_app.generate_view_object trailpack.ui.streamlit_app.iri_to_web_url trailpack.ui.streamlit_app.load_excel_data trailpack.ui.streamlit_app.navigate_to trailpack.ui.streamlit_app.on_sheet_change trailpack.ui.streamlit_app.render_sidebar_header trailpack.ui.streamlit_app.sanitize_search_query Module Contents --------------- .. py:function:: clear_column_cache_entries(column: str, prefix: str = '') -> None Clear all cache entries for a column from suggestions cache. :param column: Column name to clear cache for :param prefix: Optional prefix to append (e.g., "unit_" for unit caches) .. py:function:: extract_first_word(query: str) -> str 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. :param query: The input string :returns: The first word (substring up to first space), or empty string if input is empty .. py:function:: fetch_concept_async(iri: str, language: str) -> Optional[str] :async: Fetch concept definition from PyST API. .. py:function:: fetch_concept_sync(iri: str, language: str) -> Optional[str] Synchronous wrapper for fetching concept definition. Handles event loop management for Streamlit compatibility. .. py:function:: fetch_suggestions_async(column_name: str, language: str) -> List[Dict[str, str]] :async: Fetch PyST suggestions for a column name. .. py:function:: fetch_suggestions_sync(column_name: str, language: str) -> List[Dict[str, str]] 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. .. py:function:: generate_view_object() -> Dict[str, Any] Generate the internal view object with all mappings. .. py:function:: iri_to_web_url(iri: str, language: str = 'en') -> str Convert an IRI to a vocab.sentier.dev web page URL. :param iri: The IRI (e.g., "https://vocab.sentier.dev/Geonames/A") :param language: Language code (default: "en") :returns: //vocab.sentier.dev/web/concept/...?concept_scheme=...&language=en") :rtype: Web page URL (e.g., "https .. rubric:: 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' .. py:function:: load_excel_data(sheet_name: str) -> pandas.DataFrame Load Excel data into a pandas DataFrame using SmartDataReader. .. py:function:: navigate_to(page: int) Navigate to a specific page. .. py:function:: on_sheet_change() Callback when sheet selection changes. Clears cached data. .. py:function:: render_sidebar_header() Render the Trailpack branding block in the sidebar. .. py:function:: sanitize_search_query(query: str) -> str 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. :param query: The original search query string :returns: Sanitized query string safe for API calls .. py:data:: ICON_PATH .. py:data:: LOGO_BASE64 .. py:data:: PAGE_ICON :value: '' .. py:data:: _current_dir .. py:data:: _repo_root .. py:data:: change_file .. py:data:: env_path