Im running a local app of streamlit connected to aws.
I’m having a unexpectedly behavior related to fragment function.
This is my code:
@st.fragment(run_every=5)
def show_monitor(cluster_name: str) -> None:
df = get_task_df(cluster_name)
if not df.empty:
st.dataframe(
df.replace(
{'PROVISIONING':'INICIANDO',
'PENDING':'ESPERANDO',
'RUNNING':'TRANSCRIBIENDO',
'STOPPED':'FINALIZADA'}
),
use_container_width=True,
selection_mode='single-row',
on_select='rerun',
hide_index=True,
key='selected_row'
)
if st.session_state.selected_row['selection']['rows']:
st.write(st.session_state.selected_row)
selected_task_id = df.loc[st.session_state.selected_row['selection']['rows'][0], 'Task ID']
st.write(f"Has seleccionado la task: `{selected_task_id}`")
stop_task_button = st.button('Detener tarea')
if stop_task_button:
try:
stop_task(cluster_name, selected_task_id, reason=f"Detencion manual por: {st.session_state.display_name}")
st.success(f"Se ha detenido con éxito la task: `{selected_task_id}`")
except:
st.warning(f"Ha ocurrido un error al detener la task: `{selected_task_id}`")
show_monitor(CLUSTER_NAME)
The issue occurs when I try to select a row; the app doesn’t display the selection, and I’m not sure why. Occasionally, if I repeatedly try to select the row, the selection does appear, but it’s inconsistent