Checklist
Summary
When using the newly introduced option to provide a callable as data argument, the callable runs without ScriptRunContext.
Reproducible Code Example
# app.py
import csv
import io
import streamlit as st
def to_csv() -> str:
foo = st.session_state.get("foo", "nope")
print(foo)
buffer = io.StringIO()
writer = csv.writer(buffer)
writer.writerow([foo])
buffer.seek(0)
return buffer.getvalue()
st.download_button(
label="Download",
data=to_csv,
file_name="foo.csv",
mime="text/csv",
)
st.session_state["foo"] = "bar"
Steps To Reproduce
streamlit run app.py
- Click the button
Raises Thread 'asyncio_0': missing ScriptRunContext! This warning can be ignored when running in bare mode.
Expected Behavior
When called from the download_button, the function to_csv should have context, and see the currenct session_state.
Current Behavior
Warning
Thread 'asyncio_0': missing ScriptRunContext! This warning can be ignored when running in bare mode.
Is this a regression?
Debug info
- Streamlit version: 1.52.2
- Python version: 3.13
- Operating System: Win
- Browser: Chrome
Checklist
Summary
When using the newly introduced option to provide a callable as data argument, the callable runs without ScriptRunContext.
Reproducible Code Example
Steps To Reproduce
streamlit run app.pyRaises Thread 'asyncio_0': missing ScriptRunContext! This warning can be ignored when running in bare mode.
Expected Behavior
When called from the download_button, the function
to_csvshould have context, and see the currenctsession_state.Current Behavior
Warning
Is this a regression?
Debug info