diff --git a/code/Home.py b/code/Home.py index 079d0eb..b5a31bd 100644 --- a/code/Home.py +++ b/code/Home.py @@ -13,13 +13,14 @@ import plotly.graph_objects as go from scipy.stats import linregress import statsmodels.api as sm +import json from PIL import Image, ImageColor import streamlit.components.v1 as components import streamlit_nested_layout from streamlit_plotly_events import plotly_events -from util.streamlit import filter_dataframe, aggrid_interactive_table_session, add_session_filter, data_selector, add_caution +from util.streamlit import filter_dataframe, aggrid_interactive_table_session, add_session_filter, data_selector import extra_streamlit_components as stx if_profile = False @@ -61,6 +62,30 @@ if 'selected_points' not in st.session_state: st.session_state['selected_points'] = [] + +def _get_urls(): + cache_folder = 'aind-behavior-data/Han/ephys/report/st_cache/' + cache_session_level_fig_folder = 'aind-behavior-data/Han/ephys/report/all_sessions/' + cache_mouse_level_fig_folder = 'aind-behavior-data/Han/ephys/report/all_subjects/' + + fs = s3fs.S3FileSystem(anon=False) + + with fs.open('aind-behavior-data/Han/streamlit_CO_url.json', 'r') as f: + data = json.load(f) + + return data['behavior'], data['ephys'] + +def add_caution(): + behavior_url, ephys_url = _get_urls() + st.markdown('### ***:blue[❗️Caution: Due to bugs and resource limitations of the Streamlit public cloud, the app you are currently viewing may be unstable and buggy 🐞. ' + f'It is recommended that you switch to [the one in Code Ocean]({behavior_url}) instead. ' + 'However, you will need to log in to Code Ocean first. Please contact David if you have any questions. ' + f'See also [the ephys browser in Code Ocean]({ephys_url}) ' + '(recommended) and [the one on the public cloud](https://foraging-ephys-browser.streamlit.app/)]***') + + st.markdown('---') + + @st.cache_data(ttl=24*3600) def load_data(tables=['sessions']): diff --git "a/code/pages/1_\360\237\222\241Population analysis.py" "b/code/pages/1_\360\237\222\241Population analysis.py" index b41a0e8..614bd8d 100644 --- "a/code/pages/1_\360\237\222\241Population analysis.py" +++ "b/code/pages/1_\360\237\222\241Population analysis.py" @@ -5,9 +5,10 @@ import numpy as np from io import BytesIO -from util.streamlit import filter_dataframe, aggrid_interactive_table_session, add_session_filter, data_selector, add_caution +from util.streamlit import filter_dataframe, aggrid_interactive_table_session, add_session_filter, data_selector from util.population import _draw_variable_trial_back, _draw_variable_trial_back_linear_reg import seaborn as sns +from Home import add_caution try: diff --git "a/code/pages/2_\360\237\216\254Video browser.py" "b/code/pages/2_\360\237\216\254Video browser.py" index 46d3ced..4bd9f0a 100644 --- "a/code/pages/2_\360\237\216\254Video browser.py" +++ "b/code/pages/2_\360\237\216\254Video browser.py" @@ -9,7 +9,8 @@ import plotly.graph_objs as go from plotly.subplots import make_subplots -from util.streamlit import filter_dataframe, aggrid_interactive_table_session, add_session_filter, data_selector, add_caution +from util.streamlit import filter_dataframe, aggrid_interactive_table_session, add_session_filter, data_selector +from Home import add_caution from streamlit_plotly_events import plotly_events from util.population import _draw_variable_trial_back, _draw_variable_trial_back_linear_reg import seaborn as sns diff --git "a/code/pages/3_\360\237\214\263Bonsai.py" "b/code/pages/3_\360\237\214\263Bonsai.py" index a548b4a..46700ec 100644 --- "a/code/pages/3_\360\237\214\263Bonsai.py" +++ "b/code/pages/3_\360\237\214\263Bonsai.py" @@ -20,7 +20,8 @@ import streamlit_nested_layout from streamlit_plotly_events import plotly_events -from util.streamlit import filter_dataframe, aggrid_interactive_table_session, add_session_filter, data_selector, add_caution +from util.streamlit import filter_dataframe, aggrid_interactive_table_session, add_session_filter, data_selector +from Home import add_caution import extra_streamlit_components as stx diff --git a/code/util/streamlit.py b/code/util/streamlit.py index dcbbd35..2b2ddbe 100644 --- a/code/util/streamlit.py +++ b/code/util/streamlit.py @@ -34,16 +34,6 @@ "padding": "4px !important"}, } -def add_caution(): - st.markdown('### ***:blue[❗️Caution: Due to bugs and resource limitations of the Streamlit public cloud, the app you are currently viewing may be unstable and buggy 🐞. ' - 'It is recommended that you switch to [the one in Code Ocean](https://codeocean.allenneuraldynamics.org/cw/cb1da92b-9a59-43ed-a609-65eb08119d36/proxy/8501/) instead. ' - 'However, you will need to log in to Code Ocean first. Please contact David if you have any questions. ' - 'See also [the ephys browser in Code Ocean](https://codeocean.allenneuraldynamics.org/cw/4617f5e4-c7ef-43f2-bcda-703d052e1b20/proxy/8501/) ' - '(recommended) and [the one on the public cloud](https://foraging-ephys-browser.streamlit.app/)]***') - - st.markdown('---') - - def aggrid_interactive_table_session(df: pd.DataFrame): """Creates an st-aggrid interactive table based on a dataframe.