-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Console script returning RuntimeError #8606
Comments
Acknowledged! This behavior change seems to have been introduced via this PR, since now the Component Registry is loaded from the runtime and is not a singleton anymore. When you run the standalone command, the runtime does not seem to be initialized, resulting in the error you are seeing. |
Hello, |
I can confirm the same issue as well for the import of custom components. Reproducable code: file: streamlit_bug_report.pyimport streamlit as st
# This line raises "RuntimeError: Runtime hasn't been created!" in streamlit>=1.34.0
from streamlit_elements import elements, dashboard, mui, nivo
def app():
# assume somthing with the streamlit_elements component happens here
st.write("Hello World")
if __name__ == "__main__":
app() runs fine if one starts the app with But if the app is started via cli with help of streamlit.web.bootstrap its now raising an error since streamlit version file: streamlit_bug_report_cli.pyimport streamlit as st
import streamlit.web.bootstrap as st_bootstrap
from streamlit_bug_report import app
def main():
if st.runtime.exists():
# The app has been executed with `streamlit run app.py`
app()
else:
# If the file has been executed with python (`python app.py`), the streamlit functionality
# won't work. This line reruns the app within the streamlit context, as if it has been
# executed with `streamlit run app.py`.
# This is necessary when installing this project from a .whl package, since the executable
# only gets execute by python and not by streamlit.
st_bootstrap.run(
__file__,
is_hello=False,
args=[],
flag_options={},
)
if __name__ == "__main__":
main() Running |
The issue also affects automated tests in packages like |
Hey y'all, just a quick update that we are going to discuss the issue & potential fix (#8610) tomorrow and I'll keep you posted. Sorry for the inconvenience and thanks for reporting the issue with these details ❤️ |
## Describe your changes Closes #8606 The PR allows custom component modules to be executed standalone by not registering them with Streamlit at all, which makes sense since Streamlit is not started. It's a cherry-pick of this broader PR #8610, which also adds tests. However, we want to discuss our testing strategy first, so we decouple it from adding the fix (see for example also this PR #8616). ## GitHub Issue Link (if applicable) - #8606 - NathanChen198/streamlit-rsa-auth-ui#1 - randyzwitch/streamlit-folium#186 ## Testing Plan - E2E Tests: tests to ensure this behavior will come in a separate PR, see #8616 and #8610 --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
We have merged #8620 that should fix this issue, so it should land in streamlit-nightly and latest in |
Awesome, thanks! |
See also: zilliztech#315, streamlit/streamlit#8606 Signed-off-by: yangxuan <[email protected]>
See also: #315, streamlit/streamlit#8606 Signed-off-by: yangxuan <[email protected]>
## Describe your changes Closes streamlit#8606 The PR allows custom component modules to be executed standalone by not registering them with Streamlit at all, which makes sense since Streamlit is not started. It's a cherry-pick of this broader PR streamlit#8610, which also adds tests. However, we want to discuss our testing strategy first, so we decouple it from adding the fix (see for example also this PR streamlit#8616). ## GitHub Issue Link (if applicable) - streamlit#8606 - NathanChen198/streamlit-rsa-auth-ui#1 - randyzwitch/streamlit-folium#186 ## Testing Plan - E2E Tests: tests to ensure this behavior will come in a separate PR, see streamlit#8616 and streamlit#8610 --- **Contribution License Agreement** By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.
Checklist
Summary
When you create a Python package, you may want to provide a user-friendly CLI, via an entry point console script. Here is an excerpt from setuptools explaining it:
A practical example is when you install streamlit, and want to check which version is installed. So you run in the terminal:
This is a console script.
Console scripts are also very useful for Streamlit Components that are distributed via PyPI. And they used to work until version 1.33.0. However, with the new 1.34.0 release, they no longer do. Now, trying to run a console script from a Streamlit Component returns a
RuntimeError
.Reproducible Code Example
No response
Steps To Reproduce
. venv/bin/activate
You get a
RuntimeError
.Expected Behavior
This is the expected output from the previous example:
And until Streamlit version 1.33.0, this was the actual output.
Current Behavior
With Streamlit version 1.34.0 installed, this is the output:
Is this a regression?
Debug info
Additional Information
No response
The text was updated successfully, but these errors were encountered: