Using the RelationalAI Predictive Reasoner in a Snowflake Notebook
Get Access to the RelationalAI Native App
Section titled “Get Access to the RelationalAI Native App”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.
Set up Notebook
Section titled “Set up Notebook”-
Create Notebook
- Go to https://app.snowflake.com.
- Navigate to
Projects > Notebooksand click+ Notebook. - Enter a
Namefor the notebook. - In
Notebook location, choose the database and schema where the notebook will be stored. - In
Runtime, selectRun on container. - In
Runtime version, choose GPU for faster model training. Otherwise, choose CPU. - Select a
Compute pool, which will run the Python commands in the notebook. - Select a
Query warehouse, which will execute the SQL queries from the notebook.
-
Configure External Access
Click the menu button in the top-right corner and select
Notebook settings. In theExternal accesssection, enablePYPI_ACCESS_INTEGRATIONand clickSave. This allows the notebook to usepipto install external Python packages from PyPI. -
Install the
relationalai_gnnsPackageClick
Startto launch the notebook kernel. Therelationalai_gnnsPython package is required to interact with the RelationalAI Native App. In the first cell of the notebook, run:!pip install relationalai-gnns
Install Graphviz for Schema Diagrams
Section titled “Install Graphviz for Schema Diagrams”.visualize_dataset() renders diagrams using the Graphviz dot binary, which isn’t included
in the notebook’s container by default. To enable it:
-
Create a network rule and external access integration for the Ubuntu package mirrors:
CREATE OR REPLACE NETWORK RULE apt_network_ruleMODE = EGRESSTYPE = HOST_PORTVALUE_LIST = ('archive.ubuntu.com:80', 'archive.ubuntu.com:443','security.ubuntu.com:80', 'security.ubuntu.com:443','ports.ubuntu.com:80', 'ports.ubuntu.com:443');CREATE OR REPLACE EXTERNAL ACCESS INTEGRATION apt_access_integrationALLOWED_NETWORK_RULES = (apt_network_rule)ENABLED = TRUE;GRANT USAGE ON INTEGRATION apt_access_integration TO ROLE <ROLE>;Grant
USAGEto whichever role the notebook actually runs as — check withDESC NOTEBOOK <DATABASE>.<SCHEMA>.<NOTEBOOK_NAME>if you’re not sure. -
Attach the integration to the notebook:
ALTER NOTEBOOK <DATABASE>.<SCHEMA>.<NOTEBOOK_NAME>SET EXTERNAL_ACCESS_INTEGRATIONS = (apt_access_integration); -
Install
graphvizfrom a Python cell:!apt-get update && apt-get install -y graphviz