Running dbt locally

Assumes Prerequisites & setup is done — the venv exists, dbt debug passes.

Standard workflow

snippet.bashbash
cd src/stock/dbt   # or src/redbook/dbt
source venv/bin/activate

dbt compile --target staging   # check for syntax errors
dbt run --target staging       # execute models
dbt seed --target staging      # load reference CSVs
dbt test --target staging      # run data quality + unit tests

Run in that order. compile catches syntax errors before you spend time on a run; seed and test only make sense once the models they depend on exist.

Targeting specific models

FlagEffect
--select model_nameOnly that model
--select model_name+That model and everything downstream of it
--select +model_nameThat model and everything upstream of it
--select +model_name+Both directions
--full-refreshRebuild an incremental model from scratch
--vars '{"key": "value"}'Pass runtime variables
snippet.bashbash
dbt run --select stg_stock_carsales+ --target staging

Project vars (dbt_project.yml)

VarDefaultPurpose
start_date'2023-01-01'Start date for incremental models
exclude_test_datafalseEnvironment-specific filtering
disable_run_resultstrueDisables Elementary hooks
disable_dbt_artifacts_autouploadtrueDisables Elementary hooks

Stock-specific feature flags (passed via --vars, not project defaults): bypass_active_dealer_check, skip_colour_api — covered in the Stock Pipeline section once it's written.

Production

Same commands with --target prod, after activating DRIVE_PROD_DBT_KEY_PATH instead of the staging key. Add --full-refresh deliberately — it's destructive on incremental models (stock's full-refresh resets deactivated_at/is_sold, per the Makefile's own warning on dbt-full-refresh-stock).

Makefile shortcuts

The commands above are also wrapped as make targets (make dbt-run-stock, make dbt-run-stock-prod, etc.) — see Makefile command reference for the full list.

See also

Esc