2025-02-06 05:05:12 +08:00
# Buster CLI
2024-11-26 02:46:48 +08:00
2025-02-06 05:05:12 +08:00
A powerful command-line interface for managing semantic models in Buster. Deploy and manage your data models with ease, whether they're standalone or part of a dbt project.
2024-11-26 02:46:48 +08:00
2025-02-13 01:00:26 +08:00
## Installation
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
Choose the installation command for your operating system:
2024-11-26 02:46:48 +08:00
2025-02-13 01:00:26 +08:00
### macOS (x86_64)
```bash
2025-02-13 05:52:17 +08:00
mkdir -p ~/.local/bin & & curl -L https://github.com/buster-so/buster/releases/latest/download/buster-cli-darwin-x86_64.tar.gz | tar xz & & mv buster-cli ~/.local/bin/buster & & chmod +x ~/.local/bin/buster
2025-02-13 05:08:01 +08:00
```
### macOS (ARM/Apple Silicon)
```bash
2025-02-13 05:52:17 +08:00
mkdir -p ~/.local/bin & & curl -L https://github.com/buster-so/buster/releases/latest/download/buster-cli-darwin-arm64.tar.gz | tar xz & & mv buster-cli ~/.local/bin/buster & & chmod +x ~/.local/bin/buster
2025-02-13 01:00:26 +08:00
```
### Linux (x86_64)
```bash
2025-02-13 05:52:17 +08:00
mkdir -p ~/.local/bin & & curl -L https://github.com/buster-so/buster/releases/latest/download/buster-cli-linux-x86_64.tar.gz | tar xz & & mv buster-cli ~/.local/bin/buster & & chmod +x ~/.local/bin/buster
2025-02-13 01:00:26 +08:00
```
2025-02-13 05:08:01 +08:00
> **Note**: After installation, make sure `~/.local/bin` is in your PATH. Add this to your shell's config file (`.bashrc`, `.zshrc`, etc.):
> ```bash
> export PATH="$HOME/.local/bin:$PATH"
> ```
2025-02-13 01:00:26 +08:00
### Windows (x86_64)
1. Download the Windows binary:
```powershell
2025-02-13 05:52:17 +08:00
Invoke-WebRequest -Uri https://github.com/buster-so/buster/releases/latest/download/buster-cli-windows-x86_64.zip -OutFile buster.zip
2025-02-13 01:00:26 +08:00
```
2. Extract and install:
```powershell
Expand-Archive -Path buster.zip -DestinationPath $env:USERPROFILE\buster
Move-Item -Path $env:USERPROFILE\buster\buster-cli.exe -Destination $env:LOCALAPPDATA\Microsoft\WindowsApps\buster.exe
```
## Quick Start Guide
### 1. Authentication
First, authenticate with Buster using your API key:
2024-11-26 02:46:48 +08:00
2025-02-06 05:05:12 +08:00
```bash
2025-02-13 01:00:26 +08:00
buster auth
2025-02-06 05:05:12 +08:00
```
2024-11-26 02:46:48 +08:00
2025-02-13 01:00:26 +08:00
This will prompt you for:
- API Key (required) - Get this from the Buster Platform
- Host (optional) - Defaults to production if not specified
2025-02-13 05:02:20 +08:00
You can also configure authentication using environment variables:
```bash
# Set API key via environment variable
export BUSTER_API_KEY=your_api_key_here
# Optional: Set custom host. For self-hosted instances.
export BUSTER_HOST=your_custom_host
```
The CLI will check for these environment variables in the following order:
1. Command line arguments
2. Environment variables
3. Interactive prompt
This is particularly useful for:
- CI/CD environments
- Automated scripts
- Development workflows where you don't want to enter credentials repeatedly
2025-02-13 01:00:26 +08:00
### 2. Generate Models
2024-11-26 02:46:48 +08:00
2025-02-13 01:00:26 +08:00
Generate Buster YAML models from your existing SQL files:
2024-11-26 02:46:48 +08:00
2025-02-13 01:00:26 +08:00
```bash
buster generate
```
Key flags for generation:
- `--source-path` : Directory containing your SQL files (defaults to current directory)
- `--destination-path` : Where to output the generated YAML files (defaults to current directory)
- `--data-source-name` : Name of the data source to use in the models
- `--schema` : Database schema name
- `--database` : Database name
2025-02-26 03:34:51 +08:00
- `--flat-structure` : Output YML files in a flat structure instead of maintaining directory hierarchy
2025-02-13 01:00:26 +08:00
The generate command will:
- Scan the source directory for SQL files
- Create corresponding YAML model files
- Create a `buster.yml` configuration file if it doesn't exist
- Preserve any existing model customizations
Example with all options:
```bash
buster generate \
--source-path ./sql \
--destination-path ./models \
--data-source-name my_warehouse \
--schema analytics \
--database prod
```
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
### 3. Deploy Models
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
Deploy your models to Buster:
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
```bash
buster deploy
```
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
Deploy options:
- `--path` : Specific path to deploy (defaults to current directory)
- `--dry-run` : Validate the deployment without actually deploying (defaults to false)
2025-02-26 03:34:51 +08:00
- `--recursive` : Recursively search for model files in subdirectories (defaults to true)
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
Examples:
```bash
# Deploy all models in current directory
buster deploy
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
# Deploy a specific model or directory
buster deploy --path ./models/customers.yml
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
# Validate deployment without applying changes
buster deploy --dry-run
2025-02-26 03:34:51 +08:00
# Deploy only models in the specified directory (not recursively)
buster deploy --path ./models --recursive=false
2025-02-13 01:00:26 +08:00
```
2025-02-06 05:05:12 +08:00
2025-02-26 03:34:51 +08:00
The deploy command will:
1. Discover all YAML model files in the specified path
2. Load and validate the models
3. Check for excluded models based on tags
4. Validate cross-project references
5. Deploy the models to Buster
6. Provide detailed validation feedback and error messages
2025-02-06 05:05:12 +08:00
## Project Structure
2025-02-13 01:00:26 +08:00
A typical Buster project structure:
2025-02-06 05:05:12 +08:00
```
your-project/
├── buster.yml # Global configuration
├── models/ # Your semantic model definitions
│ ├── customers.yml
│ ├── orders.yml
│ └── products.yml
2025-02-13 01:00:26 +08:00
└── sql/ # SQL definitions
2025-02-06 05:05:12 +08:00
├── customers.sql
├── orders.sql
└── products.sql
```
2025-02-13 01:00:26 +08:00
### Configuration (buster.yml)
2025-02-06 05:05:12 +08:00
```yaml
# buster.yml
data_source_name: "my_warehouse" # Your default data source
schema: "analytics" # Default schema for models
2025-02-13 05:01:11 +08:00
database: "prod" # Optional database name
exclude_files: # Optional list of files to exclude from generation
- "temp_*.sql" # Exclude all SQL files starting with temp_
- "test/**/*.sql" # Exclude all SQL files in test directories
2025-02-26 03:34:51 +08:00
- "customers.sql" # Exclude a specific file
exclude_tags: # Optional list of tags to exclude from deployment
- "staging" # Exclude models with the 'staging' tag
- "test" # Exclude models with the 'test' tag
2025-02-06 05:05:12 +08:00
```
2025-02-13 05:01:11 +08:00
The configuration supports the following fields:
- `data_source_name` : (Required) Default data source for your models
- `schema` : (Required) Default schema for your models
- `database` : (Optional) Default database name
- `exclude_files` : (Optional) List of glob patterns for files to exclude from generation
- Supports standard glob patterns (*, ** , ?, etc.)
- Matches against relative paths from source directory
- Common use cases:
- Excluding temporary files: `temp_*.sql`
- Excluding test files: `test/**/*.sql`
- Excluding specific files: `customers.sql`
- Excluding files in directories: `archive/**/*.sql`
2025-02-26 03:34:51 +08:00
- `exclude_tags` : (Optional) List of tags to exclude from deployment
- Looks for tags in SQL files in dbt format: `{{ config(tags=['tag1', 'tag2']) }}`
- Useful for excluding staging models, test models, etc.
- Case-insensitive matching
2025-02-13 05:01:11 +08:00
2025-02-13 01:00:26 +08:00
### Model Definition Example
2025-02-06 05:05:12 +08:00
```yaml
# models/customers.yml
version: 1
models:
- name: customers
description: "Core customer data model"
2025-02-26 03:34:51 +08:00
data_source_name: "my_warehouse" # Overrides buster.yml
schema: "analytics" # Overrides buster.yml
database: "prod" # Overrides buster.yml
2025-02-06 05:05:12 +08:00
entities:
- name: customer_id
expr: "id"
type: "primary"
description: "Primary customer identifier"
2025-02-26 03:34:51 +08:00
- name: order
expr: "order_id"
type: "foreign"
description: "Reference to order model"
# Optional: reference to another model in a different project
project_path: "path/to/other/project"
# Optional: specify a different name for the referenced model
ref: "orders"
2025-02-06 05:05:12 +08:00
dimensions:
- name: email
expr: "email"
type: "string"
description: "Customer email address"
2025-02-26 03:34:51 +08:00
searchable: true # Optional: make this dimension searchable
2025-02-06 05:05:12 +08:00
measures:
- name: total_customers
expr: "customer_id"
agg: "count_distinct"
description: "Total number of unique customers"
2025-02-26 03:34:51 +08:00
type: "integer" # Optional: specify the data type
```
## Cross-Project References
Buster CLI supports referencing models across different projects, enabling you to build complex data relationships:
```yaml
entities:
- name: user_model
expr: "user_id"
type: "foreign"
description: "Reference to user model in another project"
project_path: "path/to/user/project"
ref: "users" # Optional: specify a different name for the referenced model
```
When using cross-project references, the CLI will:
1. Validate that the referenced project exists
2. Check for a valid buster.yml in the referenced project
3. Verify that the data sources match between projects
4. Confirm that the referenced model exists in the target project
This enables you to organize your models into logical projects while maintaining relationships between them.
## Tag-Based Exclusion
You can exclude models from deployment based on tags in your SQL files. This is useful for excluding staging models, test models, or any other models you don't want to deploy.
In your SQL files, add tags using the dbt format:
```sql
{{ config(
tags=['staging', 'test']
) }}
SELECT * FROM source_table
2025-02-06 05:05:12 +08:00
```
2025-02-26 03:34:51 +08:00
Then in your buster.yml, specify which tags to exclude:
```yaml
exclude_tags:
- "staging"
- "test"
```
During deployment, any model with matching tags will be automatically excluded.
2025-02-26 11:11:35 +08:00
## File and Tag Exclusions
Buster CLI provides a unified way to exclude files from processing across all commands. You can specify exclusions in your `buster.yml` file:
```yaml
data_source_name: "my_data_source"
schema: "my_schema"
database: "my_database"
exclude_files:
- "**/*_temp.sql"
- "staging/**/*.sql"
- "tests/**/*.yml"
exclude_tags:
- "test"
- "deprecated"
- "wip"
```
### Exclude Files
The `exclude_files` section allows you to specify glob patterns for files that should be excluded from processing. This works for any command that processes files.
Common patterns:
- `"**/*_temp.sql"` - Exclude any SQL file ending with _temp.sql in any directory
- `"staging/**/*.sql"` - Exclude all SQL files in the staging directory and its subdirectories
- `"test_*.yml"` - Exclude all YAML files starting with test_
### Exclude Tags
The `exclude_tags` section allows you to exclude files based on tags specified in the file content. This is useful for excluding files that are marked as test, deprecated, etc.
Tags are specified in the SQL files using the format: `-- tags = ['tag1', 'tag2']`
When a file contains any of the excluded tags, it will be skipped by all commands.
2025-02-06 05:05:12 +08:00
## Best Practices
1. **Organization**
- Keep YAML files in `models/`
- Keep SQL files in `sql/`
- Use `buster.yml` for shared settings
2025-02-26 03:34:51 +08:00
- Group related models into subdirectories
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
2. **Model Generation**
- Start with clean SQL files
- Generate models first before customizing
- Review generated models before deployment
2025-02-26 03:34:51 +08:00
- Use tags to organize and filter models
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
3. **Deployment**
- Use `--dry-run` to validate changes
- Deploy frequently to catch issues early
- Keep model and SQL files in sync
2025-02-26 03:34:51 +08:00
- Use cross-project references for complex relationships
4. **Validation**
- Ensure all models have descriptions
- Validate cross-project references before deployment
- Check for missing dependencies
- Review validation errors carefully
2025-02-06 05:05:12 +08:00
## Troubleshooting
2025-02-13 01:00:26 +08:00
Common issues and solutions:
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
1. **Authentication Issues**
- Verify your API key is correct
- Check if the host is properly specified (if using non-production)
- Ensure network connectivity to Buster
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
2. **Generation Issues**
- Verify SQL files are in the correct location
- Check file permissions
- Ensure SQL syntax is valid
2025-02-26 03:34:51 +08:00
- Check for excluded files or tags
2025-02-06 05:05:12 +08:00
2025-02-13 01:00:26 +08:00
3. **Deployment Issues**
- Validate YAML syntax
- Check for missing dependencies
- Verify data source connectivity
2025-02-26 03:34:51 +08:00
- Look for cross-project reference errors
- Check for tag-based exclusions
4. **Cross-Project Reference Issues**
- Ensure the referenced project exists
- Verify the referenced project has a valid buster.yml
- Check that data sources match between projects
- Confirm the referenced model exists in the target project
2024-11-26 02:46:48 +08:00
2025-02-06 05:05:12 +08:00
## License
2024-11-26 02:46:48 +08:00
2025-02-06 05:05:12 +08:00
MIT License - see [LICENSE ](LICENSE ) for details.