roydobbe commented on issue #64828:
URL: https://github.com/apache/airflow/issues/64828#issuecomment-4201052960

   I just created a job that always fails with some params (python wheel task). 
Leaving out the job params in the second part means they are not applied.
   
   initial run:
   
   ```python
   import json
   import os
   import requests
   from azure.identity import ClientSecretCredential
   
   JOB_ID = 12345
   TENANT_ID = os.environ.get("AZURE_TENANT_ID", "")
   CLIENT_ID = os.environ.get("AZURE_CLIENT_ID", "")
   CLIENT_SECRET = os.environ.get("AZURE_CLIENT_SECRET", "")
   DBX_HOST = os.environ.get("DBX_HOST", "")
   DBX_RESOURCE = "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d" # the same for every 
azure tenant
   
   credential = ClientSecretCredential(
       tenant_id=TENANT_ID,
       client_id=CLIENT_ID,
       client_secret=CLIENT_SECRET,
   )
   
   job_params = {
       "execution_date": "20260101",
       "environment": "dev",
       "log_level": "INFO",
   }
   
   def get_headers() -> dict:
       token = credential.get_token(f"{DBX_RESOURCE}/.default")
       return {
           "Authorization": f"Bearer {token.token}",
           "Content-Type": "application/json",
       }
   
   run_now_payload = {
       "job_id": JOB_ID,
       "job_parameters": job_params,
   }
   
   resp = requests.post(
       f"{DBX_HOST}/api/2.1/jobs/run-now",
       headers=get_headers(),
       json=run_now_payload,
   )
   resp.raise_for_status()
   run_now_result = resp.json()
   print("run-now result:", run_now_result)
   
   RUN_ID = run_now_result["run_id"]
   print(f"Triggered run_id: {RUN_ID}")
   ```
   
   repair run:
   ```python
   repair_payload = {
       "run_id": RUN_ID,
       "rerun_all_failed_tasks": True, 
       "job_parameters": job_params # leave out and the job params will not be 
applied to the repaired run.
   }
   
   resp = requests.post(
       f"{DBX_HOST}/api/2.1/jobs/runs/repair",
       headers=get_headers(),
       json=repair_payload,
   )
   resp.raise_for_status()
   repair_result = resp.json()
   print("repair-run result:", repair_result)
   
   REPAIR_ID = repair_result["repair_id"]
   print(f"Repair started. repair_id: {REPAIR_ID}  (same run_id: {RUN_ID})")
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to