-1

I have a dynamic dag using which I am creating multiple dags(different workflows) based on the value passed from lambda with their config. How can I trigger the dynamic dag script and trigger the dag from lambda

1 Answers1

0

Airflow has api which allow you to trigger dag .

With Post call to /dags/{dag_id}/dagRuns you can trigger new run.

import uuid

import requests
from requests.auth import HTTPBasicAuth

airflow_server = "http://localhost:8080/api/v1/"
user = "airflow"
password = "airflow"
auth = HTTPBasicAuth(user, password)

dag_id = "your_dag_id"
run_dag_uri = f"{airflow_server}/dags/{dag_id}/dagRuns"
data = {
  "conf": {},
  "dag_run_id": str(uuid.uuid4()),
}
response = requests.post(run_dag_uri, auth=auth, json=data)
ozs
  • 3,051
  • 1
  • 10
  • 19