Module: DatabricksJobs
- Included in:
- Databricks
- Defined in:
- lib/dbx/databricks/jobs.rb
Overview
This module handles the execution of jobs/runs using the DBX API. For more information about the DBX Jobs API, see: learn.microsoft.com/en-us/azure/databricks/workflows/jobs/jobs-2.0-api
Instance Method Summary collapse
-
#cancel_all_runs(job_id) ⇒ Object
cancel all active runs of a job POST /api/2.0/jobs/runs/cancel-all.
-
#cancel_run(run_id) ⇒ Object
cancel a single run POST /api/2.0/jobs/runs/cancel.
-
#create_job(job_json) ⇒ Object
create job POST /api/2.0/jobs/create/.
-
#delete_job(job_id) ⇒ Object
delete job POST /api/2.0/jobs/delete/.
-
#delete_run(run_id) ⇒ Object
delete inactive run POST /api/2.0/jobs/runs/delete.
-
#export_run(run_id) ⇒ Object
export notebook run as HTML GET /api/2.0/jobs/runs/export.
-
#get_run(run_id) ⇒ Object
get run metadata GET /api/2.0/jobs/runs/get.
-
#get_run_output(run_id) ⇒ Object
get run output GET /api/2.0/jobs/runs/get-output.
-
#job_info(job_id) ⇒ Object
get information about a single job GET /api/2.0/jobs/get/.
- #jobs_url ⇒ Object
-
#list_jobs ⇒ Object
list jobs GET /api/2.0/jobs/list/.
-
#list_runs(active_only: false) ⇒ Object
list runs GET /api/2.0/jobs/runs/list.
-
#run_now(job_id) ⇒ Object
run job POST /api/2.0/jobs/run-now.
-
#submit_job(job_json) ⇒ Object
submit a one-time run without directly creating a job POST /api/2.0/jobs/runs/submit.
Instance Method Details
#cancel_all_runs(job_id) ⇒ Object
cancel all active runs of a job POST /api/2.0/jobs/runs/cancel-all
114 115 116 117 118 119 120 |
# File 'lib/dbx/databricks/jobs.rb', line 114 def cancel_all_runs(job_id) uri = URI("#{jobs_url}runs/cancel-all") request = Net::HTTP::Post.new(uri, request_headers) request.body = { "job_id" => job_id }.to_json response = http.request(request) response.body end |
#cancel_run(run_id) ⇒ Object
cancel a single run POST /api/2.0/jobs/runs/cancel
104 105 106 107 108 109 110 |
# File 'lib/dbx/databricks/jobs.rb', line 104 def cancel_run(run_id) uri = URI("#{jobs_url}runs/cancel") request = Net::HTTP::Post.new(uri, request_headers) request.body = { "run_id" => run_id }.to_json response = http.request(request) response.body end |
#create_job(job_json) ⇒ Object
create job POST /api/2.0/jobs/create/
15 16 17 18 19 20 21 |
# File 'lib/dbx/databricks/jobs.rb', line 15 def create_job(job_json) uri = URI("#{jobs_url}create") request = Net::HTTP::Post.new(uri, request_headers) request.body = job_json response = http.request(request) response.body end |
#delete_job(job_id) ⇒ Object
delete job POST /api/2.0/jobs/delete/
34 35 36 37 38 39 40 |
# File 'lib/dbx/databricks/jobs.rb', line 34 def delete_job(job_id) uri = URI("#{jobs_url}delete") request = Net::HTTP::Post.new(uri, request_headers) request.body = { "job_id" => job_id }.to_json response = http.request(request) response.body end |
#delete_run(run_id) ⇒ Object
delete inactive run POST /api/2.0/jobs/runs/delete
134 135 136 137 138 139 140 |
# File 'lib/dbx/databricks/jobs.rb', line 134 def delete_run(run_id) uri = URI("#{jobs_url}runs/delete") request = Net::HTTP::Post.new(uri, request_headers) request.body = { "run_id" => run_id }.to_json response = http.request(request) response.body end |
#export_run(run_id) ⇒ Object
export notebook run as HTML GET /api/2.0/jobs/runs/export
94 95 96 97 98 99 100 |
# File 'lib/dbx/databricks/jobs.rb', line 94 def export_run(run_id) uri = URI("#{jobs_url}runs/export") request = Net::HTTP::Get.new(uri, request_headers) request.body = { "run_id" => run_id }.to_json response = http.request(request) response.body end |
#get_run(run_id) ⇒ Object
get run metadata GET /api/2.0/jobs/runs/get
84 85 86 87 88 89 90 |
# File 'lib/dbx/databricks/jobs.rb', line 84 def get_run(run_id) uri = URI("#{jobs_url}runs/get") request = Net::HTTP::Get.new(uri, request_headers) request.body = { "run_id" => run_id }.to_json response = http.request(request) response.body end |
#get_run_output(run_id) ⇒ Object
get run output GET /api/2.0/jobs/runs/get-output
124 125 126 127 128 129 130 |
# File 'lib/dbx/databricks/jobs.rb', line 124 def get_run_output(run_id) uri = URI("#{jobs_url}runs/get-output") request = Net::HTTP::Get.new(uri, request_headers) request.body = { "run_id" => run_id }.to_json response = http.request(request) response.body end |
#job_info(job_id) ⇒ Object
get information about a single job GET /api/2.0/jobs/get/
44 45 46 47 48 49 50 |
# File 'lib/dbx/databricks/jobs.rb', line 44 def job_info(job_id) uri = URI("#{jobs_url}get") request = Net::HTTP::Get.new(uri, request_headers) request.body = { "job_id" => job_id }.to_json response = http.request(request) response.body end |
#jobs_url ⇒ Object
9 10 11 |
# File 'lib/dbx/databricks/jobs.rb', line 9 def jobs_url "#{@base_url}/api/2.0/jobs/" end |
#list_jobs ⇒ Object
list jobs GET /api/2.0/jobs/list/
25 26 27 28 29 30 |
# File 'lib/dbx/databricks/jobs.rb', line 25 def list_jobs uri = URI("#{jobs_url}list") request = Net::HTTP::Get.new(uri, request_headers) response = http.request(request) response.body end |
#list_runs(active_only: false) ⇒ Object
list runs GET /api/2.0/jobs/runs/list
74 75 76 77 78 79 80 |
# File 'lib/dbx/databricks/jobs.rb', line 74 def list_runs(active_only: false) uri = URI("#{jobs_url}runs/list") request = Net::HTTP::Get.new(uri, request_headers) request.body = { "active_only" => active_only }.to_json response = http.request(request) response.body end |
#run_now(job_id) ⇒ Object
run job POST /api/2.0/jobs/run-now
54 55 56 57 58 59 60 |
# File 'lib/dbx/databricks/jobs.rb', line 54 def run_now(job_id) uri = URI("#{jobs_url}run-now") request = Net::HTTP::Post.new(uri, request_headers) request.body = { "job_id" => job_id }.to_json response = http.request(request) response.body end |
#submit_job(job_json) ⇒ Object
submit a one-time run without directly creating a job POST /api/2.0/jobs/runs/submit
64 65 66 67 68 69 70 |
# File 'lib/dbx/databricks/jobs.rb', line 64 def submit_job(job_json) uri = URI("#{jobs_url}runs/submit") request = Net::HTTP::Post.new(uri, request_headers) request.body = job_json response = http.request(request) response.body end |