Add acceptance tests for bundle deploy

This commit is contained in:
Gleb Kanterov 2025-01-28 22:15:31 +01:00
parent ecc05689ca
commit 36cff285e1
No known key found for this signature in database
GPG Key ID: 4D87C640DBD00176
9 changed files with 132 additions and 0 deletions

View File

@ -0,0 +1,9 @@
bundle:
name: my_project
sync: {} # dont need to copy files
experimental:
python:
resources:
- "resources:load_resources"

View File

@ -0,0 +1,2 @@
# Databricks notebook source
1 + 1

View File

@ -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

View File

@ -0,0 +1,34 @@
>>> 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/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!
>>> [CLI] jobs list --output json
[
{
"job_id": 1,
"settings": {
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_project/default/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"max_concurrent_runs": 1,
"name": "My Job",
"queue": {
"enabled": true
},
"tasks": [
{
"notebook_task": {
"notebook_path": "/Workspace/Users/[USERNAME]/.bundle/my_project/default/files/my_notebook"
},
"task_key": "my_notebook"
}
]
}
}
]

View File

@ -0,0 +1,7 @@
cd my_project
trace uv run --quiet --python 3.12 --with databricks-bundles==0.7.0 -- $CLI bundle deploy
trace $CLI jobs list --output json
rm -rf .databricks __pycache__ .gitignore

View File

@ -0,0 +1,13 @@
bundle:
name: my_project
sync: {} # dont need to copy files
resources:
jobs:
my_job:
name: My Job
tasks:
- task_key: my_notebook
notebook_task:
notebook_path: my_notebook.py

View File

@ -0,0 +1,2 @@
# Databricks notebook source
1 + 1

View File

@ -0,0 +1,34 @@
>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/my_project/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!
>>> [CLI] jobs list --output json
[
{
"job_id": 1,
"settings": {
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/my_project/default/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"max_concurrent_runs": 1,
"name": "My Job",
"queue": {
"enabled": true
},
"tasks": [
{
"notebook_task": {
"notebook_path": "/Workspace/Users/[USERNAME]/.bundle/my_project/default/files/my_notebook"
},
"task_key": "my_notebook"
}
]
}
}
]

View File

@ -0,0 +1,7 @@
cd my_project
trace $CLI bundle deploy
trace $CLI jobs list --output json
rm -rf .gitignore .databricks