Spaces:
Build error
Build error
rmm commited on
Commit ·
06a0df9
1
Parent(s): 774a646
chore: cleanup variable names and add docstrings
Browse filesFiles changed (3)
392 unmodified lines393394395396397398399392 unmodified linesst.session_state.container_metadata_inputs = container_metadata_inputsdef dbg_show_observation_hashes():"""Displays information about each observation including the hash392 unmodified lines393394395396397398399392 unmodified linesst.session_state.container_metadata_inputs = container_metadata_inputsdef dbg_show_observation_hashes() -> None:"""Displays information about each observation including the hash
23 unmodified lines2425262728293086 unmodified lines117118119120121122123141 unmodified lines265266267268269270271101 unmodified lines37337437537637737837923 unmodified linesfrom maps.obs_map import present_obs_mapfrom utils.st_logs import setup_logging, parse_log_bufferfrom utils.workflow_state import WorkflowFSM, FSM_STATESfrom utils.workflow_ui import refresh_progress, init_workflow_vizfrom hf_push_observations import push_all_observationsfrom classifier.classifier_image import cetacean_just_classify, cetacean_show_results_and_review, cetacean_show_results86 unmodified linesst.session_state.tab_log = tab_log# put this early so the progress indicator is at the top (also refreshed at end)refresh_progress()# create a sidebar, and parse all the input (returned as `observations` object)with st.sidebar:141 unmodified lines# trigger a refresh too (refreshhing the prog indicator means the script reruns and# we can enter the next state - visualising the results / review)# ok it doesn't if done programmatically. maybe interacting with teh button? check docs.refresh_progress()#TODO: validate this doesn't harm performance adversely.st.rerun()101 unmodified lines# after all other processing, we can show the stage/staterefresh_progress()if __name__ == "__main__":23 unmodified lines2425262728293086 unmodified lines117118119120121122123141 unmodified lines265266267268269270271101 unmodified lines37337437537637737837923 unmodified linesfrom maps.obs_map import present_obs_mapfrom utils.st_logs import setup_logging, parse_log_bufferfrom utils.workflow_state import WorkflowFSM, FSM_STATESfrom utils.workflow_ui import refresh_progress_display, init_workflow_vizfrom hf_push_observations import push_all_observationsfrom classifier.classifier_image import cetacean_just_classify, cetacean_show_results_and_review, cetacean_show_results86 unmodified linesst.session_state.tab_log = tab_log# put this early so the progress indicator is at the top (also refreshed at end)refresh_progress_display()# create a sidebar, and parse all the input (returned as `observations` object)with st.sidebar:141 unmodified lines# trigger a refresh too (refreshhing the prog indicator means the script reruns and# we can enter the next state - visualising the results / review)# ok it doesn't if done programmatically. maybe interacting with teh button? check docs.refresh_progress_display()#TODO: validate this doesn't harm performance adversely.st.rerun()101 unmodified lines# after all other processing, we can show the stage/staterefresh_progress_display()if __name__ == "__main__":
123456789101112131415161718import streamlit as stdef refresh_progress():with st.sidebar:tot = st.session_state.workflow_fsm.num_states - 1cur_i = st.session_state.workflow_fsm.current_state_indexcur_t = st.session_state.workflow_fsm.current_statest.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_stateif "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_progressst.sidebar.button("Refresh Progress", on_click=refresh_progress)1234567891011121314151617181920212223242526272829303132333435363738394041import streamlit as stdef refresh_progress_display() -> None:"""Updates the workflow progress display in the Streamlit sidebar."""with st.sidebar:num_states = st.session_state.workflow_fsm.num_states - 1current_state_index = st.session_state.workflow_fsm.current_state_indexcurrent_state_name = st.session_state.workflow_fsm.current_statecolour = 'primary'if current_state_index == num_states: # highlight that we finishedcolour = 'green'status = f":{colour}[*Progress: {current_state_index}/{num_states}. Current: {current_state_name}.*]"st.session_state.disp_progress[0].markdown(status)st.session_state.disp_progress[1].progress(current_state_index/num_states)def init_workflow_viz(debug:bool=True) -> None:"""Set up the streamlit elements for visualising the workflow progress.Adds placeholders for progress indicators, and adds a button to manually refreshthe displayed progress. Note: The button is mainly a development aid.Args:debug (bool): If True, include the manual refresh button. Default is True."""#Initialise the layout containers used in the input handling# add progress indicator to session_stateif "progress" not in st.session_state:with st.sidebar:st.session_state.disp_progress = [st.empty(), st.empty()]if debug:# add button to sidebar, with the callback to refesh_progressst.sidebar.button("Refresh Progress", on_click=refresh_progress_display)
src/input/input_handling.py+1-1
src/main.py+4-4
src/utils/workflow_ui.py+32-9