databricks-cli icon indicating copy to clipboard operation
databricks-cli copied to clipboard

Unable to update individual settings when using JobsService.update_job method

Open georgikoemdzhiev opened this issue 3 years ago • 3 comments

Hello,

Is is possible to add support for updating individual settings with the update_job method: https://github.com/databricks/databricks-cli/blob/fd2ad70d1cbe03b587970a8f41d17004d453707c/databricks_cli/sdk/service.py#L257-L271

Currently, when I would like to update just the schedule.pause_status of a job using this code:

from databricks_cli.sdk.api_client import ApiClient
from databricks_cli.sdk.service import JobsService

api_client = ApiClient(host=databricks_host, token=databricks_token)
jobs_service = JobsService(api_client)

reset_dict = {'schedule': {'pause_status': 'PAUSED'}}
jobs_service.update_job(job_id='728701863935760', new_settings=reset_dict)

I am getting this error stating that I need to provide the other 2 "required" parameters of the settings block:

Traceback (most recent call last):
  File "/home/vsts/work/1/s/main.py", line 34, in <module>
    dr.pause_all_jobs(args.databricks_host, args.databricks_token)
  File "/home/vsts/work/1/s/main.py", line 26, in pause_all_jobs
    jobs_service.update_job(job_id='728701863935760',
  File "/home/vsts/.local/lib/python3.10/site-packages/databricks_cli/sdk/service.py", line 269, in update_job
    return self.client.perform_query(
  File "/home/vsts/.local/lib/python3.10/site-packages/databricks_cli/sdk/api_client.py", line 174, in perform_query
    raise requests.exceptions.HTTPError(message, response=e.response)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://mydatabricks.cloud.databricks.com/api/2.0/jobs/update
 Response from server: 
 { 'error_code': 'INVALID_PARAMETER_VALUE',
  'message': 'Missing required fields: '
             'new_settings.schedule.quartz_cron_expression, '
             'new_settings.schedule.timezone_id'}

I used databricks-cli==0.17.4 version when I got the above error

georgikoemdzhiev avatar Feb 23 '23 11:02 georgikoemdzhiev

Just read the current job definition from the API using get_job(), change the fields you want to change, and post it back. 🤷‍♂️

mroy-seedbox avatar Feb 23 '23 15:02 mroy-seedbox

Just read the current job definition from the API using get_job(), change the fields you want to change, and post it back. 🤷‍♂️

Thank you for your suggestion. I guess that would work as well. However, I am hoping that Databricks can make that process even easier.

georgikoemdzhiev avatar Feb 27 '23 10:02 georgikoemdzhiev

Just read the current job definition from the API using get_job(), change the fields you want to change, and post it back. 🤷‍♂️

I tried your suggestion but the approach does not seem to work for me. I tried to change the job's scheduler. I opened another issue to track that here #616

georgikoemdzhiev avatar Mar 15 '23 16:03 georgikoemdzhiev