From 47bd98e791b61c480899d945f8dff986121a649f Mon Sep 17 00:00:00 2001 From: "houhan@gmail.com" Date: Sun, 11 Aug 2024 03:27:27 +0000 Subject: [PATCH 1/2] bug fix --- code/util/streamlit.py | 12 ++++++------ code/util/url_query_helper.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/code/util/streamlit.py b/code/util/streamlit.py index acac0af..2c2035c 100644 --- a/code/util/streamlit.py +++ b/code/util/streamlit.py @@ -697,7 +697,7 @@ def add_auto_train_manager(): st_prefix=cols[0], label="X axis", options=options, - default=options.index(st.session_state["auto_training_history_x_axis"]), + default="date", key="auto_training_history_x_axis", ) @@ -706,7 +706,7 @@ def add_auto_train_manager(): st_prefix=cols[1], label="Sort by", options=options, - default=options.index(st.session_state["auto_training_history_sort_by"]), + default="first_date", key="auto_training_history_sort_by", ) @@ -715,7 +715,7 @@ def add_auto_train_manager(): st_prefix=cols[2], label="Sort order", options=options, - default=options.index(st.session_state["auto_training_history_sort_order"]), + default="descending", key="auto_training_history_sort_order", ) @@ -769,7 +769,7 @@ def add_auto_train_manager(): override_height=fig_auto_train.layout.height * 1.1, override_width=fig_auto_train.layout.width, click_event=True, - select_event=False, + select_event=True, ) with cols[1]: st.markdown('#### 👀 Quick preview') @@ -801,8 +801,8 @@ def add_auto_train_manager(): 'decision', 'next_stage_suggested' ]] - with st.expander('Automatic training manager', expanded=True): - st.dataframe(df_training_manager, height=3000) + # with st.expander('Automatic training manager', expanded=True): + # st.dataframe(df_training_manager, height=3000) @st.cache_data(ttl=3600*24) def _plot_population_x_y(df, x_name='session', y_name='foraging_eff', group_by='h2o', diff --git a/code/util/url_query_helper.py b/code/util/url_query_helper.py index 12d2b76..f2c26d6 100644 --- a/code/util/url_query_helper.py +++ b/code/util/url_query_helper.py @@ -61,7 +61,7 @@ 'auto_training_curriculum_name': 'Uncoupled Baiting', 'auto_training_curriculum_version': '1.0', 'auto_training_curriculum_schema_version': '1.0', - 'auto_training_history_recent_weeks': 4, + 'auto_training_history_recent_weeks': 8, } def checkbox_wrapper_for_url_query(st_prefix, label, key, default, **kwargs): From 24390492ade34f6d47193654c7bc5a6b747127f4 Mon Sep 17 00:00:00 2001 From: "houhan@gmail.com" Date: Sun, 11 Aug 2024 05:16:55 +0000 Subject: [PATCH 2/2] fix a very weird bug where a certain date format of xrange will break plotly returning event --- code/util/plot_autotrain_manager.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/util/plot_autotrain_manager.py b/code/util/plot_autotrain_manager.py index 74d7f2c..bf2ba7a 100644 --- a/code/util/plot_autotrain_manager.py +++ b/code/util/plot_autotrain_manager.py @@ -201,9 +201,10 @@ def plot_manager_all_progress(manager: 'AutoTrainManager', # Limit x range to recent days if x is "date" if x_axis == 'date' and recent_days is not None: - xrange_min = datetime.now() - pd.Timedelta(days=recent_days) - xrange_max = datetime.now() - fig.update_xaxes(range=[xrange_min, xrange_max]) + # xrange_max = pd.Timestamp.today() # For unknown reasons, using this line will break both plotly_events and new st.plotly_chart callback... + xrange_max = pd.to_datetime(df_manager.session_date).max() + pd.Timedelta(days=1) + xrange_min = xrange_max - pd.Timedelta(days=recent_days) + fig.update_layout(xaxis_range=[xrange_min, xrange_max]) # Highight the selected subject for n, subject_id in enumerate(subject_ids):