Spaces:
Runtime error
Runtime error
| """Prepare an error message for gradiobee.""" | |
| # pylint: disable=invalid-name | |
| from typing import Optional, Tuple, Union | |
| import pandas as pd | |
| def error_msg( | |
| msg: Optional[str], | |
| title: str = "error message", | |
| ) -> Tuple[Union[str, None], None, None, None, None, None, None]: | |
| """Prepare an error message for gradiobee outputs.""" | |
| if msg is None: | |
| msg = "none..." | |
| try: | |
| msg = msg.__str__() | |
| except Exception as exc: | |
| msg = str(exc) | |
| df = pd.DataFrame([msg], columns=[title]) | |
| # return df, *((None,) * 4) # pyright complains | |
| # return df, None, None, None, None, None, None, None | |
| return df.to_html(), None, None, None, None, None, None | |