App suddenly stopped working on cloud but still works locally

Noticed this in April 2024. I think it has to do something with gensim package and dependencies. And that something was updated on the web but I am unsure where to look to confirm this and what to do next. I would appreciate any assistance - thanks.

  1. Link to public app: https://flavorspace-nkugmzxwvtc7fffhsyd5tj.streamlit.app/
  2. GitHub repository: [GitHub - jhwaffles/flavor_space]
  3. Error Message: ```
    File “/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 534, in _run_script
    exec(code, module.dict)File “/mount/src/flavor_space/app.py”, line 5, in
    import gensimFile “/home/adminuser/venv/lib/python3.11/site-packages/gensim/init.py”, line 11, in
    from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils # noqa:F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File “/home/adminuser/venv/lib/python3.11/site-packages/gensim/corpora/init.py”, line 6, in
    from .indexedcorpus import IndexedCorpus # noqa:F401 must appear before the other classes
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File “/home/adminuser/venv/lib/python3.11/site-packages/gensim/corpora/indexedcorpus.py”, line 14, in
    from gensim import interfaces, utilsFile “/home/adminuser/venv/lib/python3.11/site-packages/gensim/interfaces.py”, line 19, in
    from gensim import utils, matutilsFile “/home/adminuser/venv/lib/python3.11/site-packages/gensim/matutils.py”, line 20, in
    from scipy.linalg import get_blas_funcs, triu
4. Streamlit Version:  streamlit==1.28.1
Python Version:  3.10.13

Hey @jhwaffles
Hope you’re doing good! :slight_smile:

  1. Please provide the specific error message from Streamlit Cloud under your deployed app’s ‘Manage app’ section.

  2. No version of 1.28.1 is ever deployed in Streamlit. You can check here: Streamlit Changelog
    I would suggest you correct the Streamlit version 1.28.0 in your requirements.txt file.

  3. Have you selected Python version 3.10 for this app during deployment under the “Advance settings” modal? :thinking:

  1. After visiting your app, I’ve observed another error on both the pages, cluster browser and visualize flavor space. Both of the pages throw the same error .:point_down:

KeyError: This app has encountered an error.

File "/mount/src/flavor_space/pages/cluster_browser.py", line 9, in <module>
    projection_df=st.session_state["projection_df"]
                  ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/state/session_state_proxy.py", line 90, in __getitem__
    return get_session_state()[key]
           ~~~~~~~~~~~~~~~~~~~^^^^^
File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/state/safe_session_state.py", line 89, in __getitem__
    return self._state[key]
           ~~~~~~~~~~~^^^^^
File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/state/session_state.py", line 396, in __getitem__
    raise KeyError(_missing_key_error_message(key))

Please look into this one as well where I guess you haven’t initialized values for the st.session_state[key] variables. Have a look here: Session State

Let me know your further queries!
Thanks,
Shruti

Hi @ShruAgarwal
Thanks for looking at this:

  1. Here’s the full error message when selecting ‘manage app’"

ImportError: This app has encountered an error. The original error message is redacted to prevent data leaks. Full error details have been recorded in the logs (if you’re on Streamlit Cloud, click on ‘Manage app’ in the lower right of your app).

Traceback:

File "/home/adminuser/venv/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 534, in _run_script
    exec(code, module.__dict__)File "/mount/src/flavor_space/app.py", line 5, in <module>
    import gensimFile "/home/adminuser/venv/lib/python3.11/site-packages/gensim/__init__.py", line 11, in <module>
    from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils  # noqa:F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/home/adminuser/venv/lib/python3.11/site-packages/gensim/corpora/__init__.py", line 6, in <module>
    from .indexedcorpus import IndexedCorpus  # noqa:F401 must appear before the other classes
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File "/home/adminuser/venv/lib/python3.11/site-packages/gensim/corpora/indexedcorpus.py", line 14, in <module>
    from gensim import interfaces, utilsFile "/home/adminuser/venv/lib/python3.11/site-packages/gensim/interfaces.py", line 19, in <module>
    from gensim import utils, matutilsFile "/home/adminuser/venv/lib/python3.11/site-packages/gensim/matutils.py", line 20, in <module>
    from scipy.linalg import get_blas_funcs, triu
  1. Weird. I corrected the version to 1.28.0.

  2. Noted. I haven’t changed anything with Advance settings yet. I will try this next.

  3. The main page ‘app.py’ initializes the variables and loads it into the cluster browser and visualize flavor space pages. I believe these errors are tied to the start up of the app itself.

So I updated the requirements.txt and still see the same error. The app was running online fine since February 2024 when all the sudden in the past 2 weeks it started showing the error. But it still works works fine locally. The import error makes me think it has to do with gensim package and dependencies specifically. Any ideas?

Thanks,
-Justin H

Ok I resolved the issue! The issue was dependency-related. gensim needed scipy so I added it as a line in requirements.txt. I got thrown off because this dependency issue wasn’t there before and all the sudden it came up (app stopped working even though I did not push any code changes). I don’t know how to explain what happened but at least there was a fix. Thanks for your help!

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.