Currently Cognite’s Streamlit apps have issues with for example:
with st.spinner('Wait for it...'):
time.sleep(5)
st.success('Done!')
The code itself should wait 5 seconds before writing out Done!, but is executed instantly.
Another example is when you try to make your application responsive while waiting for some data to arrive from a remote location. For example, when you want to print out a wait message for the user because sometimes it takes some seconds to load the data, but the app doesn't work as intended. In the following example I am trying to print out a message while waiting for the function to finish, but it fails:
call_func_button = st.button("Call function with current parameters", key="button_func_call")
if call_func_button:
func_call = example_function.call(data=input_data, wait=False)
st.info("Waiting for function...")
while func_call.status == "Running":
func_call.update()
if func_call.status == "Failed":
st.error("Function failed to run!")
elif func_call.status == "Completed":
runtime = float(func_call.end_time - func_call.start_time) / 1000.0
st.success(f"Function ran successfully in {runtime} seconds!")
The line "Waiting for function..." does not appear during execution, but instead appears when the function completes.
I believe the problem lies with the threading of Streamlit and potentially some config update could change this behavior.
Thank you,
Tibor Váncza