Skip to content

Commit b4f5693

Browse files
authored
Feature/serverless v4 (#14)
* upgrade to serverless v4, upgrade databricks cli and uv * explain databricks-connect usage * change pinning * rename dependencies group * use all extras in cicd * use proper connect version * fix dbc tests
1 parent d7bf7d9 commit b4f5693

9 files changed

Lines changed: 908 additions & 625 deletions

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install uv and set the python version
2424
uses: astral-sh/setup-uv@v5
2525
with:
26-
version: "0.8.0"
26+
version: "0.9.16"
2727
python-version: ${{ matrix.python-version }}
2828
enable-cache: true
2929
- name: Setup Java JDK
@@ -32,7 +32,7 @@ jobs:
3232
java-version: 17
3333
distribution: "zulu"
3434
- name: Install the project
35-
run: uv sync --locked --extra dev
35+
run: uv sync --locked --all-extras
3636
- name: Run code checks
3737
run: uv run ruff check
3838
- name: Check code formatting
@@ -57,19 +57,19 @@ jobs:
5757
- name: Install uv and set the python version
5858
uses: astral-sh/setup-uv@v5
5959
with:
60-
version: "0.8.0"
60+
version: "0.9.16"
6161
python-version: ${{ matrix.python-version }}
6262
enable-cache: true
6363
- uses: databricks/setup-cli@main
6464
with:
65-
version: 0.260.0
65+
version: 0.279.0
6666
- name: Install the project
67-
run: uv sync --locked --extra dev
67+
run: uv sync --locked --all-extras
6868
- name: Install Databricks Connect
6969
run: |
7070
uv pip uninstall pyspark
71-
uv pip install databricks-connect==16.3.5
71+
uv pip install databricks-connect==17.2.*
7272
- name: Check Databricks CLI
7373
run: databricks current-user me
7474
- name: Run tests
75-
run: uv run pytest -v
75+
run: uv run --no-sync pytest -v

.github/workflows/deploy-test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ jobs:
2727
- name: Install uv and set the python version
2828
uses: astral-sh/setup-uv@v5
2929
with:
30-
version: "0.8.0"
30+
version: "0.9.16"
3131
python-version: ${{ matrix.python-version }}
3232
enable-cache: true
3333
- uses: databricks/setup-cli@main
3434
with:
35-
version: 0.260.0
35+
version: 0.279.0
3636
- name: Install the project
37-
run: uv sync --locked --extra dev
37+
run: uv sync --locked --all-extras
3838
- name: Check Databricks CLI
3939
run: databricks current-user me
4040
- name: Deploy Databricks Bundle

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ jobs:
2525
- name: Install uv and set the python version
2626
uses: astral-sh/setup-uv@v5
2727
with:
28-
version: "0.8.0"
28+
version: "0.9.16"
2929
python-version: ${{ matrix.python-version }}
3030
enable-cache: true
3131
- uses: databricks/setup-cli@main
3232
with:
33-
version: 0.260.0
33+
version: 0.279.0
3434
- name: Install the project
35-
run: uv sync --locked --extra dev
35+
run: uv sync --locked --all-extras
3636
- name: Check Databricks CLI
3737
run: databricks current-user me
3838
- name: Deploy Databricks Bundle

.github/workflows/validate-bundle.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ jobs:
2626
- name: Install uv and set the python version
2727
uses: astral-sh/setup-uv@v5
2828
with:
29-
version: "0.8.0"
29+
version: "0.9.16"
3030
python-version: ${{ matrix.python-version }}
3131
enable-cache: true
3232
- uses: databricks/setup-cli@main
3333
with:
34-
version: 0.260.0
34+
version: 0.279.0
3535
- name: Install the project
36-
run: uv sync --locked --extra dev
36+
run: uv sync --locked --all-extras
3737
- name: Check Databricks CLI
3838
run: databricks current-user me
3939
- name: Validate Databricks Bundle

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ For this example we use a Databricks Free Edition workspace https://www.databric
2323

2424
Groups and Service Principals are not necessary, but are used in this project to showcase handling permissions on resources such as catalogs or workflows.
2525

26-
* **Serverless environment version 3**, which matches [Databricks Runtime 16.3](https://docs.databricks.com/aws/en/release-notes/serverless/#version-163)
26+
* **Serverless environment**: [Version 4](https://docs.databricks.com/aws/en/release-notes/serverless/environment-version/four) which is similar to Databricks Runtime ~17.*
2727
* **Catalogs**: `lake_dev`, `lake_test` and `lake_prod`
2828
* **Service principals** (for CI/CD and Workflow runners)
2929
* `sp_etl_dev` (for dev and test) and `sp_etl_prod` (for prod)
@@ -45,9 +45,9 @@ A script exists set up the (Free) Workspace as described in [scripts/setup_works
4545

4646
### Setup environment
4747

48-
Sync entire `uv` environment with dev dependencies:
48+
Sync entire `uv` environment with all optional dependency groups:
4949
```bash
50-
uv sync --extra dev
50+
uv sync --all-extras
5151
```
5252

5353
> **Note:** we install Databricks Connect in a follow-up step
@@ -70,16 +70,24 @@ Install `databricks-connect` in active environment. This requires authentication
7070

7171
```bash
7272
uv pip uninstall pyspark
73-
uv pip install databricks-connect==16.3.5
73+
uv pip install databricks-connect==17.2.*
7474
```
75-
> **Note:** For Databricks Runtime 16.3
75+
76+
**Option 2: Run with temporary dependency**
77+
```bash
78+
uv run --with databricks-connect==17.2.* pytest
79+
```
80+
81+
> **Note:** For Databricks Runtime Serverless v4
82+
7683

7784
See https://docs.databricks.com/aws/en/dev-tools/vscode-ext/ for using Databricks Connect extension in VS Code.
7885

7986
### Unit-Tests
8087

8188
```bash
82-
uv run pytest -v
89+
# in case databricks-connect is installed, --no-sync prevents reinstalling pyspark
90+
uv run --no-sync pytest -v
8391
```
8492

8593
Based on whether Databricks Connect is enabled or not the Unit-Tests try to use a Databricks Cluster or start a local Spark session with Delta support.

databricks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ variables:
99
description: The name of the catalog to use for this bundle.
1010
serverless_environment_version:
1111
description: The serverless environment to use for this bundle.
12-
default: "3"
12+
default: "4"
1313
dbt_sql_warehouse_id:
1414
description: The ID of the SQL warehouse to use for dbt tasks.
1515

pyproject.toml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["uv_build>=0.8.0,<0.9"]
2+
requires = ["uv_build>=0.8.0,<0.10"]
33
build-backend = "uv_build"
44

55
[project]
@@ -13,22 +13,26 @@ authors = [
1313
requires-python = ">=3.12"
1414
urls.homepage = "https://github.com/frizzleqq/databricks-bundle-implementation"
1515

16-
# Roughly based on Databricks runtime 16.3: https://docs.databricks.com/aws/en/release-notes/serverless/#version-163
17-
# Note that we do not include pre-installed libraries like "pydantic" in the runtime-dependencies here
16+
# Based on serverless environment 4: https://docs.databricks.com/aws/en/release-notes/serverless/environment-version/four
17+
# Note that we do not include pre-installed libraries like "pydantic" in the runtime-dependencies in main dependencies
1818
dependencies = [
19-
"databricks-sdk>=0.41, <0.48.0", # pinning from dbt-databricks
19+
"databricks-sdk>=0.41, <0.68.0", # pinning from dbt-databricks
2020
]
2121

2222
[project.optional-dependencies]
23+
# Databricks runtime dependencies (preinstalled on cluster)
24+
databricks = [
25+
"delta-spark==4.0.*",
26+
"pydantic==2.10.6",
27+
"pyspark==4.0.*",
28+
]
29+
# dbt dependencies
30+
dbt = [
31+
"dbt-databricks==1.11.*",
32+
]
33+
# Development & Testing
2334
dev = [
24-
# Runtime
25-
"delta-spark>=3.3.0, <4.0.0",
26-
"pydantic==2.8.2",
27-
"pyspark>=3.5.0, <4.0.0",
28-
# dbt
29-
"dbt-databricks~=1.10.0",
30-
# Tooling
31-
"databricks-bundles~=0.260.0", # For Python-based Workflows
35+
"databricks-bundles==0.279.*", # For Python-based Workflows
3236
"mypy", # Type hints
3337
"pip", # Databricks extension needs it
3438
"pytest", # Unit testing

scripts/setup_workspace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# /// script
22
# requires-python = ">=3.12"
33
# dependencies = [
4-
# "databricks-sdk==0.61.0",
5-
# "databricks-connect~=16.3.0",
4+
# "databricks-sdk>=0.41, <0.68.0",
5+
# "databricks-connect==17.2.*",
66
# ]
77
# ///
88
"""Sets up the Databricks Workspace with necessary catalogs, groups and service principals.

0 commit comments

Comments
 (0)