webinterface.streamlit_utils module#

Streamlit utils.

class webinterface.streamlit_utils.StreamlitLogger(placeholder, logger_name=None, accumulate=True, persist=True)[source]#

Bases: object

Pickup logger and write to Streamlit front end.

Parameters:
  • placeholder (streamlit.empty) – Streamlit placeholder object on which to write logs.

  • logger_name (str, optional) – Module name of logger to pick up. Leave to None to pick up root logger.

  • accumulate (bool, optional) – Whether to accumulate log messages or to overwrite with each new message, keeping only the last line (default: True).

  • persist (bool, optional) – Wheter to keep the log when finished, or empty the placeholder element.

webinterface.streamlit_utils.display_error(friendly_message: str, exception: Exception = None, suggestions: list = None, technical_details: str = None)[source]#

Display user-friendly error with expandable technical details.

Parameters:
  • friendly_message (str) – A user-friendly error message to display prominently.

  • exception (Exception, optional) – The exception object to show with Streamlit’s nice traceback formatting.

  • suggestions (list, optional) – List of suggestions to help the user resolve the error.

  • technical_details (str, optional) – Technical error details as string (used if exception is not provided).

webinterface.streamlit_utils.get_error_suggestions(exception: Exception, context: dict) tuple[source]#

Analyze exception and return user-friendly message with suggestions.

Parameters:
  • exception (Exception) – The exception that was raised.

  • context (dict) – Context about the operation, including ‘input_format’ for the selected software tool.

Returns:

A tuple of (friendly_message, suggestions_list).

Return type:

tuple

webinterface.streamlit_utils.hide_streamlit_menu()[source]#

Hide Streamlit menu.

webinterface.streamlit_utils.save_dataframe(df)[source]#

Save dataframe to file object, with streamlit cache.

Parameters:

df (pd.DataFrame) – Dataframe to save.

Returns:

The CSV representation of the dataframe encoded in UTF-8.

Return type:

bytes