File size: 782 Bytes
01fa6a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import streamlit as st

def refresh_progress():
    with st.sidebar:
        tot = st.session_state.workflow_fsm.num_states - 1
        cur_i = st.session_state.workflow_fsm.current_state_index
        cur_t = st.session_state.workflow_fsm.current_state
        st.session_state.disp_progress[0].markdown(f"*Progress: {cur_i}/{tot}. Current: {cur_t}.*")
        st.session_state.disp_progress[1].progress(cur_i/tot)
    
def init_workflow_viz():
    # add progress indicator to session_state
    if "progress" not in st.session_state:
        with st.sidebar:
            st.session_state.disp_progress = [st.empty(), st.empty()]
            # add button to sidebar, with the callback to refesh_progress
            st.sidebar.button("Refresh Progress", on_click=refresh_progress)