From 340f435a21cfaf0c59ae334e87d1f6c682fa2132 Mon Sep 17 00:00:00 2001 From: "houhan@gmail.com" Date: Thu, 5 Sep 2024 03:38:56 +0000 Subject: [PATCH 1/2] feat: add footnote --- code/Home.py | 18 ++++++------------ code/__init__.py | 1 + code/pages/2_HMM-GLM.py | 6 +++++- code/pages/4_RL model playground.py | 4 ++++ code/util/streamlit.py | 8 ++++++++ 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/code/Home.py b/code/Home.py index def5692..26072ec 100644 --- a/code/Home.py +++ b/code/Home.py @@ -12,8 +12,6 @@ """ -__ver__ = 'v2.5.3' - import os import extra_streamlit_components as stx @@ -36,7 +34,8 @@ add_dot_property_mapper, add_session_filter, add_xy_selector, add_xy_setting, aggrid_interactive_table_curriculum, - aggrid_interactive_table_session, data_selector) + aggrid_interactive_table_session, data_selector, + add_footnote) from util.url_query_helper import (checkbox_wrapper_for_url_query, multiselect_wrapper_for_url_query, number_input_wrapper_for_url_query, @@ -49,8 +48,8 @@ page_title='Foraging behavior browser', page_icon=':mouse2:', menu_items={ - 'Report a bug': "https://github.com/hanhou/foraging-behavior-browser/issues", - 'About': "Github repo: https://github.com/hanhou/foraging-behavior-browser/" + 'Report a bug': "https://github.com/AllenNeuralDynamics/foraging-behavior-browser/issues", + 'About': "Github repo: https://github.com/AllenNeuralDynamics/foraging-behavior-browser" } ) except: @@ -507,19 +506,14 @@ def app(): add_session_filter(if_bonsai=True, url_query=url_query) data_selector() - - st.markdown('---') - st.markdown(f'#### Han Hou @ 2024 {__ver__}') - st.markdown('[bug report / feature request](https://github.com/AllenNeuralDynamics/foraging-behavior-browser/issues)') + add_footnote() with st.expander('Debug', expanded=False): - if st.button('Reload data from AWS S3'): + if st.button('Clear session state and reload data'): st.cache_data.clear() init() st.rerun() - - with st.container(): # col1, col2 = st.columns([1.5, 1], gap='small') # with col1: diff --git a/code/__init__.py b/code/__init__.py index e69de29..eb9cb3d 100644 --- a/code/__init__.py +++ b/code/__init__.py @@ -0,0 +1 @@ +__ver__ = 'v2.5.4' diff --git a/code/pages/2_HMM-GLM.py b/code/pages/2_HMM-GLM.py index 9cfd5ed..e1b9186 100644 --- a/code/pages/2_HMM-GLM.py +++ b/code/pages/2_HMM-GLM.py @@ -11,6 +11,8 @@ import streamlit_nested_layout from PIL import Image +from util.streamlit import add_footnote + try: st.set_page_config(layout="wide", page_title='Foraging behavior browser', @@ -65,7 +67,9 @@ def app(): if st.button('Reload data from S3'): st.cache_data.clear() st.rerun() - + + add_footnote() + data_folder_selected = widget_data_folder.selectbox('Select Data Folder', data_folders) if data_folder_selected: diff --git a/code/pages/4_RL model playground.py b/code/pages/4_RL model playground.py index bf8196f..9926d3d 100644 --- a/code/pages/4_RL model playground.py +++ b/code/pages/4_RL model playground.py @@ -13,6 +13,9 @@ from aind_dynamic_foraging_models.generative_model.params.util import get_params_options from aind_dynamic_foraging_basic_analysis import compute_foraging_efficiency +from util.streamlit import add_footnote + + try: st.set_page_config(layout="wide", page_title='Foraging behavior browser', @@ -162,6 +165,7 @@ def app(): with st.sidebar: seed = st.number_input("Random seed", value=42) + add_footnote() st.title("RL model playground") diff --git a/code/util/streamlit.py b/code/util/streamlit.py index e4991a6..47bb8ad 100644 --- a/code/util/streamlit.py +++ b/code/util/streamlit.py @@ -2,6 +2,8 @@ from collections import OrderedDict from datetime import datetime +from __init__ import __ver__ + import matplotlib.pyplot as plt import numpy as np import pandas as pd @@ -1110,3 +1112,9 @@ def _add_agg(df_this, x_name, y_name, group, aggr_method, if_use_x_quantile, q_q title_standoff=40, ticks = "outside", tickcolor='black', ticklen=10, tickwidth=2, ticksuffix=' ') return fig + + +def add_footnote(): + st.markdown('---') + st.markdown(f'#### Han Hou @ 2024 {__ver__}') + st.markdown('[bug report / feature request](https://github.com/AllenNeuralDynamics/foraging-behavior-browser/issues)') \ No newline at end of file From 003582ee8b7bc3dbffccb118ce4fdf4a3b8774e4 Mon Sep 17 00:00:00 2001 From: "houhan@gmail.com" Date: Thu, 5 Sep 2024 03:39:07 +0000 Subject: [PATCH 2/2] fix: option.index(default) --- code/util/url_query_helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/util/url_query_helper.py b/code/util/url_query_helper.py index 55be10b..e1fa419 100644 --- a/code/util/url_query_helper.py +++ b/code/util/url_query_helper.py @@ -81,7 +81,7 @@ def selectbox_wrapper_for_url_query(st_prefix, label, options, key, default, **k if key in st.session_state else options.index(st.query_params[key]) if key in st.query_params - else default + else options.index(default) ), key=key, **kwargs,