# CLI Cortex Framework build

`uv run cortex-build` compiles Google Cloud Cortex Framework data foundation and
data product modules locally into `dist/`, performs build-input pre-flight
validation against Google Cloud without deploying Dataform repositories
or executing BigQuery transformations, and compiles and validates
declarative data quality assertions.

The command wipes and recreates the `--output-dir` directory on each run. While
build-only runs don't send deployment telemetry events, `uv run cortex-build`
initializes telemetry consent state and accepts `--disable-telemetry`. To
validate the compiled SQL dependency graph offline, run
[`uv run cortex-compile`](https://docs.cloud.google.com/cortex/docs/uv-run-cortex-compile.md.txt).

## Synopsis

```bash
uv run cortex-build [-h] \
    [-c CONFIG_PATH | --config CONFIG_PATH] \
    [--output-dir OUTPUT_DIR] \
    [--enable-apis] [--disable-telemetry] \
    [--assertions ASSERTIONS_FILE]
```

Replace the following:

- `CONFIG_PATH`: path to your global `config.yaml` file, for example: `config/config.yaml`.
- `OUTPUT_DIR`: path to the generated Dataform build output directory, for example: `dist`.
- `ASSERTIONS_FILE`: path to a standalone Dataform assertions file, for example: `assertions.sqlx`.

## Pre-flight validation scope

Before generating Dataform files, `uv run cortex-build` runs
build-input pre-flight checks (`validate_build_inputs`):

- **Required build-input APIs** : Verifies that `bigquery.googleapis.com` is enabled on source dataset projects, both `analyticshub.googleapis.com` and `bigquery.googleapis.com` are enabled on enabled BigQuery sharing catalog projects, and `biglake.googleapis.com` is enabled for enabled BigLake Delta Sharing catalogs.
- **Source datasets and locations** : Verifies that configured source BigQuery datasets exist and match `data.bigQueryLocation`.
- **BigQuery sharing linked datasets** : Verifies that enabled BigQuery sharing datasets exist, aren't unlinked, and match `data.bigQueryLocation`.

Target dataset validation and creation run during
[`uv run cortex-deploy`](https://docs.cloud.google.com/cortex/docs/uv-run-cortex-deploy.md.txt) or
[`uv run cortex-build-and-deploy`](https://docs.cloud.google.com/cortex/docs/uv-run-cortex-build-and-deploy.md.txt),
not during `uv run cortex-build`.

## Global flags

The following table describes all flags supported by `uv run cortex-build`:

| Flag | Description | Default |
| `-h, --help` | Show the command help message and exit. | None |
| `-c, --config CONFIG_PATH` | Path to the global [`config.yaml`](https://docs.cloud.google.com/cortex/docs/deployment-configuration.md.txt#config-config-yaml) configuration file. | `config/config.yaml` |
| `--output-dir OUTPUT_DIR` | Path to the directory where compiled Dataform artifacts are written. Existing contents in this directory are deleted and recreated on each run. | `dist` |
| `--enable-apis` | Enable required build-input Google Cloud APIs automatically without interactive prompts. | `false` |
| `--disable-telemetry` | Disable telemetry event logging and suppress the telemetry collection notice during the run. For more information, see [Cortex Framework telemetry](https://docs.cloud.google.com/cortex/docs/telemetry.md.txt). | `false` |
| `--assertions ASSERTIONS_FILE` | Path to a standalone Dataform assertions file (must be a file, copied into `<output_dir>/definitions/assertions/assertions.sqlx`). For table-level YAML assertions and `.sql` templates, see [Configure data quality assertions](https://docs.cloud.google.com/cortex/docs/data-quality-assertions.md.txt). | None |
| `--create-datasets` | **Deprecated (no-op; scheduled for removal in v8.0).** Passing this flag emits a deprecation warning and has no effect. Pass `--create-datasets` to [`uv run cortex-deploy`](https://docs.cloud.google.com/cortex/docs/uv-run-cortex-deploy.md.txt) or [`uv run cortex-build-and-deploy`](https://docs.cloud.google.com/cortex/docs/uv-run-cortex-build-and-deploy.md.txt) instead. | `false` |
|---|---|---|

## Examples

Build the Dataform package into `dist/`:

```bash
export CORTEX_CONFIG_FILE=config/config.yaml

uv run cortex-build --config $CORTEX_CONFIG_FILE
```

## What's next

- Verify the compiled Dataform graph offline with [`uv run cortex-compile`](https://docs.cloud.google.com/cortex/docs/uv-run-cortex-compile.md.txt).
- Deploy compiled artifacts with [`uv run cortex-deploy`](https://docs.cloud.google.com/cortex/docs/uv-run-cortex-deploy.md.txt).
- Configure table-level validation rules in [Data quality assertions](https://docs.cloud.google.com/cortex/docs/data-quality-assertions.md.txt).
- Review target settings in [Deployment configuration](https://docs.cloud.google.com/cortex/docs/deployment-configuration.md.txt).