From 4dd9ba3c9e72afb9e09176cbd9abde4336630659 Mon Sep 17 00:00:00 2001 From: Sven Augustin Date: Fri, 27 May 2022 00:54:36 +0200 Subject: [PATCH] added some comments; write the up-to-date dataframe --- stand.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/stand.py b/stand.py index a678e25..4eb5a11 100644 --- a/stand.py +++ b/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")