-
Notifications
You must be signed in to change notification settings - Fork 184
Add preliminary job_runs resource #5603
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
base: main
Are you sure you want to change the base?
Changes from all commits
f5dccda
b4f68b7
d0cd0d1
40d6fba
b733f81
45dc0d1
1c15198
918d80a
67f82f0
f7ec335
985e7ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| bundle: | ||
| name: job-runs-basic | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: my-job | ||
| tasks: | ||
| - task_key: main | ||
| notebook_task: | ||
| notebook_path: /Workspace/test | ||
|
|
||
| job_runs: | ||
| my_run: | ||
| job_id: ${resources.jobs.my_job.id} | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
|
|
||
| === deploy triggers exactly one run | ||
| >>> [CLI] bundle validate | ||
| Name: job-runs-basic | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default | ||
|
|
||
| Validation OK! | ||
|
|
||
| >>> [CLI] bundle plan | ||
| create job_runs.my_run | ||
| create jobs.my_job | ||
|
|
||
| Plan: 2 to add, 0 to change, 0 to delete, 0 unchanged | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: job-runs-basic | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default | ||
| Resources: | ||
| Job Runs: | ||
| my_run: | ||
| Name: | ||
| URL: (not deployed) | ||
| Jobs: | ||
| my_job: | ||
| Name: my-job | ||
| URL: (not deployed) | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: job-runs-basic | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default | ||
| Resources: | ||
| Job Runs: | ||
| my_run: | ||
| Name: | ||
| URL: (not deployed) | ||
| Jobs: | ||
| my_job: | ||
| Name: my-job | ||
| URL: [DATABRICKS_URL]/jobs/[MY_JOB_ID]?w=[NUMID] | ||
|
|
||
| === exactly one run-now request was made | ||
| >>> print_requests.py //jobs/run-now | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.2/jobs/run-now", | ||
| "body": { | ||
| "job_id": [MY_JOB_ID] | ||
| } | ||
| } | ||
|
|
||
| === the triggered run id is stored in state | ||
| >>> read_id.py my_run | ||
| [MY_RUN_ID] | ||
|
|
||
| >>> read_id.py my_job | ||
| [MY_JOB_ID] | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.job_runs.my_run | ||
| delete resources.jobs.my_job | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/job-runs-basic/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| title "deploy triggers exactly one run" | ||
| trace $CLI bundle validate | ||
| trace $CLI bundle plan | ||
| trace $CLI bundle summary | ||
| trace $CLI bundle deploy | ||
|
radakam marked this conversation as resolved.
radakam marked this conversation as resolved.
|
||
|
|
||
| # confirm that redeploy does not trigger a second run | ||
| trace $CLI bundle deploy | ||
|
|
||
| trace $CLI bundle plan | ||
| trace $CLI bundle summary | ||
|
|
||
| title "exactly one run-now request was made" | ||
| trace print_requests.py //jobs/run-now | ||
|
|
||
| title "the triggered run id is stored in state" | ||
| trace read_id.py my_run | ||
| trace read_id.py my_job | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # job_runs is a direct-engine-only resource; the Terraform provider has no | ||
| # equivalent, so restrict the matrix to direct. | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
| RecordRequests = true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| bundle: | ||
| name: job-runs-notebook-change | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: my-job | ||
| tasks: | ||
| - task_key: main | ||
| notebook_task: | ||
| notebook_path: /Workspace/test | ||
|
|
||
| job_runs: | ||
| my_run: | ||
| job_id: ${resources.jobs.my_job.id} | ||
| job_parameters: | ||
| env: dev | ||
| # Snapshot the whole job so any change to it (e.g. notebook_path) re-triggers the run. | ||
| job_settings: ${resources.jobs.my_job} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
|
|
||
| === initial deploy triggers the first run | ||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-notebook-change/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> print_requests.py //jobs/run-now | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.2/jobs/run-now", | ||
| "body": { | ||
| "job_id": [NUMID], | ||
| "job_parameters": { | ||
| "env": "dev" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| === change the job notebook_path and redeploy | ||
| >>> update_file.py databricks.yml notebook_path: /Workspace/test notebook_path: /Workspace/other | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-notebook-change/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged | ||
|
|
||
| === the job was updated with the new notebook_path | ||
| >>> print_requests.py --keep //jobs/reset | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.2/jobs/reset", | ||
| "body": { | ||
| "job_id": [NUMID], | ||
| "new_settings": { | ||
| "deployment": { | ||
| "kind": "BUNDLE", | ||
| "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/job-runs-notebook-change/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/other" | ||
| }, | ||
| "task_key": "main" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| === the job change re-triggered the run via the job_settings snapshot | ||
| >>> print_requests.py //jobs/run-now | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.2/jobs/run-now", | ||
| "body": { | ||
| "job_id": [NUMID], | ||
| "job_parameters": { | ||
| "env": "dev" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.job_runs.my_run | ||
| delete resources.jobs.my_job | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/job-runs-notebook-change/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| title "initial deploy triggers the first run" | ||
| trace $CLI bundle deploy | ||
| trace print_requests.py //jobs/run-now | ||
|
|
||
| title "change the job notebook_path and redeploy" | ||
| trace update_file.py databricks.yml "notebook_path: /Workspace/test" "notebook_path: /Workspace/other" | ||
| trace $CLI bundle deploy | ||
| trace $CLI bundle plan | ||
|
|
||
| title "the job was updated with the new notebook_path" | ||
| trace print_requests.py --keep //jobs/reset | ||
|
|
||
| title "the job change re-triggered the run via the job_settings snapshot" | ||
| trace print_requests.py //jobs/run-now |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # job_runs is a direct-engine-only resource; the Terraform provider has no | ||
| # equivalent, so restrict the matrix to direct. | ||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
| RecordRequests = true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| bundle: | ||
| name: job-runs-redeploy | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: my-job | ||
| tasks: | ||
| - task_key: main | ||
| notebook_task: | ||
| notebook_path: /Workspace/test | ||
|
|
||
| job_runs: | ||
| my_run: | ||
| job_id: ${resources.jobs.my_job.id} | ||
| job_parameters: | ||
| env: dev |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
|
|
||
| === initial deploy triggers the first run | ||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-redeploy/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: job-runs-redeploy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-redeploy/default | ||
| Resources: | ||
| Job Runs: | ||
| my_run: | ||
| Name: | ||
| URL: (not deployed) | ||
| Jobs: | ||
| my_job: | ||
| Name: my-job | ||
| URL: [DATABRICKS_URL]/jobs/[MY_JOB_ID]?w=[NUMID] | ||
|
|
||
| >>> read_id.py my_job | ||
| [MY_JOB_ID] | ||
|
|
||
| >>> print_requests.py //jobs/run-now | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.2/jobs/run-now", | ||
| "body": { | ||
| "job_id": [MY_JOB_ID], | ||
| "job_parameters": { | ||
| "env": "dev" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| === change the run configuration and redeploy | ||
| >>> update_file.py databricks.yml env: dev env: prod | ||
|
|
||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-redeploy/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: job-runs-redeploy | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-redeploy/default | ||
| Resources: | ||
| Job Runs: | ||
| my_run: | ||
| Name: | ||
| URL: (not deployed) | ||
| Jobs: | ||
| my_job: | ||
| Name: my-job | ||
| URL: [DATABRICKS_URL]/jobs/[MY_JOB_ID]?w=[NUMID] | ||
|
|
||
| === the config change triggered a second, different run | ||
| >>> print_requests.py //jobs/run-now | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.2/jobs/run-now", | ||
| "body": { | ||
| "job_id": [MY_JOB_ID], | ||
| "job_parameters": { | ||
| "env": "prod" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.job_runs.my_run | ||
| delete resources.jobs.my_job | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/job-runs-redeploy/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
Uh oh!
There was an error while loading. Please reload this page.