Streamlit app in Snowflake turned into pure Streamlit app

Hi there!

I have built a streamlit app inside snowflake account; but now i want the streamlit app public facing, so I am trying to move my streamlit app to Streamlit.

In streamlit app, I am able to connect to snowflake account and create a session by using:

from snowflake.snowpark import Session

session = Session.builder.configs(st.secrets["connections"]["snowflake"]).create()

I want to do the same thing in the Steamlit with the following code:

from snowflake.core import Root
from snowflake.snowpark import Session

session = Session.builder.configs(st.secrets["connections"]["snowflake"]).create()

root = Root(session)                         
svc = root.databases[CORTEX_SEARCH_DATABASE].schemas[CORTEX_SEARCH_SCHEMA].cortex_search_services[CORTEX_SEARCH_SERVICE]

but streamlit app throws errors : modulenotfound “snowflake.core”, which I tried to put it in my environment.yaml file.

My end goal is to utilize cortex search service in my public facing streamlit. Could you please assist?

Thanks!

See the docs to learn how to name your requirements file in streamlit cloud.

my environment.yml file. I’ve read that docs link but it doesn’t help.

What did you tried to put it in your environment.yml file exactly?

Sorry, I missed your message. I am coming back to this personal project.

name: app_environment
channels:
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
dependencies:
  - python
  - snowflake-ml-python
  - snowflake-snowpark-python
  - snowflake-connector-python
  - streamlit

I put these in my environment.yaml.

You said environment.yml before.

image

Typo… it is environment.yml.

Can you check the console logs for your app and see if it’s able to install everything properly, or if there is an error when it’s trying to install.

If that doesn’t help, I would try one of two things to try and get it working:

  1. Switch your channels list to just be - conda-forge
  2. Switch to a requirements.txt
1 Like

How did you chose those specific libraries to install? It doesn’t look like any of them provides snowflake.core. I think you need to install snowflake or snowflake.core. Review the snowflake documentation.

I reviewedt the snowflake documentation. it doesn’t provide snowflake under anaconda. so I wasn’t able to use snowflake.core.

Then you can use pip.

Thanks Goyo for the help! It works now after I repeated my initial try. Not sure what I have done wrong…

Thanks blackary. I used requirements.txt in my initial attempt and it didn’t work. so i switched to environments.yml file and it stil didn’t work. After several attempts, i switched back to requirements.txt… now it works… not sure what I had done wrong at the initial try… :woman_shrugging:

1 Like

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