You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bug regarding lists-values was first described in a comment to #36. #36 in the strict sense is fixed by merged-not-yet-released PR #37. I open this issue to track the list-valued problem separately, which does not seem to be related to pydantic 2.
Describe the bug:
List valued models do not work. There is code in streamlit-pydantic for handling list-valued models that suggest that it might have worked earlier, but at least with current versions of streamlit, list-valued models do not render as forms.
List-Editing is solved in streamlit-pydantic among others by adding a button: self._render_list_add_button(key, add_col, data_list) (ui_renderer.py:1000), but that tries to add a streamlit.button(...) to the interface. However, adding a regular button within a form is disallowed by streamlit button.py:407-411 raising an exception. Only form-submit buttons are currently allowed in Streamlit within forms. (The exception raising was part of Streamlit from the very beginning of adding the "form" feature in April 2021, so it's not clear how list valued editing was supposed to work in streamlit-pydantic to begin with)
The exception then seems to be silently caught and ignored by streamlit-pydantic, so that the form does not render, correctly, but also no exception is displayed within the streamlit app.
Expected behaviour:
List valued models should be also rendered and editing should be possible with streamlit-pydantic.
Steps to reproduce the issue:
You can use the example used in #36 on a codebase which has #37 merged to reproduce. OtherSettings has : list[NonNegativeInt] values.
Technical details:
Host Machine OS (Windows/Linux/Mac): Windows
Browser (Chrome/Firefox/Safari): Firefox
Notes:
Given that the raising of the specific exception in Streamlit is quite intentional and seems to be a core design decision, an alternative mode to edit lists has to be found, if possible at all.
After a quick browse through streamlit elements it can maybe solved by a "data editor" element, though the result would likely be unsightly and cumbersome. Similarly cumbersome would be using a "text input" with some convention for splitting the values. Neither seems to be a particularly good solution, the solution space needs to be explored further.
The text was updated successfully, but these errors were encountered:
I'm not very familiar with streamlit - so excuse the ignore - but what is gained by using a form other than the visual aspects? I understand that inputs are batched, but looking at the implementation for pydantic_form I'm not entirely sure the batching matters?
Would love to see this fixed! This bug is the main thing keeping me from using streamlit-pydantic (and Streamlit altogether) for my auto-generated UIs. Looks super cool otherwise
This bug regarding lists-values was first described in a comment to #36. #36 in the strict sense is fixed by merged-not-yet-released PR #37. I open this issue to track the list-valued problem separately, which does not seem to be related to pydantic 2.
Describe the bug:
List valued models do not work. There is code in streamlit-pydantic for handling list-valued models that suggest that it might have worked earlier, but at least with current versions of
streamlit
, list-valued models do not render as forms.List-Editing is solved in
streamlit-pydantic
among others by adding a button:self._render_list_add_button(key, add_col, data_list)
(ui_renderer.py:1000), but that tries to add astreamlit.button(...)
to the interface. However, adding a regular button within a form is disallowed by streamlit button.py:407-411 raising an exception. Only form-submit buttons are currently allowed in Streamlit within forms. (The exception raising was part of Streamlit from the very beginning of adding the "form" feature in April 2021, so it's not clear how list valued editing was supposed to work in streamlit-pydantic to begin with)The exception then seems to be silently caught and ignored by streamlit-pydantic, so that the form does not render, correctly, but also no exception is displayed within the streamlit app.
Expected behaviour:
List valued models should be also rendered and editing should be possible with streamlit-pydantic.
Steps to reproduce the issue:
You can use the example used in #36 on a codebase which has #37 merged to reproduce.
OtherSettings
has: list[NonNegativeInt]
values.Technical details:
Notes:
Given that the raising of the specific exception in Streamlit is quite intentional and seems to be a core design decision, an alternative mode to edit lists has to be found, if possible at all.
After a quick browse through streamlit elements it can maybe solved by a "data editor" element, though the result would likely be unsightly and cumbersome. Similarly cumbersome would be using a "text input" with some convention for splitting the values. Neither seems to be a particularly good solution, the solution space needs to be explored further.
The text was updated successfully, but these errors were encountered: