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.
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
profile | dict | Dictionary of RAI configuration details. |
Example
Section titled “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 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.
Methods
Section titled “Methods”.get()
Section titled “.get()”Config.get(name: str, default: Any|None = None, strict:bool = True) -> Any
Get a configuration parameter value.
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
name | str | The name of the configuration parameter to get. |
default | Any | Optional default value to return if the configuration parameter is not found. |
strict | bool | Optional flag to raise an error if the configuration parameter is not found and no default value is provided. (Default: True ) |
Returns
Section titled “Returns”The value of the configuration parameter.
Example
Section titled “Example”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()
.
.set()
Section titled “.set()”Config.set(name: str, value: Any) -> None
Set a configuration parameter value.
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
name | str | The name of the configuration parameter to set. |
value | Any | The value to set the configuration parameter to. |
Returns
Section titled “Returns”None
Example
Section titled “Example”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.
Valid Profile Keys
Section titled “Valid Profile Keys”Key | Required | Description |
---|---|---|
"account" | Yes | The Snowflake account name to use. |
"role" | The Snowflake role to use. (Default: "PUBLIC" ) | |
"warehouse" | Yes | The 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:
| |
"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 ) |