How can i run a single task in job from Rest API

200842
New Contributor

How can I run a single task in a job that has many tasks?
I can do it in the UI, but I can’t find a way to do it using the REST API. Does anyone know how to accomplish this?

Ayushi_Suthar
Databricks Employee
Databricks Employee

Hi @200842 , Greetings! 

It is currently not possible to run a single task or a group of tasks from a job without running the entire job from the API. 

Leave a like if this helps, followups are appreciated.
Kudos,

Ayushi

View solution in original post

themattmorris
New Contributor III

It looks like this may be a possibility now? I haven't actually tried it, but I noticed a parameter named "only" has been added to the Databricks SDK for when running a job.

 

Here is the commit that made the change: [Release] Release v0.38.0 (#826) · databricks/databricks-sdk-py@d516d1e

And here is the line on the main branch as of right now: databricks-sdk-py/databricks/sdk/service/jobs.py at f2472bf98160bd4556efbb575b68c5375b2e902e · datab...

The Databricks API docs doesn't display this parameter, but it seems this is a feature that is either coming or already works. It may be worth trying out.

It does work. It will create a new run and will not run the other tasks. 

databricks api post /api/2.2/jobs/run-now --profile demo --json '{
"job_id": REDACT231061639,
"only": ["task_2_of_3"]
}' 2>&1)
⎿ {
"number_in_job":REDACT448649047,
"run_id":REDACT448649047
}