Skip to content

Using the RelationalAI Predictive Reasoner in a Snowflake Notebook

To use the RelationalAI Predictive Reasoner, you’ll need access to the RelationalAI Native App. You can request access via the Snowflake Marketplace. When submitting your request, be sure to include a note indicating that you’re interested in the app’s predictive reasoning capabilities using graph neural networks (GNNs).

Once your request is approved you will receive email notification by RAI. Follow the instructions here to install the RAI Native App. Note that you will need to be a user with either ORGADMIN or ACCOUNTADMIN privileges to do the installation.

If you have already installed the RelationalAI Native App reach out to us to request enabling the predictive reasoning feature flag.

To train models and make predictions within a Snowflake Notebook, you need access to certain RelationalAI services through the Predictive Reasoner Python SDK. Since this SDK isn’t available by default, you must install it as a third-party Python package. Snowflake supports this by allowing you to import packages from a Snowflake stage. For more details, refer to the official Snowflake documentation.

So, you’ll first need to upload the SDK package to a Snowflake stage. Follow the steps below:

  1. Download the SDK package. Obtain the provided ZIP file relationalai_gnns.zip.
  2. Create a Snowflake stage to upload the package. Run the following SQL commands in a Snowflake worksheet:
    • Select the database and schema where you want to create the stage to upload the package:
    USE DATABASE RELATIONAL_AI_GNN; --database name that sdk is uploaded
    USE SCHEMA SDK_SCHEMA; --schema name that sdk is uploaded
    • Create the stage (if it doesn’t already exist):
    CREATE STAGE IF NOT EXISTS SDK_STAGE;
    • Set a query tag with metadata for tracking and auditing:
    ALTER SESSION SET query_tag = '{
    "origin":"sf_sit-is",
    "name":"notebook_demo_pack",
    "version":{"major":1,"minor":0},
    "attributes":{"is_quickstart":0,"source":"sql","vignette":"import_package_stage"}
    }';
    • Optionally, remove any previously uploaded versions of the package from the stage to ensure that only the latest build is used:
    LIST @SDK_STAGE; -- view files
    REMOVE @SDK_STAGE/relationalai_gnns.zip; -- delete old package
  3. Upload the package to SDK_STAGE:
    • In the left navigation pane, go to Catalog -> Database Explorer.
    • Navigate to the target stage location, for example: RELATIONAL_AI_GNN > SDK_SCHEMA > Stages > SDK_STAGE.
    • In the stage view, click Files (top-right corner).
    • In the upload dialog, drag and drop the file relationalai_gnns.zip.
    • Click Upload to complete the process.
  1. Create Notebook

    • Go to https://app.snowflake.com.
    • Select Projects > Notebooks > + Notebook.
    • Insert a Name for the notebook.
    • In Notebook location choose the same database where the SDK has been uploaded.
    • In Runtime version choose a version that supports python 3.10 (or more).
  2. Load Python Packages

    The Predictive Reasoner Python SDK uses some Python packages. These packages need to be installed before a Notebook can run. To install such packages you should click on the top Packages and then type the name of each package in theAnaconda Packages search box and select the package. You should install the following packages:

    • numpy
    • tabulate
    • pydantic
    • sqlalchemy
    • python-graphviz
    • cryptography
    • pydot
    • certifi

    Finally, click Save.

  3. Load relationalai_gnns.zip Python Package

    Finally, you will need to install the relationalai_gnns.zip Python package that is needed to interface with the RelationalAI Native App. The process is somewhat similar with the regular Python packages that you just installed, except you will be clicking on the Stage Packages tab on top and specifying the path to the relationalai_gnns.zip package.

    The path needs to be fully qualified. For example @RELATIONAL_AI_GNN.SDK_SCHEMA.SDK_STAGE/relationalai_gnns.zip.

    The system checks whether the path contains a valid Python package and, if yes, a green check box appears. Click Import to import the relationalai_gnns.zip package into your notebook.