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

Update st.cache to st.cache_data ro cache_resource #17

Open
johnnyb1509 opened this issue May 5, 2023 · 18 comments
Open

Update st.cache to st.cache_data ro cache_resource #17

johnnyb1509 opened this issue May 5, 2023 · 18 comments

Comments

@johnnyb1509
Copy link

Hi maintainer,

As st.cache depreciated on streamlit, please update to other method

@tushar-31093
Copy link

I kept wondering if the code had some issue. Apparently, this library needs an update.

@karmataco
Copy link

Is there a work around? I have an error in my home page displaying that I can't get rid of.

@johnnyb1509
Copy link
Author

I think we need to fork the repo then fix it. There r no respondence from author

@karmataco
Copy link

I think we need to fork the repo then fix it. There r no respondence from author

I can't even find where the problem is at. I can't find a reference in the code

@tushar-31093
Copy link

tushar-31093 commented Jun 17, 2023

I think we need to fork the repo then fix it. There r no respondence from author

I can't even find where the problem is at. I can't find a reference in the code

There is no direct use in the code but the dependencies it builds. The dependencies it installs, somewhere it has this cache method that is outdated and it causes an issue during runtime.

If it were there directly in the code, we would have fixed it already and used it as is.

Maybe update your streamlit versions etc in the base environment and then use this library once. You'd see the issue.

I'll try to share some reproducible code here for what gave the error.

Btw. I did make it vanish by force removing the warning or something I believe. It's working for me.

View the page.

https://alphaai.streamlit.app/

@tushar-31093
Copy link

I think we need to fork the repo then fix it. There r no respondence from author

Possible for you to share screenshots etc for where the issue came in?

@karmataco
Copy link

I hid the alert div. Is that how you managed to hide it? Also, I found the culprit and there's a pull request that hasn't been accepted :(. It's literally one line
ktosiek/streamlit-cookies-manager#3

@Klein-Baru
Copy link

Klein-Baru commented Jun 17, 2023

Solution to the st.cache deprecation problem.

I was able to find a way through:

  1. The warning appears on the Firefox browser and does not appear on the Chrome and Brave browsers. (from tests I conducted with streamlit v1.23.1) You can consider switching browsers😂😂.
  2. Add some arguments to the streamlit run <python file> command. Thus to suppress the warnings, use streamlit run <python file> --client.showErrorDetails=false

solutions above are for local host only. Online deployment has not been tested.

@RyanBin0126
Copy link

RyanBin0126 commented Jun 22, 2023

Discovered the usage of st.cache in the import statement from streamlit_cookies_manager import EncryptedCookieManager. I refactored the code by replacing st.cache with st.cache_data. After restarting PyCharm and reloading the Streamlit app, the warning was resolved.

@Klein-Baru
Copy link

Klein-Baru commented Jun 23, 2023 via email

@Klein-Baru
Copy link

@RyanBin0126 Awesome!!. I understand your solution theoretically, I will try it out practically to see it in action.

On Thu, Jun 22, 2023, 3:22 PM RyanBin @.> wrote: I found st.cache in "from streamlit_cookies_manager import EncryptedCookieManager". Though I changed st.cache to st.cache_data, i still received a warning. I am keeping looking the other st.cache. — Reply to this email directly, view it on GitHub <#17 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7EDH77DJZ3Z6HJOGN4EQ3LXMQ2GXANCNFSM6AAAAAAXWUA6RQ . You are receiving this because you commented.Message ID: @.>

@RyanBin0126 How do you refactor the st.cache to st.cache_data in Pycharm? I cant find the streamlit-cookies-manager module where st.cache is, presumably, initially declared.

@RyanBin0126
Copy link

@RyanBin0126 Awesome!!. I understand your solution theoretically, I will try it out practically to see it in action.

On Thu, Jun 22, 2023, 3:22 PM RyanBin @.> wrote: I found st.cache in "from streamlit_cookies_manager import EncryptedCookieManager". Though I changed st.cache to st.cache_data, i still received a warning. I am keeping looking the other st.cache. — Reply to this email directly, view it on GitHub <#17 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7EDH77DJZ3Z6HJOGN4EQ3LXMQ2GXANCNFSM6AAAAAAXWUA6RQ . You are receiving this because you commented.Message ID: _@**.**_>

@RyanBin0126 How do you refactor the st.cache to st.cache_data in Pycharm? I cant find the streamlit-cookies-manager module where st.cache is, presumably, initially declared.

@Klein-Baru
There are two methods.

The first method is more convenient for those who are using PyCharm.
At the place where you initially imported "from streamlit_login_auth_ui.widgets import login", hold the Ctrl key and click on "login" with the mouse. You will be taken to "widgets.py". At the top of the .py file, you will see "from streamlit_cookies_manager import EncryptedCookieManager". Next, jump into the py file "encrypted_cookie_manager" where "EncryptedCookieManager" is located. Line 14, above the method "key_from_parameters", you will find "@st.cache". You can modify it there.

The second method is to directly open the file Miniconda3\envs"your envs"\Lib\site-packages\streamlit_cookies_manager\encrypted_cookie_manager.py in the system and make the modification.

Good luck!

@Klein-Baru
Copy link

@RyanBin0126 Awesome!!. I understand your solution theoretically, I will try it out practically to see it in action.

On Thu, Jun 22, 2023, 3:22 PM RyanBin @.> wrote: I found st.cache in "from streamlit_cookies_manager import EncryptedCookieManager". Though I changed st.cache to st.cache_data, i still received a warning. I am keeping looking the other st.cache. — Reply to this email directly, view it on GitHub <#17 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7EDH77DJZ3Z6HJOGN4EQ3LXMQ2GXANCNFSM6AAAAAAXWUA6RQ . You are receiving this because you commented.Message ID: _@**.**_>

@RyanBin0126 How do you refactor the st.cache to st.cache_data in Pycharm? I cant find the streamlit-cookies-manager module where st.cache is, presumably, initially declared.

@Klein-Baru There are two methods.

The first method is more convenient for those who are using PyCharm. At the place where you initially imported "from streamlit_login_auth_ui.widgets import login", hold the Ctrl key and click on "login" with the mouse. You will be taken to "widgets.py". At the top of the .py file, you will see "from streamlit_cookies_manager import EncryptedCookieManager". Next, jump into the py file "encrypted_cookie_manager" where "EncryptedCookieManager" is located. Line 14, above the method "key_from_parameters", you will find "@st.cache". You can modify it there.

The second method is to directly open the file Miniconda3\envs"your envs"\Lib\site-packages\streamlit_cookies_manager\encrypted_cookie_manager.py in the system and make the modification.

Good luck!

@RyanBin0126

Tried method 1 on Pycharm, the warning disappeared!! Thanks for sharing.

@woensug-choi
Copy link

tried streamlit run <python file> --client.showErrorDetails=false on deployment and works ok for now..

@banstala
Copy link

banstala commented Sep 6, 2023

The --client.showErrorDetails=false option does work-- on the browser (the web-page for login does not show up the warning), but in test environment the warning is still shown on the terminal where the streamlit app is being run.

On the other hand, finding the encrypted_cookie_manager.py file and replacing @st.cache with @st.cache_resource solves the issue on a deeper level-- the warning vanishes from the login page on the browser, as well as on the terminal where the app is being run.

Cheers for both interim solutions, nonetheless !

Will be looking forward to the bug-fix in a future release of streamlit-login-auth-ui.

@MaxSeck
Copy link

MaxSeck commented Sep 14, 2023

So I found the encrypted_cookie_manager.py and @st.cache in line 14. When trying to change to @st.cache_data I can't save it and get this error message:

Failed to save 'encrypted_cookie_manager.py': Unable to write file 'vscode-remote://wsl+ubuntu/usr/local/lib/python3.10/dist-packages/streamlit_cookies_manager/encrypted_cookie_manager.py' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/usr/local/lib/python3.10/dist-packages/streamlit_cookies_manager/encrypted_cookie_manager.py')

Already tried to change the permission but I still can't save it.

@RyanBin0126
Copy link

So I found the encrypted_cookie_manager.py and @st.cache in line 14. When trying to change to @st.cache_data I can't save it and get this error message:

Failed to save 'encrypted_cookie_manager.py': Unable to write file 'vscode-remote://wsl+ubuntu/usr/local/lib/python3.10/dist-packages/streamlit_cookies_manager/encrypted_cookie_manager.py' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/usr/local/lib/python3.10/dist-packages/streamlit_cookies_manager/encrypted_cookie_manager.py')

Already tried to change the permission but I still can't save it.

Try modifying it in a local file instead of the pycharm editor

@olsonperrensen
Copy link

Someone wants to make a PR to solve this in main ?

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

9 participants