-
Notifications
You must be signed in to change notification settings - Fork 186
Immutable folder support in DABs #5254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andrewnester
wants to merge
29
commits into
main
Choose a base branch
from
demo-immutable
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
b685ec2
Immutable folder support in DABs
andrewnester a429b26
remove unused snapshot path method
andrewnester e7c1968
added an acceptance test
andrewnester 67914d0
fix for notebook import
andrewnester 549492a
removed unused function
andrewnester aedfdb0
fix schema + unit test
andrewnester eddec61
use immutable_folder config
andrewnester 27a6b02
Merge branch 'main' into demo-immutable
andrewnester 4a9bcd9
remove merge conflict
andrewnester ebd26ea
fix empty artifact path + tests
andrewnester 5efe1da
fixed test config
andrewnester 6215a49
fixes
andrewnester 7b44126
Merge branch 'main' into demo-immutable
andrewnester be6dec3
fix fmt
andrewnester 0f1ed52
fix annotations
andrewnester d978559
fix lint
andrewnester 9a6c898
do not call set permissions on immutable ws root
andrewnester 079998b
addressed feedback
andrewnester c6b1ff5
no destroy + acl + fix for empty path
andrewnester 3a0ec41
pr feedback
andrewnester b9f67f7
fixed app deploying
andrewnester 01136f5
use snapshot_path veriable prefixes and move to experimetal
andrewnester 6e9aa77
Merge branch 'main' into demo-immutable
andrewnester e26f085
addressed feedback
andrewnester e2a5b2a
simplify and clean up
andrewnester 6f3f077
update out.test.toml
andrewnester 5cefc2f
comment
andrewnester 55acaf4
fix test on windows
andrewnester 60e41d3
added client side validation for size of upload
andrewnester File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
acceptance/bundle/deploy/immutable-no-artifacts/databricks.yml.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| bundle: | ||
| name: test-bundle-immutable-no-artifacts-$UNIQUE_NAME | ||
|
|
||
| experimental: | ||
| immutable_folder: true | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: my job | ||
| tasks: | ||
| - task_key: spark_python_task | ||
| spark_python_task: | ||
| python_file: ./src/main.py | ||
| environment_key: env | ||
| - task_key: notebook_task | ||
| notebook_task: | ||
| notebook_path: ./src/notebook.py | ||
| base_parameters: | ||
| path: ${workspace.file_path}/some_path | ||
|
|
||
|
|
||
| environments: | ||
| - environment_key: env | ||
| spec: | ||
| environment_version: "4" |
3 changes: 3 additions & 0 deletions
3
acceptance/bundle/deploy/immutable-no-artifacts/out.test.toml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
acceptance/bundle/deploy/immutable-no-artifacts/output.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
|
|
||
| >>> [CLI] bundle validate | ||
| Name: test-bundle-immutable-no-artifacts-[UNIQUE_NAME] | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle-immutable-no-artifacts-[UNIQUE_NAME]/default | ||
|
|
||
| Validation OK! | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading immutable bundle snapshot... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] jobs get [NUMID] | ||
| "/Workspace/Users/[UUID]/.snapshots/[UUID]/[SNAPSHOT_HASH]/src/files/src/main.py" | ||
|
|
||
| >>> [CLI] jobs get [NUMID] | ||
| "/Workspace/Users/[UUID]/.snapshots/[UUID]/[SNAPSHOT_HASH]/src/files/src/notebook" | ||
|
|
||
| >>> [CLI] jobs get [NUMID] | ||
| "/Workspace/Users/[UUID]/.snapshots/[UUID]/[SNAPSHOT_HASH]/src/files/some_path" | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.jobs.my_job | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-immutable-no-artifacts-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| trace $CLI bundle validate | ||
| trace $CLI bundle deploy | ||
|
|
||
|
|
||
| # Get a job and check that task paths point into the snapshot | ||
| JOB_ID=$($CLI bundle summary -o json | jq -r '.resources.jobs.my_job.id') | ||
| trace $CLI jobs get $JOB_ID | jq '.settings.tasks' | jq '.[] | select(.spark_python_task != null) | .spark_python_task.python_file' | ||
| trace $CLI jobs get $JOB_ID | jq '.settings.tasks' | jq '.[] | select(.notebook_task != null) | .notebook_task.notebook_path' | ||
| trace $CLI jobs get $JOB_ID | jq '.settings.tasks' | jq '.[] | select(.notebook_task != null) | .notebook_task.base_parameters.path' | ||
|
|
||
| trace $CLI bundle destroy --auto-approve |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| print("Hello from Spark Python Task!") |
3 changes: 3 additions & 0 deletions
3
acceptance/bundle/deploy/immutable-no-artifacts/src/notebook.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Databricks notebook source | ||
|
|
||
| print("Hello from Notebook Task!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| Local = true | ||
| Cloud = false # Temporary disable cloud tests until the API is fully available | ||
| RecordRequests = true | ||
|
|
||
| # immutable_folder only works with the direct engine. | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
|
|
||
| Ignore = [ | ||
| "databricks.yml", | ||
| ".databricks", | ||
| ".venv", | ||
| "script", | ||
| "*.pyc", | ||
| ] | ||
|
|
||
| # Normalize the content-addressed snapshot hash so it doesn't need to be | ||
| # hardcoded in output.txt and the test stays stable across file changes. | ||
| [[Repls]] | ||
| Old = '[0-9a-f]{64}' | ||
| New = '[SNAPSHOT_HASH]' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| bundle: | ||
| name: test-bundle-immutable-$UNIQUE_NAME | ||
|
|
||
| experimental: | ||
| immutable_folder: true | ||
|
|
||
| artifacts: | ||
| python_artifact: | ||
| type: whl | ||
| build: uv build --wheel | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: my job | ||
| tasks: | ||
| - task_key: spark_python_task | ||
| spark_python_task: | ||
| python_file: ./src/main.py | ||
| environment_key: env | ||
| - task_key: notebook_task | ||
| notebook_task: | ||
| notebook_path: ./src/notebook.py | ||
| - task_key: python_wheel_task | ||
| python_wheel_task: | ||
| package_name: immutable | ||
| entry_point: main | ||
| environment_key: env | ||
| environments: | ||
| - environment_key: env | ||
| spec: | ||
| environment_version: "4" | ||
| dependencies: | ||
| - ./dist/*.whl |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
|
|
||
| >>> [CLI] bundle validate | ||
| Name: test-bundle-immutable-[UNIQUE_NAME] | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/test-bundle-immutable-[UNIQUE_NAME]/default | ||
|
|
||
| Validation OK! | ||
|
|
||
| >>> [CLI] bundle plan -o json | ||
| Building python_artifact... | ||
| [ | ||
| { | ||
| "notebook_task": { | ||
| "notebook_path": "${workspace.snapshot_path}/src/files/src/notebook" | ||
| }, | ||
| "task_key": "notebook_task" | ||
| }, | ||
| { | ||
| "environment_key": "env", | ||
| "python_wheel_task": { | ||
| "entry_point": "main", | ||
| "package_name": "immutable" | ||
| }, | ||
| "task_key": "python_wheel_task" | ||
| }, | ||
| { | ||
| "environment_key": "env", | ||
| "spark_python_task": { | ||
| "python_file": "${workspace.snapshot_path}/src/files/src/main.py" | ||
| }, | ||
| "task_key": "spark_python_task" | ||
| } | ||
| ] | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Building python_artifact... | ||
| Uploading immutable bundle snapshot... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] jobs get [NUMID] | ||
| "/Workspace/Users/[UUID]/.snapshots/[UUID]/[SNAPSHOT_HASH]/src/files/src/main.py" | ||
|
|
||
| >>> [CLI] jobs get [NUMID] | ||
| "/Workspace/Users/[UUID]/.snapshots/[UUID]/[SNAPSHOT_HASH]/src/files/src/notebook" | ||
|
|
||
| >>> [CLI] jobs get [NUMID] | ||
| [ | ||
| "/Workspace/Users/[UUID]/.snapshots/[UUID]/[SNAPSHOT_HASH]/src/artifacts/.internal/immutable-0.0.1-py3-none-any.whl" | ||
| ] | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.jobs.my_job | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/test-bundle-immutable-[UNIQUE_NAME]/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| [project] | ||
| name = "immutable" | ||
| version = "0.0.1" | ||
| authors = [{ name = "andrew.nester@databricks.com" }] | ||
| requires-python = ">=3.10,<3.13" | ||
| dependencies = [ | ||
| # Any dependencies for jobs and pipelines in this project can be added here | ||
| # See also https://docs.databricks.com/dev-tools/bundles/library-dependencies | ||
| # | ||
| # LIMITATION: for pipelines, dependencies are cached during development; | ||
| # add dependencies to the 'environment' section of your pipeline.yml file instead | ||
| ] | ||
|
|
||
| [dependency-groups] | ||
| dev = [ | ||
| "pytest", | ||
| "ruff", | ||
| "databricks-dlt", | ||
| "databricks-connect>=15.4,<15.5", | ||
| "ipykernel", | ||
| ] | ||
|
|
||
| [project.scripts] | ||
| main = "immutable.main:main" | ||
|
|
||
| [build-system] | ||
| requires = ["setuptools>=40.8.0"] | ||
| build-backend = "setuptools.build_meta" | ||
|
|
||
| [tool.setuptools.packages.find] | ||
| where = ["src"] | ||
|
|
||
| [tool.ruff] | ||
| line-length = 120 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| trace $CLI bundle validate | ||
| trace $CLI bundle plan -o json | jq '.plan["resources.jobs.my_job"].new_state.value.tasks' | ||
| trace $CLI bundle deploy | ||
|
|
||
|
|
||
| # Get a job and check that task paths are immutable | ||
| JOB_ID=$($CLI bundle summary -o json | jq -r '.resources.jobs.my_job.id') | ||
| trace $CLI jobs get $JOB_ID | jq '.settings.tasks' | jq '.[] | select(.spark_python_task != null) | .spark_python_task.python_file' | ||
| trace $CLI jobs get $JOB_ID | jq '.settings.tasks' | jq '.[] | select(.notebook_task != null) | .notebook_task.notebook_path' | ||
| trace $CLI jobs get $JOB_ID | jq '.settings.environments[0].spec.dependencies' | ||
|
|
||
| # Redirect run output to a log file — the real workspace produces different output than the local test server. | ||
| $CLI bundle run my_job &> LOG.run |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| def main(): | ||
| print("Hello from Python Wheel Task!") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| print("Hello from Spark Python Task!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Databricks notebook source | ||
|
|
||
| print("Hello from Notebook Task!") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| Local = true | ||
| Cloud = false # Temporary disable cloud tests until the API is fully available | ||
|
|
||
| # immutable_folder only works with the direct engine. | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
|
|
||
| Ignore = [ | ||
| "dist", | ||
| "build", | ||
| "databricks.yml", | ||
| ".databricks", | ||
| ".venv", | ||
| "script", | ||
| "*.pyc", | ||
| "src/*.egg-info", | ||
| ] | ||
|
|
||
| [[Repls]] | ||
| # Replace snapshot hash with SNAPSHOT_HASH | ||
| Old = "[0-9a-f]{64}" | ||
| New = "[SNAPSHOT_HASH]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import streamlit as st | ||
|
|
||
| st.write("hello") |
11 changes: 11 additions & 0 deletions
11
acceptance/bundle/resources/apps/immutable/databricks.yml.tmpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| bundle: | ||
| name: test-bundle-immutable-app-$UNIQUE_NAME | ||
|
|
||
| experimental: | ||
| immutable_folder: true | ||
|
|
||
| resources: | ||
| apps: | ||
| my_app: | ||
| name: my-immutable-app | ||
| source_code_path: ./app |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.