Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

streamlit-keyup no longer renders with Streamlit 1.32.2 #35

Closed
nathancooperjones opened this issue Mar 19, 2024 · 5 comments · Fixed by #37
Closed

streamlit-keyup no longer renders with Streamlit 1.32.2 #35

nathancooperjones opened this issue Mar 19, 2024 · 5 comments · Fixed by #37

Comments

@nathancooperjones
Copy link

Streamlit 1.32.2 released on 3/14/24 and, with this release, a change was made such that streamlit-keyup no longer renders at all.

I'll attach screenshots below with what renders on my screen with a variety of recent Streamlit releases with the following dummy app code:

from st_keyup import st_keyup
import streamlit as st


st.write(st.__version__)

value = st_keyup(label='Enter a value')

st.write(value)

Streamlit 1.31.0:
Screenshot 2024-03-19 at 9 22 34 AM

Streamlit 1.32.0:
Screenshot 2024-03-19 at 9 23 12 AM

Streamlit 1.32.1:
Screenshot 2024-03-19 at 9 23 37 AM

Streamlit 1.32.2:
Screenshot 2024-03-19 at 9 24 08 AM

@msabramo
Copy link
Contributor

I saw this too.

Great job tracking down which version caused the breakage!

I wonder if we can get even more info about the breakage by cloning Streamlit from git and using git bisect to find the exact commit that caused the breakage. That could be really helpful to @blackary in figuring out a fix.

@msabramo
Copy link
Contributor

msabramo commented Mar 31, 2024

OK, I just did a git bisect and FWIW, it says that 8de20441339a0e5232b32d60b66f76f0bcb5ee0b is the Streamlit commit that broke things:

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit (1.32.2.dev20240313~2)(bisect)
$ git bisect good
8de20441339a0e5232b32d60b66f76f0bcb5ee0b is the first bad commit
commit 8de20441339a0e5232b32d60b66f76f0bcb5ee0b
Author: Ken McGrady <[email protected]>
Date:   Wed Mar 13 19:10:09 2024 -0700

    Fix initial iframe height for custom component (#8290)

    ## Describe your changes

    In 1.32.0, we introduced some changes to custom components that rendered
    an iframe of a certain height instead of a default of 0. This change
    ensures that when the `frameHeight` is `undefined`, it will use 0.

    ## GitHub Issue Link (if applicable)
    Closes #8285

    ## Testing Plan

    - Added a test to make sure it's set (and the Skeleton appears and
    disappears)

    ---

    **Contribution License Agreement**

    By submitting this pull request you agree that all contributions to this
    project are made under the Apache 2.0 license.

 .../CustomComponent/ComponentInstance.test.tsx     | 85 ++++++++++++++++++++++
 .../widgets/CustomComponent/ComponentInstance.tsx  | 36 ++++-----
 2 files changed, 98 insertions(+), 23 deletions(-)

msabramo added a commit to msabramo/streamlit-keyup that referenced this issue Mar 31, 2024
This commit fixes the issue where the component was not rendering with
Streamlit 1.32.2. The issue was that the `Streamlit.setFrameHeight(73)`
was being called before the component was rendered. This commit moves
the `Streamlit.setFrameHeight(73)` to the `onRender` function.

Fixes blackary#35
@msabramo
Copy link
Contributor

See #37 for a possible fix, although I mostly just got lucky messing around and don't know if this is a proper fix.

msabramo added a commit to msabramo/streamlit-keyup that referenced this issue Mar 31, 2024
After submitting blackaryGH-37 as a potential fix for blackaryGH-35, I wondered if there was a
way to add FE tests that would detect that sort of issue. I found that [Robot
Framework] is a popular tool for this, and it has a [SeleniumLibrary] that can
be used to interact with web pages. This commit adds a simple test case that
opens a browser, inputs text into the `st_keyup` input field, and waits for the
page to contain some expected text. The test case is run by a shell script that
uses the `robot` command to run the test case.  The test case is run by a shell
script that uses the `robot` command to run the test case.

This test fails with the code on `main` when using Streamlit 1.32.2, because of
blackaryGH-35:

```
(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (fe-tests-robot-framework)
$ pip freeze | grep '^streamlit'
streamlit==1.32.2

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (fe-tests-robot-framework)
$ ./run-robot-tests
==============================================================================
Robot
==============================================================================
Robot.Test Cases
==============================================================================
Interact with st_keyup                                                | FAIL |
Element 'css:iframe[title="st_keyup.st_keyup"]' not visible after 5 seconds.
------------------------------------------------------------------------------
Robot.Test Cases                                                      | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Robot                                                                 | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Output:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/output.xml
Log:     /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/log.html
Report:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/report.html
```

But it passes with the code in blackaryGH-37:

```
(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2●)
$ git branch
  fe-tests-robot-framework
* blackarygh-35-not-rendering-with-streamlit-1.32.2
  main

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2●)
$ git checkout -b blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework
Switched to a new branch 'blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework'

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework●)
$ git merge fe-tests-robot-framework
Merge made by the 'ort' strategy.
 .gitignore                               |  5 ++++-
 run-robot-tests                          |  3 +++
 tests/robot/resources/app_keywords.robot | 16 ++++++++++++++++
 tests/robot/test_cases.robot             | 16 ++++++++++++++++
 4 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100755 run-robot-tests
 create mode 100644 tests/robot/resources/app_keywords.robot
 create mode 100644 tests/robot/test_cases.robot

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework)
$ ./run-robot-tests
==============================================================================
Robot
==============================================================================
Robot.Test Cases
==============================================================================
Interact with st_keyup                                                | PASS |
------------------------------------------------------------------------------
Robot.Test Cases                                                      | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Robot                                                                 | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Output:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/output.xml
Log:     /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/log.html
Report:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/report.html
```

[Robot Framework]: https://robotframework.org/
[SeleniumLibrary]: https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html
@blackary
Copy link
Owner

blackary commented Apr 1, 2024

Wow, @msabramo , thank you so much for tracking the issue down and adding a fix -- this is so helpful!

blackary added a commit that referenced this issue Apr 1, 2024
…it-1.32.2

GH-35: Fix not rendering w/ Streamlit 1.32.2
@msabramo
Copy link
Contributor

msabramo commented Apr 1, 2024

Thank you, @blackary for sharing your work!

msabramo added a commit to msabramo/streamlit-keyup that referenced this issue Apr 7, 2024
After submitting blackaryGH-37 as a potential fix for blackaryGH-35, I wondered if there was a
way to add FE tests that would detect that sort of issue. I found that [Robot
Framework] is a popular tool for this, and it has a [SeleniumLibrary] that can
be used to interact with web pages. This commit adds a simple test case that
opens a browser, inputs text into the `st_keyup` input field, and waits for the
page to contain some expected text. The test case is run by a shell script that
uses the `robot` command to run the test case.  The test case is run by a shell
script that uses the `robot` command to run the test case.

This test fails with the code on `main` when using Streamlit 1.32.2, because of
blackaryGH-35:

```
(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (fe-tests-robot-framework)
$ pip freeze | grep '^streamlit'
streamlit==1.32.2

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (fe-tests-robot-framework)
$ ./run-robot-tests
==============================================================================
Robot
==============================================================================
Robot.Test Cases
==============================================================================
Interact with st_keyup                                                | FAIL |
Element 'css:iframe[title="st_keyup.st_keyup"]' not visible after 5 seconds.
------------------------------------------------------------------------------
Robot.Test Cases                                                      | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Robot                                                                 | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Output:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/output.xml
Log:     /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/log.html
Report:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/report.html
```

But it passes with the code in blackaryGH-37:

```
(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2●)
$ git branch
  fe-tests-robot-framework
* blackarygh-35-not-rendering-with-streamlit-1.32.2
  main

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2●)
$ git checkout -b blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework
Switched to a new branch 'blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework'

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework●)
$ git merge fe-tests-robot-framework
Merge made by the 'ort' strategy.
 .gitignore                               |  5 ++++-
 run-robot-tests                          |  3 +++
 tests/robot/resources/app_keywords.robot | 16 ++++++++++++++++
 tests/robot/test_cases.robot             | 16 ++++++++++++++++
 4 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100755 run-robot-tests
 create mode 100644 tests/robot/resources/app_keywords.robot
 create mode 100644 tests/robot/test_cases.robot

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework)
$ ./run-robot-tests
==============================================================================
Robot
==============================================================================
Robot.Test Cases
==============================================================================
Interact with st_keyup                                                | PASS |
------------------------------------------------------------------------------
Robot.Test Cases                                                      | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Robot                                                                 | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Output:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/output.xml
Log:     /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/log.html
Report:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/report.html
```

[Robot Framework]: https://robotframework.org/
[SeleniumLibrary]: https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants