Config#

relationalai
#class Config(profile: dict)

The Config class is used to get and set configuration parameters for your RAI Model. Call Config() without parameters to get an object representing the current configuration, or pass a dictionary of configuration keys and values to change one or more parameters.

Parameters#

NameTypeDescription
profiledictDictionary of RAI configuration details.

Valid Profile Keys#

KeyRequiredDescription
"account"YesThe Snowflake account name to use.
"role"The Snowflake role to use. (Default: "PUBLIC")
"warehouse"YesThe Snowflake warehouse to use.
"rai_app_name"The name of the RAI Native App to use. (Default: "relationalai")
"authenticator"The Snowflake authentication method to use. Must be one of:
  • "snowflake" (Default)
    • Connect via username/password.
    • Requires the "user" and "password" keys.
  • "username_password_mfa"
    • Connect via username/password with multi-factor authentication.
    • Requires the "user" and "password" keys.
  • "externalbrowser"
    • Connect in an external browser window by typing your credentials or using single sign-on (SSO).
"user"The Snowflake username to use for authentication.
"password"The Snowflake password to use for authentication.
"engine"The name of the RAI engine to use. If missing, an engine of size "engine_size" is created automatically using your Snowflake username as the engine name.
"engine_size"The engine size to use when creating an engine. (Default: "HIGHMEM_X64_S")
"debug"Whether to generate debug logs for use with the RAI debugger. (Default: True)
"debug.host"The host name to use for the RAI debugger. (Default: "localhost")
"debug.port"The port number to use for the RAI debugger. (Default: 8080)

Methods#

NameDescriptionReturns
.get()Get a configuration value.Any
.set()Set a configuration value.None

Example#

Get a Config object that represents the current configuration:

#import relationalai as rai

# Get the current configuration. If you have a raiconfig.toml file, the Config object
# reflects the values contained in the active profile.
cfg = rai.Config()

Use .get() and .set() to get and set configuration values:

## Get the name of the currently configured RAI engine.
engine_name = cfg.get("engine")

# Configure a new engine name. Note that this doesn't edit the raiconfig.toml file.
# It only changes the engine name on the Config object.
cfg.set("engine", "my_new_engine")

You can also set configuration values by passing a dictionary of configuration keys and avlues to the Config() constructor:

## Create a Config object with a custom engine name and size.
cfg = rai.Config({
    "engine": "my_custom_engine",
    "engine_size": "HIGHMEM_X64_M",
})

# Pass the Config object to the Model constructor.
model = rai.Model("MyModel", config=cfg)

Any required configuration keys that are missing are read from the raiconfig.toml file’s active profile or, if the key is also missing from the profile, fall back to the default value.

As a consequence, you can use the Config() constructor to use RAI without a raiconfig.toml file by providing all the required configuration keys in the dictionary:

## Create a Config object using the default username/password authenticator and
# use it to create a model with a raiconfig.toml file.
cfg = rai.Config({
    "user": "<SNOWFLAKE_USER>",
    "password": "<SNOWFLAKE_PASSWORD>",
    "account": "<SNOWFLAKE_ACCOUNT>",
    "role": "<SNOWFLAKE_ROLE>",
    "warehouse": "<SNOWFLAKE_WAREHOUSE>",
})
model = rai.Model("MyModel", config=cfg)

See the configuration guide for more information on configuring your model’s connection to the RAI Native App.

See Also#