Spaces:
Runtime error
Runtime error
Download models/__init__.py from Archon/streamlit-parent: direct link, hf CLI and curl.
- Browser
- Download file 1.85 kB
-
https://huggingface.co/spaces/Archon/streamlit-parent/resolve/main/models/__init__.py
- Command line
-
hf download hf://spaces/Archon/streamlit-parent/models/__init__.py
-
curl -L -o __init__.py https://huggingface.co/spaces/Archon/streamlit-parent/resolve/main/models/__init__.py
1.85 kB
| from abc import abstractmethod | |
| from typing import Optional | |
| import streamlit as st | |
| from sqlalchemy import String, Date, Integer, Double | |
| from sqlalchemy.orm.attributes import InstrumentedAttribute | |
| class StreamlitHelper: | |
| def get_column_configurations(cls): | |
| config = {} | |
| for k in cls.__dict__: | |
| v = cls.__dict__[k] | |
| if isinstance(v, InstrumentedAttribute): | |
| config.update(cls._get_column_configuration(v)) | |
| return config | |
| def _get_column_configuration(cls, column): | |
| pre_conf = cls._get_column_configuration0(column) | |
| if pre_conf and len(pre_conf) > 0: | |
| return pre_conf | |
| comment: str = column.comment | |
| disabled = True | |
| if comment and "可修改" in comment: | |
| disabled = False | |
| if isinstance(column.type, String): | |
| return { | |
| column.name: st.column_config.TextColumn( | |
| disabled=disabled, help=comment | |
| ) | |
| } | |
| elif isinstance(column.type, Integer) or isinstance(column.type, Double): | |
| return { | |
| column.name: st.column_config.NumberColumn( | |
| disabled=disabled, help=comment | |
| ) | |
| } | |
| elif isinstance(column.type, Date): | |
| return { | |
| column.name: st.column_config.DateColumn( | |
| disabled=disabled, help=comment | |
| ) | |
| } | |
| else: | |
| return { | |
| column.name: st.column_config.TextColumn( | |
| disabled=disabled, help=comment | |
| ) | |
| } | |
| def _get_column_configuration0(cls, column) -> Optional[dict]: | |
| pass | |