jamiet
jamiet

Reputation: 12264

Is it possible to trigger a DAG using the Python client for Cloud Composer?

I notice that it is possible to trigger a DAG using gcloud by issuing

gcloud composer environments run myenv trigger_dag -- some_dag --run_id=foo

It is my understanding that gcloud uses the client libraries to do everything that it does and hence I am assuming that I can do the same operation (i.e. trigger a composer DAG) using the Python client for Cloud Composer. Unfortunately I've browsed through the documentation at that link, specifically at https://googleapis.dev/python/composer/latest/service_v1beta1/environments.html, and I don't see anything there that enables me to do the same as gcloud composer environments run.

Please can someone help explain if its possible to trigger a DAG using the Python client for Cloud Composer?

Upvotes: 0

Views: 973

Answers (1)

Ricco D
Ricco D

Reputation: 7287

Unfortunately the Python Client Library of Cloud Composer does not support trigger of DAGs as of now. A possible workaround for triggering it via Python is to send a HTTP request directly to the airflow instance in your Cloud Composer. See Trigger a DAG from Cloud Functions for more details. See Python code that triggers the DAG hosted in Cloud Function.

In this document, the Cloud Function configured to trigger a DAG when a new file is uploaded to the bucket. If that don't fit your use case, you can always change the trigger type of the Cloud Function that will fit to with your use case.

Upvotes: 1

Related Questions