added some comments; write the up-to-date dataframe
This commit is contained in:
14
stand.py
14
stand.py
@ -29,19 +29,27 @@ df = restapi.data
|
||||
download(df)
|
||||
|
||||
|
||||
# if df in restapi changed, we need to reload it into aggrid.
|
||||
# if df in restapi did not change, we do not reload to ensure changes in the browser persist.
|
||||
|
||||
response = aggrid(
|
||||
df,
|
||||
reload_data=changed
|
||||
)
|
||||
|
||||
|
||||
# if we reloaded, aggrid returns the df from before (why?), thus we do not update the restapi.
|
||||
# if we did not reload, aggrid may return an updated df from an edit in the browser,
|
||||
# and thus we need to update the restapi.
|
||||
|
||||
new_df = response["data"]
|
||||
if not new_df.equals(df) and not changed:
|
||||
restapi.data = new_df
|
||||
restapi.data = df = new_df
|
||||
|
||||
|
||||
if not new_df.empty:
|
||||
new_df.to_hdf("output.h5", key="data")
|
||||
if not df.empty:
|
||||
print("<<< write hdf")
|
||||
df.to_hdf("output.h5", key="data")
|
||||
|
||||
|
||||
print(">>> end of streamlit run")
|
||||
|
Reference in New Issue
Block a user