Configure compilation behavior
Use compilation settings to control how PyRel validates your model and query during the build step.
This guide shows how to set strict mode and soft error mode in raiconfig.yaml or Python code and how to confirm the loaded values in Model.config.
These settings affect compilation only.
They do not change connection setup or later job execution.
- You have access to a Snowflake account with the RelationalAI Native App installed. If you are unsure, contact your Snowflake administrator.
- You have a working PyRel installation. See Set Up Your Environment for instructions.
What compilation configuration covers
Section titled “What compilation configuration covers”This guide applies to the Build model and query step in the PyRel execution workflow:
When you run PyRel, it first compiles the model and query you wrote in Python. This includes your model definitions, any materialization requirements, and the query you want to run. During this step, PyRel translates that code into a form the backend can execute and can catch validation problems early, including type errors.
Use this table to choose which setting to change:
| Setting | Use it when |
|---|---|
| Strict mode | You want earlier, stricter validation during compilation. |
| Soft error mode | You want some type issues treated more leniently while you iterate. |
Enable or disable strict mode
Section titled “Enable or disable strict mode”Strict mode makes the PyRel compiler validate more aggressively during compilation. It is disabled by default. Enable it when you want earlier validation during compilation, such as in CI, tests, or production jobs.
When you enable strict mode, PyRel catches certain declaration and schema problems earlier:
- References to relationships that have not been declared yet raise immediately instead of relying on implicit relationship creation.
- Strict relationship field validation runs when relationships are defined.
Follow these steps:
-
Set
compiler.strictinraiconfig.yamlconnections:# ...compiler:strict: true -
Inspect the parsed config
from relationalai.semantics import Modelm = Model("MyModel")print(m.config.compiler.strict)A printed value of
Trueconfirms that PyRel loaded the strict-mode setting from your config.
Set compiler.strict using CompilerConfig or a plain Python dict.
These examples assume file discovery already provides a valid connection configuration.
Use one of the following approaches:
-
Set the value with a typed config class
from relationalai.config import CompilerConfig, create_configfrom relationalai.semantics import Modelcfg = create_config(compiler=CompilerConfig(strict=True))m = Model("MyModel", config=cfg)print(m.config.compiler.strict) -
Set the value with a dict
from relationalai.config import create_configfrom relationalai.semantics import Modelcfg = create_config(compiler={"strict": True})m = Model("MyModel", config=cfg)print(m.config.compiler.strict)
Enable or disable soft error mode
Section titled “Enable or disable soft error mode”Soft error mode treats compiler type errors as warnings instead of failures. It is disabled by default, so type errors fail compilation unless you turn it on. Enable it when you’re iterating quickly in notebooks or exploratory work and want compilation to continue while you fix types.
Do the following:
-
Set
compiler.soft_type_errorsinraiconfig.yamlconnections:# ...compiler:soft_type_errors: true -
Inspect the parsed config
from relationalai.semantics import Modelm = Model("MyModel")print(m.config.compiler.soft_type_errors)A printed value of
Trueconfirms that PyRel loaded the soft error mode setting from your config.
Set compiler.soft_type_errors using CompilerConfig or a plain Python dict.
These examples assume file discovery already provides a valid connection configuration.
Use one of the following approaches:
-
Set the value with a typed config class
from relationalai.config import CompilerConfig, create_configfrom relationalai.semantics import Modelcfg = create_config(compiler=CompilerConfig(soft_type_errors=True))m = Model("MyModel", config=cfg)print(m.config.compiler.soft_type_errors) -
Set the value with a dict
from relationalai.config import create_configfrom relationalai.semantics import Modelcfg = create_config(compiler={"soft_type_errors": True})m = Model("MyModel", config=cfg)print(m.config.compiler.soft_type_errors)