Skip to content

Commit 55e9403

Browse files
committed
fix: update session loading parameter to filter sessions older than 6 months
1 parent d35dc21 commit 55e9403

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

code/Home.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ def show_curriculums():
302302

303303

304304
# ------- Layout starts here -------- #
305-
def init(if_load_bpod_data_override=None, if_load_docDB_override=None, if_load_sessions_older_than_one_year_override=None):
305+
def init(if_load_bpod_data_override=None, if_load_docDB_override=None, if_load_sessions_older_than_6_month_override=None):
306306

307307
# Clear specific session state and all filters
308308
for key in st.session_state:
@@ -319,16 +319,25 @@ def init(if_load_bpod_data_override=None, if_load_docDB_override=None, if_load_s
319319
if 'if_load_bpod_sessions' in st.session_state
320320
else False)
321321
st.session_state.bpod_loaded = _if_load_bpod
322-
323-
_if_load_sessions_older_than_one_year = if_load_bpod_data_override if if_load_sessions_older_than_one_year_override is not None else (
324-
st.query_params['if_load_sessions_older_than_one_year'].lower() == 'true'
325-
if 'if_load_sessions_older_than_one_year' in st.query_params
326-
else st.session_state.if_load_sessions_older_than_one_year
327-
if 'if_load_sessions_older_than_one_year' in st.session_state
328-
else False)
329-
322+
323+
_if_load_sessions_older_than_6_month = (
324+
if_load_sessions_older_than_6_month_override
325+
if if_load_sessions_older_than_6_month_override is not None
326+
else (
327+
st.query_params["if_load_sessions_older_than_6_month"].lower() == "true"
328+
if "if_load_sessions_older_than_6_month" in st.query_params
329+
else (
330+
st.session_state.if_load_sessions_older_than_6_month
331+
if "if_load_sessions_older_than_6_month" in st.session_state
332+
else False
333+
)
334+
)
335+
)
336+
330337
# --- Load data using aind-analysis-arch-result-access ---
331-
df_han = get_session_table(if_load_bpod=_if_load_bpod, if_load_sessions_older_than_one_year=_if_load_sessions_older_than_one_year_override)
338+
# Convert boolean to months: if True, load all sessions (None), if False, load only recent 6 months
339+
only_recent_n_month = None if _if_load_sessions_older_than_6_month else 6
340+
df_han = get_session_table(if_load_bpod=_if_load_bpod, only_recent_n_month=only_recent_n_month)
332341
df = {'sessions_main': df_han} # put it in df['session_main'] for backward compatibility
333342

334343
if not len(df):
@@ -346,7 +355,6 @@ def init(if_load_bpod_data_override=None, if_load_docDB_override=None, if_load_s
346355
# Some ad-hoc modifications on df_sessions
347356
_df = st.session_state.df['sessions_main'].copy()
348357

349-
350358
# -- overwrite the `if_stage_overriden_by_trainer`
351359
# Previously it was set to True if the trainer changes stage during a session.
352360
# But it is more informative to define it as whether the trainer has overridden the curriculum.
@@ -460,10 +468,10 @@ def app():
460468

461469
with cols[1]:
462470
with st.form(key='load_settings', clear_on_submit=False):
463-
if_load_sessions_older_than_one_year = checkbox_wrapper_for_url_query(
471+
if_load_sessions_older_than_6_month = checkbox_wrapper_for_url_query(
464472
st_prefix=st,
465-
label='Include sessions older than one year (reload after change)',
466-
key='if_load_sessions_older_than_one_year',
473+
label='Include sessions older than 6 months (reload after change)',
474+
key='if_load_sessions_older_than_6_month',
467475
default=False,
468476
)
469477
if_load_bpod_sessions = checkbox_wrapper_for_url_query(
@@ -709,4 +717,4 @@ def add_main_tabs():
709717
st.markdown('#### 1. Reload the page')
710718
st.markdown('#### 2. Click this original URL https://foraging-behavior-browser.allenneuraldynamics-test.org/')
711719
st.markdown('#### 3. Report your bug here: https://github.com/AllenNeuralDynamics/foraging-behavior-browser/issues (paste your URL and screenshoots)')
712-
raise e
720+
raise e

code/pages/0_Data inventory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,6 @@ def add_venn_diagrms(df_merged):
559559
# Share the same master df as the Home page
560560
if "df" not in st.session_state or "sessions_main" not in st.session_state.df.keys() or not st.session_state.bpod_loaded:
561561
st.spinner("Loading data from Han temp pipeline...")
562-
init(if_load_docDB_override=False, if_load_bpod_data_override=True, if_load_sessions_older_than_one_year_override=True)
562+
init(if_load_docDB_override=False, if_load_bpod_data_override=True, if_load_sessions_older_than_6_month_override=True)
563563

564564
app()

0 commit comments

Comments
 (0)