# Configure compilation behavior

Compilation settings control how PyRel validates your model and query before submitting a job to the RelationalAI Native App.
This guide covers what compilation means in PyRel, the settings that affect it, and how to change those settings.

:::prereqs
- 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 [Start building with PyRel](/get-started/start-building-with-pyrel/index.md) for instructions.
:::

## What compilation configuration covers

This guide applies to the *Build model and query* step in the PyRel execution workflow:

```d2 inline layout=dagre theme=0 darkTheme=false pad=8 title="PyRel workflow"
direction: right

step1: { shape: rectangle; label: "1. Load and validate\nconfiguration" }
step2: {
   shape: rectangle
   label: "2. Build model\nand query"
   style.fill: "#FDE68A"
   style.stroke: "#B45309"
}
step3: { shape: rectangle; label: "3. Submit\nRelationalAI job" }
step4: { shape: rectangle; label: "4. Run job with\nreasoners" }
step5: { shape: rectangle; label: "5. Materialize\nresults" }

step1 -> step2
step2 -> step3
step3 -> step4
step4 -> step5
```

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                                                    |
| ------------------------------------------------------- | -------------------------------------------------------------- |
| [Dry-run mode](#enable-or-disable-dry-run-mode)         | You want to validate your model only without executing it.     |
| [Soft type errors](#enable-or-disable-soft-type-errors) | You want type errors treated more leniently while you iterate. |

## Enable or disable dry-run mode

Use dry-run mode when you want PyRel to only compile your model and/or query and not execute it.
It is disabled by default.

Select the tab for your preferred configuration method to see how to set it up.

**raiconfig.yaml**

1. **Set [`compiler.dry_run`](/api/python/latest/config/config_fields/compilerconfig_class/index.md#dry_run) in `raiconfig.yaml`**

   ```yaml
   connections:
     # ...

   compiler:
       dry_run: true
   ```

2. **Inspect the parsed config**

   :::note
   This check assumes your existing `raiconfig.yaml` already includes a valid connection configuration.
   If you define more than one connection, set `default_connection` so `Model` uses the intended config.
   See [Configure Snowflake authentication](/build/guides/configuration/snowflake-auth/index.md) for details on connection configuration.
   :::

   ```python
   from relationalai.semantics import Model

   m = Model("MyModel")

   print(m.config.compiler.dry_run)
   ```

   A printed value of `True` confirms that PyRel loaded the `dry_run` setting from your config.

**Programmatic**

Set `compiler.dry_run` with `CompilerConfig` or a plain Python dict.
These examples assume file discovery already provides a valid connection configuration.
Use one of the following approaches:

1. **Set the value with a typed config class**

   ```python
   from relationalai.config import CompilerConfig, create_config
   from relationalai.semantics import Model

   cfg = create_config(compiler=CompilerConfig(dry_run=True))
   m = Model("MyModel", config=cfg)

   print(m.config.compiler.dry_run)
   ```

2. **Set the value with a dict**

   ```python
   from relationalai.config import create_config
   from relationalai.semantics import Model

   cfg = create_config(compiler={"dry_run": True})
   m = Model("MyModel", config=cfg)

   print(m.config.compiler.dry_run)
   ```

:::related
- [Create configuration in code](/build/guides/configuration/programmatic/index.md)
- [CompilerConfig API reference](/api/python/latest/config/config_fields/compilerconfig_class/index.md)
:::

## Enable or disable soft type errors

Use soft type errors when you want PyRel to treat type errors more leniently while you iterate.
It is disabled by default, so compilation will fail on type errors unless you turn it on.

:::caution
Because PyRel stops enforcing type errors as failures, you can miss issues until later in your workflow.
Use this setting intentionally as a way to iterate faster while building your model, but turn it off to catch type errors before deploying production workflows.
:::

Select the tab for your preferred configuration method to see how to set it up.

**raiconfig.yaml**

1. **Set [`compiler.soft_type_errors`](/api/python/latest/config/config_fields/compilerconfig_class/index.md#soft_type_errors) in `raiconfig.yaml`**

   ```yaml
   connections:
     # ...

   compiler:
     soft_type_errors: true
   ```

2. **Inspect the parsed config**

   :::note
   This check assumes your existing `raiconfig.yaml` already includes a valid connection configuration.
   If you define more than one connection, set `default_connection` so `Model` uses the intended config.
   See [Configure Snowflake authentication](/build/guides/configuration/snowflake-auth/index.md) for details on connection configuration.
   :::

   ```python
   from relationalai.semantics import Model

   m = Model("MyModel")

   print(m.config.compiler.soft_type_errors)
   ```

   A printed value of `True` confirms that PyRel loaded the `soft_type_errors` setting from your config.

**Programmatic**

Set `compiler.soft_type_errors` with `CompilerConfig` or a plain Python dict.
These examples assume file discovery already provides a valid connection configuration.
Use one of the following approaches:

1. **Set the value with a typed config class**

   ```python
   from relationalai.config import CompilerConfig, create_config
   from relationalai.semantics import Model

   cfg = create_config(compiler=CompilerConfig(soft_type_errors=True))
   m = Model("MyModel", config=cfg)

   print(m.config.compiler.soft_type_errors)
   ```

2. **Set the value with a dict**

   ```python
   from relationalai.config import create_config
   from relationalai.semantics import Model

   cfg = create_config(compiler={"soft_type_errors": True})
   m = Model("MyModel", config=cfg)

   print(m.config.compiler.soft_type_errors)
   ```

:::related
- [Create configuration in code](/build/guides/configuration/programmatic/index.md)
- [CompilerConfig API reference](/api/python/latest/config/config_fields/compilerconfig_class/index.md)
:::
