Getting Started: Cloud Notebooks#

IMPORTANT

Before you can use relationalai, ensure that your Snowflake account administrator has:

  1. Installed the RelationalAI Native App from the Snowflake Marketplace.
  2. Granted your Snowflake user the app_user application role.

See the Native App Installation guide for details.

You can use RelationalAI in cloud notebook environments like Snowflake, Google Colab or Hex. Click on the tabs below to see the instructions for each cloud notebook environment.

Install RAI#

Container Notebooks#

To create a new Snowflake Container Notebook, navigate to New Notebook from the Snowsight home page:

new notebook menu selection

Choose a database and a warehouse and select the Run on container option:

new notebook modal with option to run on container

Click the triple-dot icon (⋮) in the top right corner of the notebook to open a modal:

triple-dot icon for accessing more notebook settings

In the modal that pops up, enable the PyPI integration:

pypi integration modal

If you don’t see the PyPI integration option, ensure that the commands in the Installation Notebook were run by an account administrator.

To install the RelationalAI library, run the following shell command in the first cell of the notebook:

#%pip install relationalai

Warehouse Notebooks#

Follow these steps to install the RelationalAI (RAI) Python package for use in a Snowflake notebook environment with the Run on warehouse option:

  1. Choose Notebook settings from the triple-dot (⋮) dropdown in the top-right corner of the Snowflake Notebooks window and switch to the External access tab. Turn on the S3_RAI_INTERNAL_BUCKET_EGRESS_INTEGRATION toggle. This allows your notebook to access data from the RAI Native App.
  2. Upload the RAI Python library as a ZIP file into your notebook filesystem. You can download the ZIP file here.
  3. Run the following code to make the packages in the ZIP file visible to the Python interpreter:
#import sys
sys.path.append("./relationalai.zip")

Test Your Installation#

Verify that the relationalai package is installed and working correctly by running the following code:

#import relationalai as rai

# Create a model named "MyFirstModel".
model = rai.Model("MyFirstModel")

# Send a test query.
with model.query() as select:
    response = select(1 + 1)

# The results are stored as a pandas DataFrame in the response.results attribute.
print(response.results)
#    v
# 0  2
NOTE

The first time you query a model, a RAI engine is created for you. Engines are RAI Native App compute resources similar to Snowflake warehouses that evaluate queries from RAI models. Note that it may take several minutes to create your engine.

Next Steps#

Check out the Tutorial to learn how to create a model step-by-step using the RAI Python API.