Skip to content

Commit

Permalink
Merge pull request #75 from AllenNeuralDynamics/han_minor_improvements
Browse files Browse the repository at this point in the history
feat: add pipeline-rerun message
  • Loading branch information
hanhou authored Aug 8, 2024
2 parents b2a5371 + 5a4e929 commit 8b7c54d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 8 additions & 2 deletions code/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ def init():

df = load_data(['sessions'], data_source='bonsai')

if not len(df):
return False

# --- Perform any data source-dependent preprocessing here ---
# Because sync_URL_to_session_state() needs df to be loaded (for dynamic column filtering),
# 'if_load_bpod_sessions' has not been synced from URL to session state yet.
Expand Down Expand Up @@ -447,6 +450,8 @@ def _get_data_source(rig):

# Establish communication between pygwalker and streamlit
init_streamlit_comm()

return True


def app():
Expand Down Expand Up @@ -717,6 +722,7 @@ def app():


if 'df' not in st.session_state or 'sessions_bonsai' not in st.session_state.df.keys():
init()
ok = init()

app()
if ok:
app()
11 changes: 9 additions & 2 deletions code/util/aws_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ def load_data(tables=['sessions'], data_source = 'bonsai'):
df = {}
for table in tables:
file_name = s3_processed_nwb_folder[data_source] + f'df_{table}.pkl'
with fs.open(file_name) as f:
df[table + '_bonsai'] = pd.read_pickle(f)
try:
with fs.open(file_name) as f:
df[table + '_bonsai'] = pd.read_pickle(f)
except FileNotFoundError as e:
st.markdown(f'''### df_{table}.pkl is missing on S3. \n'''
f'''## It is very likely that Han is [rerunning the whole pipeline](https://github.com/AllenNeuralDynamics/aind-foraging-behavior-bonsai-trigger-pipeline?tab=readme-ov-file#notes-on-manually-re-process-all-nwbs-and-overwrite-s3-database-and-thus-the-streamlit-app). Please come back after an hour.''')
st.markdown('')
st.image("https://private-user-images.githubusercontent.com/24734299/356400867-bea2c7a9-c561-4c5f-afa5-92d63c040be6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMxNTYxNDYsIm5iZiI6MTcyMzE1NTg0NiwicGF0aCI6Ii8yNDczNDI5OS8zNTY0MDA4NjctYmVhMmM3YTktYzU2MS00YzVmLWFmYTUtOTJkNjNjMDQwYmU2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODA4VDIyMjQwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM5NDI4YjYzNTNiM2FiMDZlMzMyYmE2NjY5ZGMzNmM4ZTA4MWI4YjUxZGJlMWNlMTM0NGYwMDQ2MjRhNDcwODImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Sb8JeqY1yFnO6DAZLFe4eDd6AYEICaCtFar_CdTT_-Y",
width=500)
return df


Expand Down

0 comments on commit 8b7c54d

Please sign in to comment.