Skip to main content

CI/CD pipeline for Databricks Genie spaces - multi-workspace promotion at scale

Project description

SpaceOps ๐Ÿš€

CI/CD for Databricks Genie Spaces โ€” Multi-workspace promotion at scale

SpaceOps provides a complete pipeline to define, version, test, and promote Genie spaces (knowledge store, joins, instructions, examples, functions, benchmarks) across dev/stage/prod environments.

Why SpaceOps?

  • Version Control: Store Genie space definitions as code in Git
  • Drift Control: Detect and prevent configuration drift across environments
  • Benchmark Testing: Block promotions if query accuracy drops
  • Multi-Workspace: Promote spaces across dev โ†’ stage โ†’ prod with environment-specific overrides
  • Snapshots & Backups: Export space state for auditing and disaster recovery

Quick Start

Installation

# Clone the repository
git clone https://github.com/your-org/spaceops.git
cd spaceops

# Install dependencies
pip install -e .

# Verify installation
spaceops --version

Environment Setup

export DATABRICKS_HOST="https://your-workspace.cloud.databricks.com"
export DATABRICKS_TOKEN="your-token"

Basic Commands

# Snapshot an existing space
spaceops snapshot <space_id> -o spaces/my-space/space.yaml

# Validate a space definition
spaceops validate spaces/my-space/space.yaml

# Push to Databricks (create or update)
spaceops push spaces/my-space/space.yaml --space-id <existing_id>

# Compare local vs remote
spaceops diff spaces/my-space/space.yaml <space_id>

# Run benchmark tests
spaceops benchmark <space_id> spaces/my-space/benchmarks/accuracy.yaml

# Promote to an environment
spaceops promote spaces/my-space/space.yaml prod --config config/promotion.yaml

Project Structure

spaceops/
โ”œโ”€โ”€ spaceops/                 # Python package
โ”‚   โ”œโ”€โ”€ cli.py               # CLI commands
โ”‚   โ”œโ”€โ”€ client.py            # Databricks Genie API client
โ”‚   โ”œโ”€โ”€ models.py            # Pydantic data models
โ”‚   โ”œโ”€โ”€ diff.py              # Configuration diff utilities
โ”‚   โ””โ”€โ”€ benchmark.py         # Benchmark test runner
โ”œโ”€โ”€ spaces/                   # Space definitions (version controlled)
โ”‚   โ””โ”€โ”€ billing/
โ”‚       โ”œโ”€โ”€ space.yaml       # Space configuration
โ”‚       โ””โ”€โ”€ benchmarks/
โ”‚           โ””โ”€โ”€ accuracy.yaml
โ”œโ”€โ”€ config/                   # Environment configurations
โ”‚   โ”œโ”€โ”€ dev.yaml
โ”‚   โ”œโ”€โ”€ stage.yaml
โ”‚   โ”œโ”€โ”€ prod.yaml
โ”‚   โ””โ”€โ”€ promotion.yaml       # Multi-env promotion config
โ””โ”€โ”€ .github/workflows/
    โ””โ”€โ”€ genie-cicd.yaml      # CI/CD pipeline

Space Definition Format

Space definitions are YAML files that define the complete configuration:

title: "My Analytics Space"
description: "AI-powered analytics"
warehouse_id: null  # Set per-environment

data_sources:
  tables:
    - identifier: "catalog.schema.table"
      column_configs:
        - column_name: "id"
          enable_format_assistance: true
        - column_name: "category"
          enable_entity_matching: true

joins:
  - left_table: "catalog.schema.orders"
    right_table: "catalog.schema.customers"
    left_column: "customer_id"
    right_column: "id"
    join_type: "left"

instructions:
  - content: "When calculating revenue, use the net_amount column."
    category: "calculation"

example_queries:
  - question: "What was total revenue last month?"
    sql: "SELECT SUM(net_amount) FROM orders WHERE..."

Benchmark Testing

Create benchmark suites to validate Genie's query accuracy:

# benchmarks/accuracy.yaml
name: "Core Accuracy Tests"
min_accuracy: 0.8  # 80% must pass

queries:
  - question: "What was total usage last month?"
    expected_tables:
      - "system.billing.usage"
    expected_sql_contains:
      - "SUM"
      - "usage_quantity"

  - question: "Show costs by SKU"
    expected_tables:
      - "system.billing.usage"
      - "system.billing.list_prices"
    expected_sql_contains:
      - "JOIN"

Run benchmarks:

spaceops benchmark <space_id> benchmarks/accuracy.yaml --min-accuracy 0.9

CI/CD Pipeline

The included GitHub Actions workflow provides:

  1. Validation โ€” Validates all space definitions on every PR
  2. Diff โ€” Shows what changes will be applied
  3. Dev Deploy โ€” Auto-deploys on merge to develop
  4. Stage Deploy โ€” Auto-deploys on merge to main
  5. Prod Deploy โ€” Requires manual approval + benchmark gates

Required Secrets

Secret Description
DATABRICKS_DEV_HOST Dev workspace URL
DATABRICKS_DEV_TOKEN Dev workspace token
DATABRICKS_STAGE_HOST Stage workspace URL
DATABRICKS_STAGE_TOKEN Stage workspace token
DATABRICKS_PROD_HOST Prod workspace URL
DATABRICKS_PROD_TOKEN Prod workspace token
DEV_SPACE_ID Space ID in dev (after first deploy)
STAGE_SPACE_ID Space ID in stage (after first deploy)
PROD_SPACE_ID Space ID in prod (after first deploy)

Environment Protection

Configure GitHub environment protection rules:

  • production: Require reviewers, restrict to main branch

CLI Reference

spaceops snapshot

Export a space configuration for backup or version control.

spaceops snapshot <space_id> [OPTIONS]

Options:
  -o, --output PATH    Output file path
  --format [yaml|json] Output format (default: yaml)
  --host TEXT          Databricks workspace host
  --token TEXT         Databricks access token

spaceops push

Push a space definition to Databricks.

spaceops push <definition_path> [OPTIONS]

Options:
  --space-id TEXT      Existing space ID to update
  --warehouse-id TEXT  Override warehouse ID
  --env PATH           Environment config file
  --dry-run            Show what would be done

spaceops diff

Compare local definition with remote space.

spaceops diff <definition_path> <space_id> [OPTIONS]

spaceops validate

Validate a space definition file.

spaceops validate <definition_path>

spaceops benchmark

Run benchmark tests against a Genie space.

spaceops benchmark <space_id> <benchmark_paths>... [OPTIONS]

Options:
  --min-accuracy FLOAT  Minimum required accuracy (0-1)
  --output PATH         Output report file
  --format [markdown|json]

spaceops promote

Promote a space to a target environment.

spaceops promote <definition_path> <target_env> [OPTIONS]

Options:
  --config PATH        Promotion config file (required)
  --benchmark PATH     Benchmark file to run before promotion
  --min-accuracy FLOAT Minimum accuracy for benchmark
  --skip-benchmark     Skip benchmark validation
  --dry-run            Show what would be done
  --force              Force promotion even if benchmarks fail

spaceops list

List all Genie spaces in the workspace.

spaceops list [OPTIONS]

spaceops delete

Delete a Genie space.

spaceops delete <space_id> [OPTIONS]

Options:
  -y, --yes            Skip confirmation

API Reference

SpaceOps uses the Databricks Genie Management API:

  • GET /api/2.0/genie/spaces/{space_id}?include_serialized_space=true
  • POST /api/2.0/genie/spaces
  • PATCH /api/2.0/genie/spaces/{space_id}
  • DELETE /api/2.0/genie/spaces/{space_id}

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run with coverage
pytest --cov=spaceops

License

MIT License - see LICENSE file for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and linting
  5. Submit a pull request

Built with โค๏ธ for the Databricks community


Repository: github.com/charotAmine/databricks-spaceops

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spaceops-0.2.1.tar.gz (26.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spaceops-0.2.1-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file spaceops-0.2.1.tar.gz.

File metadata

  • Download URL: spaceops-0.2.1.tar.gz
  • Upload date:
  • Size: 26.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spaceops-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a36c0f250bb507a6d8c1513e0a057f8308d9b53eaff1ecc21a120ac452fff482
MD5 78c2d35876877468ec3f5f590376ea20
BLAKE2b-256 d333320ca178f5901a671df5d28beb3d28be28aadbd64d0a9dd08d780f960b57

See more details on using hashes here.

Provenance

The following attestation bundles were made for spaceops-0.2.1.tar.gz:

Publisher: release.yaml on charotAmine/databricks-spaceops

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spaceops-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: spaceops-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for spaceops-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12dd699e93a7a9c074062aaacf8f1941314e4f3bdc536e787516969998c74c3a
MD5 b5da363b31014170ca49353b3878a9d4
BLAKE2b-256 908e1ad15b36a08d3d8dcec97f61be04528ef2a93a0719b5ac78a0b4ce6962d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for spaceops-0.2.1-py3-none-any.whl:

Publisher: release.yaml on charotAmine/databricks-spaceops

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page