Spaces:
Running
Running
File size: 1,361 Bytes
9adc040 30518e3 9adc040 df2ac1c 9adc040 df2ac1c 2ab4866 bd44ff4 9adc040 df2ac1c 9adc040 98f7c42 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
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}/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)
|