Version 0.81.0

Hi there,

The st.form is a really cool feature! Thanks for that.
Generally it is working fine, but I noticed that custom components do not show up within a form.
Is this just not implemented yet, is it a bug, or is it just me?

Thanks,
LeChuck

Hey @LeChuck !

I checked in with the team, and I believe it should show up just fine. Can you provide some example code to demonstrate the issue? I wonder if the custom component is not setting its height correctly.

Hi @kmcgrady,
Thanks for your reply.
While trying to make a minimal example, I noticed that there is an update 0.81.1.
After updating it is now working fine. Before it didnā€™t.
So, problem solved! :slight_smile:
Thanks anyway.
Cheers

@Lior_D did you manage to deploy your app with st.form at the end? I am facing the same issue :confounded: with version 0.82.0

@kmcgrady any update from your side on how this could be resolved?

Thanks @coxi for reminding me. I think using bootstrap is a unique use case here. I donā€™t think we internally expected users to run scripts via bootstrap. I can forward this information to the team to consider.

3 Likes

Thanks for the quick reply. That would be really great!

As additional info, in my case I am trying to deploy the app using RStudio Connect, not sure what they use under the hood tho, but maybe also bootstrap.

@coxi
Hi, no unfortunately not yet.

@kmcgrady
We do not run scripts via bootstrap per se, rather we use it as an extremely useful development tool, so having any feature working on bootstrap is a prerequisite for us to be using it.

Thanks,
L

Hey Iā€™m experiencing the exact same issue, tried to change the code countless times but nothing works. Did you find a solution? Thanks

Hey @Lior_D, @fedegaucho, @coxi,

Yeah, kmcgrady is correct that we donā€™t really support using bootstrap in this way (because itā€™s just undocumented internals of Streamlit, which are all subject to change ā€“ as youā€™re seeing here :)).

However! We do support debugging Streamlit apps interactively. You can achieve this without using bootstrap. I do this with PyCharm - you can see it in this ā€œIntro to Custom Componentsā€ youtube video, starting at about the 10 minute mark. The tl;dr is that you debug streamlit run myscript.py, rather than myscript.py:

You can see that ā€œScript pathā€ is set to <some_virtualenv_path>/bin/streamlit, and the ā€œparametersā€ are set to run <scriptname.py>. (To discover the path to bin/streamlit within my virtual environment, I just ran which streamlit inside a shell with my virtualenv activated.)

When I set a breakpoint inside my script, PyCharm just works in the way youā€™d hope!

(I donā€™t use VSCode, but I imagine this should work there as well.)

Does this solve what youā€™re trying to do with bootstrap.py?

As a command-line freak, my one-liner solution is to just add this anywhere in my appā€™s code to start a debugger at that spot:

import pdb; pdb.set_trace()

Alternatively, on Python 3.7+ you can just use this:

breakpoint()

ā€¦and the cool part is that you can configure which debugger gets called with breakpoint() by setting the PYTHONBREAKPOINT environment variable. For example, to set pudb as your debugger you just need to put this in your bashrc:

export PYTHONBREAKPOINT="pudb.set_trace"

Hi @kmcgrady , I support this usecase. I also use bootstrap to run my script. Basically this is the only solution to programmatically invoke streamlit script other than using command line. Also please let us know, if there are other solutions to achieve the same

Attaching my original question on the same: How can I invoke streamlit from within python code? - #2 by Jacob_Lukose

Hey @tim , thank you for sharing this, is really helpful, and going to give it a try! Unfortunately, my problem it was that Rstudio connect seems to deploy every script with the bootstrapping method and therefore thereā€™s no way to make forms work on their server. Anyway, I solved the issue by recreating the form using just buttons and now it works as expected!

@fedegaucho Iā€™m not familiar with Rstudio, so I might be misunderstanding - are you saying that they have a Streamlit integration that relies on Streamlit internals?

@Jacob_Lukose - Pythonā€™s subprocess module is a good way to procedurally invoke other processes, including Streamlit.

We use subprocess internally for a number of things, including executing Streamlit scripts in our automated end-to-end tests. See the run_e2e_tests.py script for an example in our codebase.

@fedegaucho would you be able to share your implementation? Iā€™m running in the same problem and a work around using just buttons would be very helpful.

Same problem as @coxi and @fedegaucho . We use RStudio Connect to host our streamlit apps, and it seems that forms do not work at all when the app is deployed by RSConnect.

Same error as Lior_Dā€™s original comment. Everything visually renders, but you get a ā€˜Missing Submit Buttonā€™ error and the widgets act like normal widgets, not form widgets.

Hey @lklein, Instead of this:

with st.form("form_name"):
        selectbox = st.selectbox("selectbox_text", ["option1", "option2"])
        textInput = st.text_input('selectinput_text')
        submitted = st.form_submit_button('Submit')
        
if submitted:
    for option in selectbox:
        print(option)

I did the following:

selectbox = st.selectbox("selectbox_text", ["option1", "option2"])
textInput = st.text_input("selectinput_text")

if st.button("Button_text"):
        for option in selectbox:
            print(option)

And it worked for me. The only other issue was the fact that, in the app, once you fill one widget, streamlit runs the whole code. I solved it with if statements.

Hope it can help

@tim Iā€™m not sure about it, just saw in some logs that something with boostrap was involved and I inferred it to be related to coxiā€™s issue. Anyway I just shared my workaround below on Iklein comment, probably not the best but working!

Hi, I ended up here because I too am running into issues with using forms on a Streamlit app that is deployed to RStudio Connect. In both my development environment and the Connect environment, I am using Python-3.8.8 and Streamlit-0.86.0 (have also tried other versions of streamlit >=0.81.0). Running the app locally, the form functionality works perfectly. When running the same app deployed on RStudio Connect, I get the same error message as @Lior_D showed above (ā€œMissing Submit Buttonā€). Wondering if anyone has figured out the issue here? Thanks!

Just to follow-up, in my case it turned out that an API change implemented in Streamlit > 0.78.0 causes issues with certain versions of RStudio Connect. Upgrading RStudio Connect to v1.9.0.1 fixed the issue and enables the full functionality of the latest versions of Streamlit.

Great to hear, thanks for posting @timL!