Batch mode?

So, not a web developer, here…more of a command-line-oriented kind-of-program developer; hence, the reason to look into a pure-python web-development framework.

I am used to
program < input > output

Reading the documentation, I have a couple of questions along the above matter…command line execution.

Right off the bat, the documentation says:
“Working with Streamlit is simple. First you sprinkle a few Streamlit commands into a normal Python script, then you run it with streamlit run:”


Question #1.-
After sprinkling Streamlit dust onto my original Python script, do I continue to have the ability of running my script from beginning to end from the command line? say, batch mode?

Question #2.-
Same as question #1, but in the case of a multi-page application.

The reason for my questions is that we may want to include the app into some kind of optmization loop, either by itself or as part of some multi-disciplinary thing, etc.

Can explain in detail what is batch mode?

Can you give a minimal code of what you are trying to achieve, so we can experiment with it.

Most streamlit functions won’t work without streamlit.

Well, I don’t have any script at this time, just “thinking ahead” and trying to figure out whether my imaginary scripts will lose their scripting abilities and become scripts that require user interaction through the web.

In other words, I am asking if visiting the web page is a must or whether my program can continue to run, gracefully terminate and whether I can get my prompt back.

To be sure, Streamlit documentation indicates that I can at least continue to pass arguments to my script:

When passing your script some custom arguments, they must be passed after two dashes. Otherwise the arguments get interpreted as arguments to Streamlit itself.

streamlit run [-- script args]

So, it is not that am planning on executing my script “without” streamlit, I just want to have the option of running it from the command line, with a file as a command line argument, run to completion, terminate and return so that I can then go get the results.

Presumably, the input file command line argument would provide all necessary inputs.

For example, let’s say my script detects the command line argument, reads the file and populates input values; in that case, I could write something like:

if not desk_height:
    desk_height = st.number_input('Input desk height')

Would that do?
Would that allow my script to continue to run?
If and when I get to the end of my script, how would I go about truly terminating the program and actually return the prompt?

Yeah, I can imagine that. But, it is not like I am planning on running the script “without” Streamlit…whatever that means.

But, now that you mention it, I was wondering what it means when in the documentation, they say things like:

Streamlit will not run any statements after st.stop(). We recommend rendering a message to explain why the script has stopped. When run outside of Streamlit, this will raise an Exception.

It means just what it says. If in doubt, just try.

In order to run your script non-interactively and return to the command prompt you need to run it “outside streamlit”. But that is fine if you arrange your code as you explain in the former post (the program can get all the user input from the cli parameters without invoking the GUI).