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

Import Syntax Issues With Streamlit 1.12.2 #44

Closed
code49 opened this issue Sep 21, 2022 · 4 comments
Closed

Import Syntax Issues With Streamlit 1.12.2 #44

code49 opened this issue Sep 21, 2022 · 4 comments

Comments

@code49
Copy link

code49 commented Sep 21, 2022

Trying to build a website using Hydralit, and encountered ModuleNotFound errors immediately upon importing the library.

It seems like at some point Streamlit changed around their code schema; changing two lines in sessionstate.py seemed to do the trick:

# from
from streamlit.scriptrunner.script_run_context import get_script_run_ctx

# to
from streamlit.runtime.scriptrunner.script_run_context import get_script_run_ctx

and

# from
from streamlit.server.server import Server

# to
from streamlit.web.server import Server

I'm pretty new to Streamlit/Hydralit, but hopefully these changes won't break anything else? Seems to be working just fine from the testing I've been doing.

@code49
Copy link
Author

code49 commented Sep 21, 2022

After some more digging, it seems like these changes would also introduce issues around getting the sessionstate for a specific session_id (perhaps the functionality of Server has changed?); working on potential solutions now.

As a side note, this seems to be the part of the same-ish issue as #43 , so perhaps the fix to that will fix these import path issues as well.

@saikumarmk
Copy link
Contributor

Yes, the way the streamlit server imports worked before was that it used a hack to obtain a state, which is now deprecated. The Server class no longer has a method called get_current, which breaks Hydra anyway. See this forum post on Streamlit 1.12 breaking functionality: https://discuss.streamlit.io/t/streamlit-script-run-context-gone-with-1-8/23526/5. Fishing the Server instance from the GC is hacky.

I've been working on refactoring Hydralit to use the built-in session_state, which removes the need for the sessionstate.py file entirely.

@saikumarmk
Copy link
Contributor

Update:

I've put in a PR for a rewrite that works with Streamlit >=1.12. You can check it out at #45. I've only tested it with hydralit_example though.

@TangleSpace
Copy link
Owner

please update to the latest package (1.0.14), as a fix has been created and deployed.

pip install -U hydralit

Thanks very much for your hard work saikumarmk!

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

No branches or pull requests

3 participants