Modules Reference¶
Auto-generated API documentation for brix modules.
Profile Service¶
brix.modules.dbt.profile.service
¶
Profile management service for dbt profiles.yml.
Handles loading templates, validating profiles, and writing to disk.
ProfileConfig
¶
Bases: BaseSettings
Profile configuration from environment variables.
Environment variables
BRIX_DBT_PROFILE_PATH: Override default profile path
Source code in src/brix/modules/dbt/profile/service.py
ProfileExistsError
¶
ProfileInitResult
¶
Result of profile initialization.
Source code in src/brix/modules/dbt/profile/service.py
__init__(*, success, path, action, message)
¶
Initialize profile init result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
success
|
bool
|
Whether initialization succeeded |
required |
path
|
Path
|
Path to the profile file |
required |
action
|
Literal['created', 'overwritten', 'skipped']
|
What action was taken (created, overwritten, skipped) |
required |
message
|
str
|
Human-readable result message |
required |
Source code in src/brix/modules/dbt/profile/service.py
get_default_profile_path()
¶
Get the default profile path, checking env var first.
Returns:
| Type | Description |
|---|---|
Path
|
Path from BRIX_DBT_PROFILE_PATH env var, or ~/.dbt/profiles.yml |
Source code in src/brix/modules/dbt/profile/service.py
load_template(template_name='profiles.yml')
¶
Load and validate the bundled profile template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_name
|
str
|
Name of the template file |
'profiles.yml'
|
Returns:
| Type | Description |
|---|---|
tuple[str, DbtProfiles]
|
Tuple of (raw template content, validated DbtProfiles) |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If template doesn't exist |
ValueError
|
If template is invalid YAML or doesn't match schema |
Source code in src/brix/modules/dbt/profile/service.py
init_profile(profile_path=None, *, force=False, template_name='profiles.yml')
¶
Initialize a dbt profile from template.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profile_path
|
Path | None
|
Target path for profiles.yml (uses default if None) |
None
|
force
|
bool
|
Overwrite existing file if True |
False
|
template_name
|
str
|
Name of template to use |
'profiles.yml'
|
Returns:
| Type | Description |
|---|---|
ProfileInitResult
|
ProfileInitResult with success status and details |
Raises:
| Type | Description |
|---|---|
ProfileExistsError
|
If file exists and force is False |
FileNotFoundError
|
If template doesn't exist |
ValueError
|
If template validation fails |
Source code in src/brix/modules/dbt/profile/service.py
Profile Editor¶
brix.modules.dbt.profile.editor
¶
Profile editing service for dbt profiles.yml.
Provides CRUD operations for profiles and outputs with atomic save-on-change behavior.
ProfileNotFoundError
¶
OutputNotFoundError
¶
ProfileAlreadyExistsError
¶
OutputAlreadyExistsError
¶
load_profiles(path=None)
¶
Load profiles from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | None
|
Path to profiles.yml, uses default if None |
None
|
Returns:
| Type | Description |
|---|---|
DbtProfiles
|
Parsed DbtProfiles instance |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If file doesn't exist |
ValueError
|
If YAML is invalid |
Source code in src/brix/modules/dbt/profile/editor.py
save_profiles(profiles, path=None)
¶
Validate and save profiles to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance to save |
required |
path
|
Path | None
|
Path to profiles.yml, uses default if None |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If profiles fail validation |
IOError
|
If file cannot be written |
Source code in src/brix/modules/dbt/profile/editor.py
get_profile_names(profiles)
¶
Get list of profile names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of profile names |
get_output_names(profiles, profile_name)
¶
Get list of output names for a profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance |
required |
profile_name
|
str
|
Name of the profile |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of output names |
Raises:
| Type | Description |
|---|---|
ProfileNotFoundError
|
If profile doesn't exist |
Source code in src/brix/modules/dbt/profile/editor.py
add_profile(profiles, name, target, output_name, output_config)
¶
Add a new profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance |
required |
name
|
str
|
Profile name |
required |
target
|
str
|
Default target name |
required |
output_name
|
str
|
Initial output name |
required |
output_config
|
OutputConfig
|
Initial output configuration (DuckDbOutput or DatabricksOutput) |
required |
Returns:
| Type | Description |
|---|---|
DbtProfiles
|
Updated DbtProfiles instance |
Raises:
| Type | Description |
|---|---|
ProfileAlreadyExistsError
|
If profile already exists |
Source code in src/brix/modules/dbt/profile/editor.py
update_profile_target(profiles, name, target)
¶
Update a profile's default target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance |
required |
name
|
str
|
Profile name |
required |
target
|
str
|
New default target name |
required |
Returns:
| Type | Description |
|---|---|
DbtProfiles
|
Updated DbtProfiles instance |
Raises:
| Type | Description |
|---|---|
ProfileNotFoundError
|
If profile doesn't exist |
Source code in src/brix/modules/dbt/profile/editor.py
delete_profile(profiles, name)
¶
Delete a profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance |
required |
name
|
str
|
Profile name to delete |
required |
Returns:
| Type | Description |
|---|---|
DbtProfiles
|
Updated DbtProfiles instance |
Raises:
| Type | Description |
|---|---|
ProfileNotFoundError
|
If profile doesn't exist |
Source code in src/brix/modules/dbt/profile/editor.py
add_output(profiles, profile_name, output_name, output_config)
¶
Add an output to a profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance |
required |
profile_name
|
str
|
Name of the profile |
required |
output_name
|
str
|
Name for the new output |
required |
output_config
|
OutputConfig
|
Output configuration (DuckDbOutput or DatabricksOutput) |
required |
Returns:
| Type | Description |
|---|---|
DbtProfiles
|
Updated DbtProfiles instance |
Raises:
| Type | Description |
|---|---|
ProfileNotFoundError
|
If profile doesn't exist |
OutputAlreadyExistsError
|
If output already exists |
Source code in src/brix/modules/dbt/profile/editor.py
update_output(profiles, profile_name, output_name, *, path=None, threads=None)
¶
Update a DuckDB output's configuration (legacy interface).
For updating any adapter type, use update_output_fields() instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance |
required |
profile_name
|
str
|
Name of the profile |
required |
output_name
|
str
|
Name of the output |
required |
path
|
str | None
|
New path value (optional, DuckDB only) |
None
|
threads
|
int | None
|
New threads value (optional) |
None
|
Returns:
| Type | Description |
|---|---|
DbtProfiles
|
Updated DbtProfiles instance |
Raises:
| Type | Description |
|---|---|
ProfileNotFoundError
|
If profile doesn't exist |
OutputNotFoundError
|
If output doesn't exist |
ValueError
|
If threads is not a positive integer |
Source code in src/brix/modules/dbt/profile/editor.py
update_output_fields(profiles, profile_name, output_name, updates)
¶
Update an output's configuration with arbitrary field updates.
Works with any adapter type (DuckDB, Databricks, etc.).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance |
required |
profile_name
|
str
|
Name of the profile |
required |
output_name
|
str
|
Name of the output |
required |
updates
|
dict[str, Any]
|
Dictionary of field names to new values |
required |
Returns:
| Type | Description |
|---|---|
DbtProfiles
|
Updated DbtProfiles instance |
Raises:
| Type | Description |
|---|---|
ProfileNotFoundError
|
If profile doesn't exist |
OutputNotFoundError
|
If output doesn't exist |
ValueError
|
If validation fails (e.g., threads < 1) |
Source code in src/brix/modules/dbt/profile/editor.py
delete_output(profiles, profile_name, output_name)
¶
Delete an output from a profile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance |
required |
profile_name
|
str
|
Name of the profile |
required |
output_name
|
str
|
Name of the output to delete |
required |
Returns:
| Type | Description |
|---|---|
DbtProfiles
|
Updated DbtProfiles instance |
Raises:
| Type | Description |
|---|---|
ProfileNotFoundError
|
If profile doesn't exist |
OutputNotFoundError
|
If output doesn't exist |
ValueError
|
If this is the last output in the profile |
Source code in src/brix/modules/dbt/profile/editor.py
get_output(profiles, profile_name, output_name)
¶
Get an output configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
profiles
|
DbtProfiles
|
DbtProfiles instance |
required |
profile_name
|
str
|
Name of the profile |
required |
output_name
|
str
|
Name of the output |
required |
Returns:
| Type | Description |
|---|---|
OutputConfig
|
Output configuration (DuckDbOutput or DatabricksOutput) |
Raises:
| Type | Description |
|---|---|
ProfileNotFoundError
|
If profile doesn't exist |
OutputNotFoundError
|
If output doesn't exist |
Source code in src/brix/modules/dbt/profile/editor.py
Project Service¶
brix.modules.dbt.project.service
¶
Project management service for dbt projects.
Handles project initialization, path resolution, and package version fetching.
ProjectConfig
¶
Bases: BaseSettings
Project configuration from environment variables.
Environment variables
BRIX_DBT_PROJECT_BASE_DIR: Default base directory for projects
Source code in src/brix/modules/dbt/project/service.py
ProjectExistsError
¶
ProjectInitResult
dataclass
¶
Result of project initialization.
Source code in src/brix/modules/dbt/project/service.py
resolve_project_path(project_name, base_dir=None, team=None)
¶
Resolve the final project path from components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str
|
Name of the project (becomes directory name) |
required |
base_dir
|
Path | None
|
Base directory (uses env var or cwd if None) |
None
|
team
|
str | None
|
Optional team subdirectory |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
Resolved absolute path to project directory |
Example
resolve_project_path("my_project") PosixPath('/current/dir/my_project') resolve_project_path("my_project", Path("assets/dbt_projects"), "analytics") PosixPath('/current/dir/assets/dbt_projects/analytics/my_project')
Source code in src/brix/modules/dbt/project/service.py
fetch_package_version(package)
¶
Fetch the latest version of a package from dbt Hub.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str
|
Package name (e.g., "dbt-labs/dbt_utils") |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Version string (e.g., ">=1.3.0") or None if fetch fails |
Source code in src/brix/modules/dbt/project/service.py
get_package_version(package)
¶
Get the version for a package, with fallback to defaults.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str
|
Package name (e.g., "dbt-labs/dbt_utils") |
required |
Returns:
| Type | Description |
|---|---|
str
|
Version string (e.g., ">=1.0.0") |
Source code in src/brix/modules/dbt/project/service.py
fetch_package_versions_parallel(pkg_names, max_workers=5)
¶
Fetch multiple package versions in parallel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pkg_names
|
list[str]
|
List of package names (e.g., ["dbt-labs/dbt_utils", "elementary-data/elementary"]) |
required |
max_workers
|
int
|
Maximum number of concurrent threads |
5
|
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
Dictionary mapping package names to version strings |
Source code in src/brix/modules/dbt/project/service.py
create_project_structure(project_path, project_name, profile_name, *, packages=None, materialization=None, persist_docs=False, with_example=False)
¶
Create the dbt project directory structure and files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path
|
Path
|
Path to create project in |
required |
project_name
|
str
|
Name of the project |
required |
profile_name
|
str
|
Name of the profile to use |
required |
packages
|
list[HubPackage] | None
|
List of packages to include (uses template default if None) |
None
|
materialization
|
str | None
|
Default materialization (view, table, ephemeral) |
None
|
persist_docs
|
bool
|
Whether to enable persist_docs for Databricks |
False
|
with_example
|
bool
|
Whether to create example model |
False
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of created file paths (relative to project_path) |
Source code in src/brix/modules/dbt/project/service.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
init_project(project_name, profile_name, base_dir=None, team=None, *, packages=None, materialization=None, persist_docs=False, with_example=False, force=False)
¶
Initialize a new dbt project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_name
|
str
|
Name of the project |
required |
profile_name
|
str
|
Name of the profile to use |
required |
base_dir
|
Path | None
|
Base directory for project (uses env var or cwd if None) |
None
|
team
|
str | None
|
Optional team subdirectory |
None
|
packages
|
list[HubPackage] | None
|
List of packages to include |
None
|
materialization
|
str | None
|
Default materialization (view, table, ephemeral) |
None
|
persist_docs
|
bool
|
Whether to enable persist_docs for Databricks |
False
|
with_example
|
bool
|
Whether to create example model |
False
|
force
|
bool
|
Overwrite existing project if True |
False
|
Returns:
| Type | Description |
|---|---|
ProjectInitResult
|
ProjectInitResult with success status and details |
Raises:
| Type | Description |
|---|---|
ProjectExistsError
|
If project exists and force is False |
ProjectNameError
|
If project name is invalid |
Source code in src/brix/modules/dbt/project/service.py
Project Editor¶
brix.modules.dbt.project.editor
¶
Project editing service for dbt projects.
Provides CRUD operations for dbt_project.yml and packages.yml with atomic save-on-change behavior.
ProjectNotFoundError
¶
PackageNotFoundError
¶
PackageAlreadyExistsError
¶
InvalidFieldError
¶
load_project(path)
¶
Load dbt_project.yml from disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
Path to dbt_project.yml file |
required |
Returns:
| Type | Description |
|---|---|
DbtProject
|
Parsed DbtProject instance |
Raises:
| Type | Description |
|---|---|
ProjectNotFoundError
|
If file doesn't exist |
ValueError
|
If YAML is invalid |
Source code in src/brix/modules/dbt/project/editor.py
save_project(project, path)
¶
Validate and save dbt_project.yml to disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
DbtProject
|
DbtProject instance to save |
required |
path
|
Path
|
Path to dbt_project.yml file |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If project fails validation |
IOError
|
If file cannot be written |
Source code in src/brix/modules/dbt/project/editor.py
load_packages(project_dir)
¶
Load packages.yml from project directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_dir
|
Path
|
Path to project directory (or dbt_project.yml file) |
required |
Returns:
| Type | Description |
|---|---|
DbtPackages
|
Parsed DbtPackages instance (empty if file doesn't exist) |
Source code in src/brix/modules/dbt/project/editor.py
save_packages(packages, project_dir)
¶
Save packages.yml to project directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
DbtPackages
|
DbtPackages instance to save |
required |
project_dir
|
Path
|
Path to project directory (or dbt_project.yml file) |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If packages fail validation |
IOError
|
If file cannot be written |
Source code in src/brix/modules/dbt/project/editor.py
update_project_field(project, field, value)
¶
Update a single project field.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
DbtProject
|
DbtProject instance |
required |
field
|
str
|
Field name to update |
required |
value
|
str | None
|
New value for the field |
required |
Returns:
| Type | Description |
|---|---|
DbtProject
|
Updated DbtProject instance |
Raises:
| Type | Description |
|---|---|
InvalidFieldError
|
If field is not editable |
ValueError
|
If value fails validation (e.g., invalid project name) |
Source code in src/brix/modules/dbt/project/editor.py
update_path_field(project, field, action, value)
¶
Update a path list field (add/remove/set).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
DbtProject
|
DbtProject instance |
required |
field
|
str
|
Field name (model_paths, seed_paths, etc.) |
required |
action
|
Literal['add', 'remove', 'set']
|
Operation to perform |
required |
value
|
str | list[str]
|
Path(s) to add/remove, or full list for "set" |
required |
Returns:
| Type | Description |
|---|---|
DbtProject
|
Updated DbtProject instance |
Raises:
| Type | Description |
|---|---|
InvalidFieldError
|
If field is not a path field |
ValueError
|
If action is invalid or path not found for remove |
Source code in src/brix/modules/dbt/project/editor.py
get_package_identifiers(packages)
¶
Get list of all package identifiers for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
DbtPackages
|
DbtPackages instance |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
List of package identifiers |
Source code in src/brix/modules/dbt/project/editor.py
find_package_index(packages, identifier)
¶
Find package index by identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
DbtPackages
|
DbtPackages instance |
required |
identifier
|
str
|
Package name (hub), git URL, or local path |
required |
Returns:
| Type | Description |
|---|---|
int | None
|
Index of package or None if not found |
Source code in src/brix/modules/dbt/project/editor.py
has_package(packages, identifier)
¶
Check if package exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
DbtPackages
|
DbtPackages instance |
required |
identifier
|
str
|
Package identifier |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if package exists |
Source code in src/brix/modules/dbt/project/editor.py
add_hub_package(packages, package_name, version)
¶
Add a hub package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
DbtPackages
|
DbtPackages instance |
required |
package_name
|
str
|
Package name (e.g., "dbt-labs/dbt_utils") |
required |
version
|
str
|
Version specifier (e.g., ">=1.0.0") |
required |
Returns:
| Type | Description |
|---|---|
DbtPackages
|
Updated DbtPackages instance |
Raises:
| Type | Description |
|---|---|
PackageAlreadyExistsError
|
If package already exists |
Source code in src/brix/modules/dbt/project/editor.py
add_git_package(packages, git_url, revision, subdirectory=None)
¶
Add a git package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
DbtPackages
|
DbtPackages instance |
required |
git_url
|
str
|
Git repository URL |
required |
revision
|
str
|
Branch, tag, or commit hash |
required |
subdirectory
|
str | None
|
Optional subdirectory within repo |
None
|
Returns:
| Type | Description |
|---|---|
DbtPackages
|
Updated DbtPackages instance |
Raises:
| Type | Description |
|---|---|
PackageAlreadyExistsError
|
If package already exists |
Source code in src/brix/modules/dbt/project/editor.py
add_local_package(packages, local_path)
¶
Add a local package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
DbtPackages
|
DbtPackages instance |
required |
local_path
|
str
|
Local filesystem path |
required |
Returns:
| Type | Description |
|---|---|
DbtPackages
|
Updated DbtPackages instance |
Raises:
| Type | Description |
|---|---|
PackageAlreadyExistsError
|
If package already exists |
Source code in src/brix/modules/dbt/project/editor.py
remove_package(packages, identifier)
¶
Remove a package by its identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
DbtPackages
|
DbtPackages instance |
required |
identifier
|
str
|
Package name, git URL, or local path |
required |
Returns:
| Type | Description |
|---|---|
DbtPackages
|
Updated DbtPackages instance |
Raises:
| Type | Description |
|---|---|
PackageNotFoundError
|
If package not found |
Source code in src/brix/modules/dbt/project/editor.py
update_package_version(packages, package_name, new_version)
¶
Update a hub package version.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
DbtPackages
|
DbtPackages instance |
required |
package_name
|
str
|
Package name (must be a hub package) |
required |
new_version
|
str
|
New version specifier |
required |
Returns:
| Type | Description |
|---|---|
DbtPackages
|
Updated DbtPackages instance |
Raises:
| Type | Description |
|---|---|
PackageNotFoundError
|
If package not found |
ValueError
|
If package is not a hub package |
Source code in src/brix/modules/dbt/project/editor.py
get_package_display_info(packages)
¶
Get package information for display.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
packages
|
DbtPackages
|
DbtPackages instance |
required |
Returns:
| Type | Description |
|---|---|
list[tuple[str, str]]
|
List of (identifier, type_info) tuples for display |
Source code in src/brix/modules/dbt/project/editor.py
Project Finder¶
brix.modules.dbt.project.finder
¶
Project discovery service for dbt projects.
Provides functions to find dbt_project.yml files in a directory tree with interactive fuzzy selection support.
get_search_root()
¶
Get the search root directory.
Returns git repository root if in a git repo, otherwise current working directory.
Returns:
| Type | Description |
|---|---|
Path
|
Path to search root directory |
Source code in src/brix/modules/dbt/project/finder.py
find_dbt_projects(root=None, max_depth=10)
¶
Find all dbt_project.yml files under root directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path | None
|
Search root (uses get_search_root() if None) |
None
|
max_depth
|
int
|
Maximum directory depth to search (default 10) |
10
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
List of absolute paths to dbt_project.yml files, sorted by path |
Source code in src/brix/modules/dbt/project/finder.py
prompt_select_project(projects, search_root=None)
¶
Interactive project selection with fuzzy autocomplete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
projects
|
list[Path]
|
List of dbt_project.yml paths |
required |
search_root
|
Path | None
|
Root directory for relative path display (uses get_search_root() if None) |
None
|
Returns:
| Type | Description |
|---|---|
Path | None
|
Selected project path, or None if cancelled |
Source code in src/brix/modules/dbt/project/finder.py
discover_and_select_project(root=None, max_depth=10)
¶
Combined discovery and selection flow.
Finds dbt projects in the directory tree, prompts user to select one, and loads the selected project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path | None
|
Search root (uses get_search_root() if None) |
None
|
max_depth
|
int
|
Maximum directory depth to search |
10
|
Returns:
| Type | Description |
|---|---|
tuple[Path, DbtProject] | None
|
Tuple of (project_path, loaded DbtProject) or None if cancelled/not found |
Source code in src/brix/modules/dbt/project/finder.py
dbt Passthrough¶
brix.modules.dbt.passthrough
¶
dbt module - business logic for dbt operations.
DbtNotFoundError
¶
ProjectPathCache
¶
CachedPathNotFoundError
¶
load_project_cache()
¶
Load cached project path.
Returns:
| Type | Description |
|---|---|
Path | None
|
Cached project path if valid, None otherwise. |
Raises:
| Type | Description |
|---|---|
CachedPathNotFoundError
|
If cached path no longer exists or is not a directory. |
Source code in src/brix/modules/dbt/passthrough.py
save_project_cache(project_path)
¶
Save project path to cache.
Converts relative paths to absolute before saving.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path
|
Path
|
The project path to cache. |
required |
Source code in src/brix/modules/dbt/passthrough.py
find_dbt_executable()
¶
Find the dbt executable path.
This function handles two scenarios: 1. brix is installed in the same venv as dbt - dbt should be directly available 2. brix is installed as a global tool - need to discover project venv with dbt
Returns:
| Type | Description |
|---|---|
str
|
Path to the dbt executable. |
Raises:
| Type | Description |
|---|---|
DbtNotFoundError
|
If dbt cannot be found. |
Source code in src/brix/modules/dbt/passthrough.py
pre_dbt_hook()
¶
Hook for setup before running dbt. Placeholder for future logic.
run_dbt(args, project_path=None)
¶
Run dbt with the given arguments and return exit code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
list[str]
|
List of arguments to pass to dbt. |
required |
project_path
|
Path | None
|
Optional directory to run dbt in. |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Exit code from the dbt process (1 if dbt not found or invalid project path). |
Source code in src/brix/modules/dbt/passthrough.py
Logging¶
brix.utils.logging
¶
Terraform-style logging system for brix CLI.
Environment variables
BRIX_LOG: Log level (TRACE, DEBUG, INFO, WARN, ERROR, OFF) BRIX_LOG_PATH: File path for log output BRIX_LOG_JSON: Enable JSON format (true/false)
Logging convention: Use %-formatting for logger calls (lazy evaluation), f-strings elsewhere. This is Python logging best practice.
LogLevel
¶
Bases: IntEnum
Log levels matching Terraform's TF_LOG.
Custom TRACE level added below DEBUG (Python's DEBUG=10).
Source code in src/brix/utils/logging.py
LogConfig
¶
Bases: BaseSettings
Logging configuration from environment variables.
Environment variables
BRIX_LOG: Log level (TRACE, DEBUG, INFO, WARN, ERROR, OFF) BRIX_LOG_PATH: File path for log output BRIX_LOG_JSON: Enable JSON format (true/false)
Source code in src/brix/utils/logging.py
normalize_log_level(v)
classmethod
¶
Normalize log level to uppercase.
Source code in src/brix/utils/logging.py
BrixFormatter
¶
Bases: Formatter
Human-readable log formatter for console output.
Format: [2024-01-15T10:30:45Z] [DEBUG] message
Source code in src/brix/utils/logging.py
format(record)
¶
Format the log record as human-readable text.
Source code in src/brix/utils/logging.py
BrixJsonFormatter
¶
Bases: Formatter
JSON log formatter for file output and machine parsing.
Output: {"@timestamp": "...", "@level": "DEBUG", "@message": "...", "@module": "..."}
Source code in src/brix/utils/logging.py
format(record)
¶
Format the log record as JSON.
Source code in src/brix/utils/logging.py
setup_logging(level=None, log_path=None, json_format=None)
¶
Initialize the brix logger with config from env and CLI overrides.
CLI arguments override environment variables. Thread-safe initialization with singleton pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str | None
|
CLI override for BRIX_LOG |
None
|
log_path
|
Path | None
|
CLI override for BRIX_LOG_PATH |
None
|
json_format
|
bool | None
|
CLI override for BRIX_LOG_JSON |
None
|
Returns:
| Type | Description |
|---|---|
Logger
|
Configured logger instance |
Source code in src/brix/utils/logging.py
get_logger()
¶
Get the brix logger (initializes with defaults if needed).
For use throughout the codebase.