Spaces:
Runtime error
Runtime error
| from functools import partial | |
| from pathlib import Path | |
| #import kangas as kg | |
| import streamlit as st | |
| import streamlit.components.v1 as components | |
| from datasets import load_dataset | |
| import socket | |
| proj_dir = Path(__file__).parent | |
| hostname = socket.gethostname() | |
| ip_address = socket.gethostbyname(hostname) | |
| servername = 'calebcometml-kangas-demo.hf.space' | |
| src = f"https://{servername}:80/kangas" | |
| st.set_page_config(layout="wide") | |
| st.markdown("1. Select dataset of your choice") | |
| def kangas_fn(dataset_repo): | |
| repo_wo_slash = dataset_repo.replace('/', '__') + '.datagrid' | |
| dg_file_name = repo_wo_slash + '.datagrid' | |
| with st.spinner("Loading Dataset..."): | |
| dataset = load_dataset(dataset_repo, split="train") | |
| with st.spinner("Creating Kangas..."): | |
| dg = kg.DataGrid(dataset) | |
| with st.spinner("Saving Kangas..."): | |
| dg.save(str(proj_dir / 'datagrids' / dg_file_name)) | |
| #kg.show( | |
| # port=7640, | |
| # host=servername, | |
| # protocol="https" | |
| #) | |
| height = st.sidebar.slider("iFrame Height", 200, 1500, 900, 100) | |
| scrolling = st.sidebar.checkbox("iFrame Scrolling") | |
| hf_dataset = st.text_input("HuggingFace Dataset", value='beans') | |
| st.button("Download and Run", on_click=partial(kangas_fn, hf_dataset)) | |
| st.markdown("""Click the dropdown in Kangas to see pre-loaded datasets""") | |
| st.components.v1.iframe(src, None, height, scrolling=True) | |