Brickflows

1.7.0 · active · verified Sun Apr 12

Brickflows is a Python library and CLI tool designed to simplify the development and deployment of scalable workflows on Databricks. It enables users to define Databricks workflows declaratively using Python, leveraging decorators for tasks and integrating seamlessly with Databricks Asset Bundles (DABs) for deployment. The current version is 1.7.0, and it maintains an active release cadence with frequent updates and bug fixes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a simple 'Hello World' Databricks workflow using Brickflows. It includes defining a workflow with a default cluster and a single task. To deploy, you must first set up a Brickflow project using the `brickflow` CLI and ensure the Databricks CLI is configured to authenticate with your workspace.

from datetime import timedelta
from brickflow import Workflow, Cluster, TaskSettings
import os

# Configure Databricks host and token via environment variables or databricks configure --token
# For this example, ensure your ~/.databrickscfg is set up or environment variables are available.
# Example: export DATABRICKS_HOST="https://<your-workspace-url>.cloud.databricks.com" 
#          export DATABRICKS_TOKEN="dapi..."

wf = Workflow(
    "hello_world_workflow",
    default_cluster=Cluster(
        name="brickflow-example-cluster",
        spark_version='12.2.x-scala2.12',
        node_type_id='Standard_DS3_v2',
        num_workers=1
    ),
    default_task_settings=TaskSettings(
        timeout_seconds=timedelta(hours=2).seconds
    )
)

@wf.task()
def hello_task():
    print(f"Hello from Databricks! Host: {os.environ.get('DATABRICKS_HOST', 'N/A')}")
    return "Task completed successfully"

# To run this, you would typically use the brickflows CLI:
# 1. Create a project: `mkdir my_brickflow_project && cd my_brickflow_project && brickflow projects add`
# 2. Place this code in `workflows/hello_world_wf.py` (assuming workflows is your workflows directory).
# 3. Deploy: `brickflow deploy --deploy-mode=bundle -p <your_databricks_profile>`

view raw JSON →