Running dbt locally
Assumes Prerequisites & setup is done — the venv exists, dbt debug passes.
Standard workflow
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 testsRun 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
| Flag | Effect |
|---|---|
--select model_name | Only that model |
--select model_name+ | That model and everything downstream of it |
--select +model_name | That model and everything upstream of it |
--select +model_name+ | Both directions |
--full-refresh | Rebuild an incremental model from scratch |
--vars '{"key": "value"}' | Pass runtime variables |
dbt run --select stg_stock_carsales+ --target stagingProject vars (dbt_project.yml)
| Var | Default | Purpose |
|---|---|---|
start_date | '2023-01-01' | Start date for incremental models |
exclude_test_data | false | Environment-specific filtering |
disable_run_results | true | Disables Elementary hooks |
disable_dbt_artifacts_autoupload | true | Disables 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.