Search code examples
pythonairflowairflow-api

Airflow set dag run note


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


Solution

  • 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