Model Selection¶
When working with a project that has many models, you often want to run only a subset. smelt provides --select and --exclude flags to control which models are included in a run.
These flags are available on smelt run, smelt build, and smelt explain.
Selection syntax¶
By name¶
Select a single model by its name:
By tag¶
Select all models with a given tag:
Tags are assigned in smelt.yml or in YAML frontmatter:
Include upstream dependencies¶
Prefix with + to include the selected model(s) and all their upstream dependencies:
This ensures that every model daily_revenue depends on is also run, in the correct order.
Include downstream dependents¶
Suffix with + to include the selected model(s) and everything that depends on them:
Include both upstream and downstream¶
Combine the prefix and suffix:
This selects daily_revenue, all its upstream dependencies, and all its downstream dependents.
Multiple selectors¶
The --select flag is repeatable. All selectors are combined (union):
Short form with -s:
Excluding models¶
The --exclude flag uses the same syntax as --select but removes models from the selection:
Exclusions are applied after selections. If you use --select and --exclude together, smelt first builds the selected set, then removes the excluded models.
Practical examples¶
Run a single model¶
Run a model and all its dependencies¶
Run everything downstream of staging¶
Run everything except expensive models¶
Run a specific model with dependencies, excluding one branch¶
Explain selected models¶
How selection works¶
- If no
--selectflags are provided, all models are included. - Each
--selectflag adds models to the set. The+prefix/suffix expands the set by walking the dependency graph. - Each
--excludeflag removes models from the set, using the same expansion rules. - The final set is executed in topological order (dependencies first).
Tip
During development, use --select +model_name to run just the model you are working on along with its dependencies. This is much faster than running the entire project.
Further reading¶
- Incremental Models for combining selection with time ranges
- SQL Models for setting tags in YAML frontmatter