Skip to content

config

relationalai

Load and manage PyRel configuration.

Most projects only need the create_config function:

  • Call create_config() with arguments to auto-discover and load configuration from common sources (for example raiconfig.yaml / raiconfig.yml).
  • Or pass keyword arguments to build a configuration in code.

This package re-exports the most commonly used config and connection classes so you can import from this package instead of importing from submodules like config or connections.

To load a config from a file, create a raiconfig.yaml in your project:

default_connection: sf
connections:
sf:
type: snowflake
authenticator: username_password
account: my_account
warehouse: my_warehouse
user: my_user
password: ${SNOWFLAKE_PASSWORD}

Then load it with create_config (searches upwards from the current working directory):

>>> from relationalai.config import create_config
>>> cfg = create_config()
>>> session = cfg.get_session(name="sf")

Profiles let you define named overrides (for example, dev vs prod) on top of a shared base config. Select which overlay to apply with active_profile.

default_connection: sf
connections:
sf:
type: snowflake
authenticator: username_password
account: my_account
warehouse: base_warehouse
user: my_user
password: ${SNOWFLAKE_PASSWORD}
profile:
dev:
connections:
sf:
warehouse: dev_warehouse
prod:
connections:
sf:
warehouse: prod_warehouse
active_profile: dev

When you load this config with create_config, the active_profile is applied on top of the base config so that Config.get_session creates a session using the overrides in the active profile.

You can also build a config programmatically by passing connection definitions as plain dictionaries. For example, to create a Snowflake connection config:

>>> from relationalai.config import create_config
>>> cfg = create_config(
... connections={
... "sf": {
... "type": "snowflake",
... "authenticator": "username_password",
... "account": "my_account",
... "warehouse": "my_warehouse",
... "user": "my_user",
... "password": "my_password",
... }
... }
... )

Alternatively, you can instantiate connection config classes and use them to build the config:

>>> from relationalai.config import create_config, UsernamePasswordAuth
>>> cfg = create_config(
... connections={
... "sf": UsernamePasswordAuth(
... account="my_account",
... warehouse="my_warehouse",
... user="my_user",
... password="my_password",
... )
... }
... )

See the config and connections submodules for more details on the available config and connection types.

  • If a raiconfig.yaml/raiconfig.yml is not found, create_config can fall back to other supported sources (Snowflake and DBT), converting them into the same validated config shape. See the create_config docs for details.

Attributes exposed by this module.

Functions exposed by this module.

Classes exposed by this module.

Submodules and subpackages available under this namespace.