Got it,   

But here you are just stopping the NB execution right, but i want the for loop iteration to get stooped for that rootrunid. Let's say i have a for each loop in workflow inside which i have a job, for each iteration to be stooped/failed if one of the iteration fails.

if existing_failure > 0:
dbutils.notebook.exit("Exiting due to a previously logged failure.").

 

 

i tried something like this to cancel the job based on run id for that loop job but its cancelling , i need to make it fail,not cancel:

 

import requests
def cancel_job(run_id, token😞
    url = f"https://<databricks-instance>/api/2.1/jobs/runs/cancel"
    headers = {"Authorization": f"Bearer {token}"}
    data = {"run_id": run_id}
    response = requests.post(url, headers=headers, json=data)
    return response.status_code