-
Notifications
You must be signed in to change notification settings - Fork 69
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
Add acceptance tests for bundle deploy #2254
base: main
Are you sure you want to change the base?
Changes from 6 commits
0dd8d21
f6dd05b
bb9e6ff
4fbe4f1
c0b9936
488be17
6fa5f25
db1285f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
bundle: | ||
name: my_project | ||
|
||
experimental: | ||
python: | ||
resources: | ||
- "resources:load_resources" | ||
|
||
targets: | ||
dev: | ||
mode: development | ||
default: true | ||
workspace: | ||
host: $DATABRICKS_HOST |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Databricks notebook source | ||
1 + 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from databricks.bundles.core import Bundle, Resources | ||
from databricks.bundles.jobs import Job | ||
|
||
|
||
def load_resources(bundle: Bundle) -> Resources: | ||
resources = Resources() | ||
|
||
my_job = Job.from_dict( | ||
{ | ||
"name": "My Job", | ||
"tasks": [ | ||
{ | ||
"task_key": "my_notebook", | ||
"notebook_task": { | ||
"notebook_path": "my_notebook.py", | ||
}, | ||
}, | ||
], | ||
} | ||
) | ||
|
||
resources.add_job("job1", my_job) | ||
|
||
return resources |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
>>> uv run --quiet --python 3.12 --with databricks-bundles==0.7.0 -- $CLI bundle deploy | ||
Uploading bundle files to /Workspace/Users/$USERNAME/.bundle/my_project/dev/files... | ||
Deploying resources... | ||
Updating deployment state... | ||
Deployment complete! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cd my_project | ||
|
||
envsubst < databricks.yml.tmpl > databricks.yml | ||
|
||
trace uv run --quiet --python 3.12 --with databricks-bundles==0.7.0 -- $CLI bundle deploy | ||
|
||
# FIXME: doesn't work because fake state is shared and tests run in parallel | ||
# trace $CLI jobs list --output json | ||
|
||
rm -rf .databricks __pycache__ databricks.yml .gitignore |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
bundle: | ||
name: my_project | ||
|
||
resources: | ||
jobs: | ||
my_job: | ||
name: My Job | ||
tasks: | ||
- task_key: my_notebook | ||
notebook_task: | ||
notebook_path: my_notebook.py | ||
|
||
targets: | ||
dev: | ||
mode: development | ||
default: true | ||
workspace: | ||
host: $DATABRICKS_HOST | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this here? isn't that the default? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean that databricks.yml doesn't have to declare targets if env variables are set? Note that we don't use "bundle init" here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean that $DATABRICK_HOST is already what's going to be used (that's how all other tests work), so no need to specify it explicitly and use .tmpl. That line can just be deleted, it should work. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Databricks notebook source | ||
1 + 1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
>>> $CLI bundle deploy | ||
Uploading bundle files to /Workspace/Users/$USERNAME/.bundle/my_project/dev/files... | ||
Deploying resources... | ||
Updating deployment state... | ||
Deployment complete! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cd my_project | ||
|
||
envsubst < databricks.yml.tmpl > databricks.yml | ||
|
||
trace $CLI bundle deploy | ||
|
||
# FIXME: doesn't work because fake state is shared and tests run in parallel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use Badness field in test.toml (git grep for examples). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should just fix the fake. It isn't hard |
||
# trace $CLI jobs list --output json | ||
|
||
rm -rf databricks.yml .gitignore .databricks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is indeed a needed feature, both for local tests but most importantly for cloud tests (#2242).
Could you make a separate PR just for cached terraform - it's important that we review it well.
Also, could you not depend on side effect of "bundle validate"? Here some scripts/docs on how to prepare terraform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen instructions for air-gapped environments. I'm not sure I will have enough capacity to do it correctly. I think we need to implement it by relying on caching in GitHub actions and adding a step where we download Terraform. The cache key should be based on Terraform and Terraform provider versions. Right now, we don't even do that in our own GitHub action that we provide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Github actions cache is nice to have, not a must.
Let's discuss on Slack -- I can help with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase on top of this #2267