Spaces:
Running
Running
File size: 1,419 Bytes
cb5b71d dc92053 cb5b71d 6a31b9a cb5b71d dc92053 6a31b9a dc92053 cb5b71d 6a31b9a |
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 |
import streamlit as st
from core.past_projects import open_project
from core.query_params import get_project_timestamp
from core.state import CurrentProject
from core.state import Metadata
from core.state import OpenTab
from core.state import SelectedRecordSet
from core.state import SelectedResource
import mlcroissant as mlc
def needed_field(text: str) -> str:
return f"{text}:red[*]"
def init_state(force=False):
"""Initializes the session state. `force=True` to force re-initializing it."""
timestamp = get_project_timestamp()
if CurrentProject not in st.session_state or force:
if timestamp:
project = CurrentProject.from_timestamp(timestamp)
if project:
st.session_state[CurrentProject] = project
st.session_state[Metadata] = open_project(project.path)
else:
st.session_state[CurrentProject] = None
if Metadata not in st.session_state or force:
st.session_state[Metadata] = Metadata()
if mlc.Dataset not in st.session_state or force:
st.session_state[mlc.Dataset] = None
if SelectedResource not in st.session_state or force:
st.session_state[SelectedResource] = None
if SelectedResource not in st.session_state or force:
st.session_state[SelectedRecordSet] = None
if OpenTab not in st.session_state or force:
st.session_state[OpenTab] = None
|