2

How to use the note present in DAG runs panel from the ui? I would want to programmatically fill it. For example changing the content depending the on the params passed to the DAG run enter image description here

Assem
  • 11,574
  • 5
  • 59
  • 97
Justin
  • 67
  • 1
  • 5
  • looks like you can do with API. https://airflow.apache.org/docs/apache-airflow/stable/stable-rest-api-ref.html#operation/set_dag_run_note i don't know how to do with API though. – Emma Mar 07 '23 at 16:17

1 Answers1

1

After setting the bounty,I've figured out the solution:

In python, it can be done:

def update_dag_run_note(run_id):
    session = settings.Session()
    editable_dag_run = session.query(DagRun).filter(DagRun.run_id == run_id).one()
    editable_dag_run.note = "your note"
    session.add(editable_dag_run)
    session.commit()

or via API, It can be done as @Emma suggested in comments:

Patch /api/v1/dags/{dag_id}/dagRuns/{dag_run_id}/setNote stable-rest-api-ref

Assem
  • 11,574
  • 5
  • 59
  • 97