-
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
b7781f3
2d12f1d
8236aa9
d23fa96
7756b6d
e4f1ee9
81c0092
c24048c
22802ea
243bc4a
23e6afb
927b7bc
c268de2
88b87d1
8a71c9e
c9890d8
f0427e0
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: [DATABRICKS_URL]/jobs/[MY_JOB_ID]/runs/[MY_RUN_ID]?w=[NUMID] | ||
| 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,26 @@ | ||
| bundle: | ||
| name: job-runs-job-parameters | ||
|
|
||
| resources: | ||
| jobs: | ||
| my_job: | ||
| name: my-job | ||
| parameters: | ||
| - name: env | ||
| default: dev | ||
| - name: region | ||
| default: us | ||
| tasks: | ||
| - task_key: main | ||
| notebook_task: | ||
| notebook_path: /Workspace/test | ||
|
|
||
| job_runs: | ||
| my_run: | ||
| job_id: ${resources.jobs.my_job.id} | ||
| # Override only one of the job's two parameters. GetRun resolves the full | ||
| # parameter set (including the un-overridden `region` default), so without | ||
| # job_parameters in ignore_remote_changes this drift would recreate the run | ||
| # on every plan. | ||
| job_parameters: | ||
| env: prod |
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,49 @@ | ||
|
|
||
| === deploy triggers the run with only the overridden parameter | ||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/job-runs-job-parameters/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": "prod" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| === plan is stable: the resolved job default does not look like drift | ||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 2 unchanged | ||
|
|
||
| >>> [CLI] bundle summary | ||
| Name: job-runs-job-parameters | ||
| Target: default | ||
| Workspace: | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/job-runs-job-parameters/default | ||
| Resources: | ||
| Job Runs: | ||
| my_run: | ||
| Name: | ||
| URL: [DATABRICKS_URL]/jobs/[NUMID]/runs/[NUMID]?w=[NUMID] | ||
| Jobs: | ||
| my_job: | ||
| Name: my-job | ||
| URL: [DATABRICKS_URL]/jobs/[NUMID]?w=[NUMID] | ||
|
|
||
| >>> [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-job-parameters/default | ||
|
|
||
| Deleting files... | ||
| Destroy complete! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| title "deploy triggers the run with only the overridden parameter" | ||
| trace $CLI bundle deploy | ||
| trace print_requests.py //jobs/run-now | ||
|
|
||
| title "plan is stable: the resolved job default does not look like drift" | ||
| trace $CLI bundle plan | ||
| trace $CLI bundle summary |
| 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.
Uh oh!
There was an error while loading. Please reload this page.