Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2024 11:13 AM
Hi @varshini_reddy ,
What you can do is to add another task at the end of the job to run if one/all dependencies failed.
This task would be a notebook that would make a call to REST API to stop the job.
# Set up the Databricks API endpoint and token
databricks_instance = "<your-databricks-instance>" # e.g., "https://<your-region>.azuredatabricks.net"
job_id = <your_job_id> # Replace with the ID of the job you want to disable
personal_access_token = "<your_personal_access_token>"
# API endpoint to update the job
api_url = f"{databricks_instance}/api/2.1/jobs/update"
# Function to disable the job by setting the pause status to PAUSED
def disable_job():
# Set the payload to pause the job
payload = {
"job_id": job_id,
"new_settings": {
"schedule": {
"pause_status": "PAUSED"
}
}
}
# Send the API request
response = requests.post(
api_url,
headers={"Authorization": f"Bearer {personal_access_token}"},
json=payload
)
# Check if the request was successful
if response.status_code == 200:
print(f"Job {job_id} has been successfully paused.")
else:
print(f"Failed to pause the job. Status Code: {response.status_code}")
print(f"Response: {response.text}")
disable_job()