Is there a way to see the actual code that was executed with a call to streamlit run app_name.py? Ideally, I’m looking for a history of app_name.py contents each time it was called by streamlit run. Does Streamlit log anything like this?
That’s an interesting question. Streamlit doesn’t currently create logging to that degree, but I suppose that’s a feature that could be built.
One thing you could do is use the python debugger. For example:
import streamlit as st import pandas as pd import trace import sys def main(): points=pd.DataFrame([[50,0.01],[51,0.1],[51.05,1.05]], columns = ["lat","lon"]) st.map(points) # create a Trace object, telling it what to ignore, and whether to # do tracing or line-counting or both. tracer = trace.Trace( ignoredirs=[sys.prefix, sys.exec_prefix], trace=1, count=1) # run the new command using the given tracer tracer.run('main()') # make a report, placing output in the current directory r = tracer.results() r.write_results(show_missing=True, coverdir=".")
In the output of the above you’ll see lines like this:
map_dots.py(8): points=pd.DataFrame([[50,0.01],[51,0.1],[51.05,1.05]], columns = ["lat","lon"]) map_dots.py(9): st.map(points)
With the sample code I posted, it will also show calls to the streamlit module. I believe there’s a way you can configure the tracer to filter out lines from modules you don’t want to see. Let me know if you figure it out.
Thanks for the question!