Skip to content

Commit

Permalink
don't load docDB by default
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhou committed Dec 24, 2024
1 parent 9ea3e81 commit f1bfdc7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
18 changes: 16 additions & 2 deletions code/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def show_curriculums():
pass

# ------- Layout starts here -------- #
def init(if_load_docDB=True):
def init(if_load_docDB_override=None):

# Clear specific session state and all filters
for key in st.session_state:
Expand Down Expand Up @@ -454,7 +454,14 @@ def _get_data_source(rig):


# --- Load data from docDB ---
if if_load_docDB:
if_load_docDb = if_load_docDB_override if if_load_docDB_override is not None else (
st.query_params['if_load_docDB'].lower() == 'true'
if 'if_load_docDB' in st.query_params
else st.session_state.if_load_docDB
if 'if_load_docDB' in st.session_state
else False)

if if_load_docDb:
_df = merge_in_df_docDB(_df)

# add docDB_status column
Expand Down Expand Up @@ -536,6 +543,13 @@ def app():
key='if_load_bpod_sessions',
default=False,
)

if_load_docDB = checkbox_wrapper_for_url_query(
st_prefix=cols[2],
label='Load metadata from docDB (reload after change)',
key='if_load_docDB',
default=False,
)

with cols[1]:
if st.button(' Reload data ', type='primary'):
Expand Down
2 changes: 1 addition & 1 deletion code/pages/1_Basic behavior analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,6 @@ def _plot_histograms(df, column, bins, use_kernel_smooth, use_density):
return fig

if "df" not in st.session_state or "sessions_bonsai" not in st.session_state.df.keys():
init(if_load_docDB=False)
init(if_load_docDB_override=False)

app()
1 change: 1 addition & 0 deletions code/util/url_query_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# Note: When creating the widget, add argument "value"/"index" as well as "key" for all widgets you want to sync with URL
to_sync_with_url_query_default = {
"if_load_bpod_sessions": False,
"if_load_docDB": False,
"to_filter_columns": [
"subject_id",
"task",
Expand Down

0 comments on commit f1bfdc7

Please sign in to comment.