Provider#
relationalai
#class Provider(
profile: str|None = None,
config: Config|None = None,
connection: Session|None = None
)
The Provider
class is used to manage the RAI Native App from Python.
It provides methods corresponding to SQL procedures and RAI CLI commands.
Parameters#
Name | Type | Description |
---|---|---|
profile | str | Optional name of the raiconfig.toml profile to use when creating the model. If None , the active raiconfig.toml profile is used. |
config | Config | Optional configuration object to use when creating the model. If None , configuration details provided by the profile and connection parameters are used. |
connection | Session | Optional Snowpark Session object to use when creating the model. If None , connection details provided by the profile or config parameters are used. |
Methods#
Name | Description | Returns |
---|---|---|
.activate() | Activate the RAI Native App. | None |
.create_streams() | Create streams in a model. | None |
.deactivate() | Deactivate the RAI Native App. | None |
.delete_stream() | Delete a stream in a model. | None |
.list_streams() | List all streams in a model. | list[dict] |
.sql() | Execute a SQL query. | Snowpark DataFrame |
Example#
By default, Provider
uses the active profile in your raiconfig.toml
file:
#import relationalai as rai
# Create a Provider object using the active raiconfig.toml profile.
app = rai.Provider()
# Create a Provider object using a specific raiconfig.toml profile.
app = rai.Provider(profile="<profile_name>")
If you are not using a raiconfig.toml
file, you can provide configuration details directly to the Provider
object by passing a Config
object or a Snowpark Session
object to the config
or connection
parameter, respectively:
## Create a Provider object using a Config object instead of a raiconfig.toml file.
config = rai.Config({
"platform": "snowflake",
"authenticator": "snowflake",
"account": "<SNOWFLAKE_ACCOUNT>",
"user": "<SNOWFLAKE_USER>",
"password": "<SNOWFLAKE_PASSWORD>",
"role": "<SNOWFLAKE_ROLE>",
"warehouse": "<SNOWFLAKE_WAREHOUSE>",
})
app = rai.Provider(config=config)
# Create a Provider object using a Snowpark Session object.
from snowflake.snowpark import Session
connection_params = {
"account": "<SNOWFLAKE_ACCOUNT>",
"user": "<SNOWFLAKE_USER>",
"password": "<SNOWFLAKE_PASSWORD>",
"role": "<SNOWFLAKE_ROLE>",
"warehouse": "<SNOWFLAKE_WAREHOUSE>",
}
session = Session.builder.configs(connection_params).create()
app = rai.Provider(connection=session)
Using a Session
object is useful when you need to authenticate with Snowflake using a method other than a username and password, such as SSH.
See the Snowpark docs for more information on creating Session
objects.