Skip to content

relationalai.Config

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.

NameTypeDescription
profiledictDictionary of RAI configuration details.

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 values 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.

NameDescriptionReturns
.get()Get a configuration value.Any
.set()Set a configuration value.None
Config.get(name: str, default: Any|None = None, strict:bool = True) -> Any

Get a configuration parameter value.

NameTypeDescription
namestrThe name of the configuration parameter to get.
defaultAnyOptional default value to return if the configuration parameter is not found.
strictboolOptional flag to raise an error if the configuration parameter is not found and no default value is provided. (Default: True)

The value of the configuration parameter.

Use .get() to get the value of a configuration parameter:

import relationalai as rai
# Get the current configuration.
cfg = rai.Config()
# Get the configured engine name.
print(cfg.get("engine"))
# 'my_engine'

See Valid Profile Keys for a list of configuration parameters that can be retrieved using .get().

Config.set(name: str, value: Any) -> None

Set a configuration parameter value.

NameTypeDescription
namestrThe name of the configuration parameter to set.
valueAnyThe value to set the configuration parameter to.

None

Use .set() to set the value of a configuration parameter:

import relationalai as rai
# Get the current configuration.
cfg = rai.Config()
# Set the RAI engine name and size.
cfg.set("engine", "my_engine")
cfg.set("engine_size", "HIGHMEM_X64_M")
# Create a model with the new configuration.
model = rai.Model("MyModel", config=cfg)

Note that setting a value for a configuration key with .set() doesn’t edit the raiconfig.toml file. It only changes the value on the Config object for the current session.

See Valid Profile Keys for a list of configuration parameters.

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)