Spaces:
Runtime error
Runtime error
File size: 1,423 Bytes
f4f6aba 564d114 dd68837 31a1df6 dd68837 31a1df6 4c1bb6f dd68837 564d114 dd68837 31a1df6 dd68837 31a1df6 4c1bb6f dd68837 31a1df6 dd68837 |
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 45 46 47 48 49 50 51 52 53 54 55 56 |
"""The app.py used with streamlit
This ties together the different parts of the app.
"""
import os
import shutil
from pathlib import Path
from tempfile import mkdtemp
from typing import Literal
import streamlit as st
from create import create_repo_input_form
from edit import edit_input_form
from gethelp import help_page
from start import start_input_form
# Change cwd to a temporary path
if "work_dir" not in st.session_state:
work_dir = Path(mkdtemp(prefix="skops-"))
shutil.copy2("cat.png", work_dir / "cat.png")
os.chdir(work_dir)
st.session_state.work_dir = work_dir
# Create a hf_path, which is where the repo will be created locally. When the
# session is created, copy the dummy cat.png file there and make it the cwd
if "hf_path" not in st.session_state:
hf_path = Path(mkdtemp(prefix="skops-"))
st.session_state.hf_path = hf_path
st.header("Skops model card creator")
class Screen:
state: Literal["start", "edit", "create_repo"] = "start"
if "screen" not in st.session_state:
st.session_state.screen: Screen = Screen()
if st.session_state.screen.state == "start":
start_input_form()
elif st.session_state.screen.state == "help":
help_page()
elif st.session_state.screen.state == "edit":
edit_input_form()
elif st.session_state.screen.state == "create_repo":
create_repo_input_form()
else:
st.write("Something went wrong, please open an issue")
|