added some comments; write the up-to-date dataframe

This commit is contained in:
2022-05-27 00:54:36 +02:00
parent dfb0c2c586
commit 4dd9ba3c9e

View File

@ -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")