Giter Site home page Giter Site logo

google-cloud-functions-triggered-airflow-dags's Introduction

Cloud Functions Triggered DAGs

The following guide walks through the entire worflow on how to trigger a dag using Cloud Functions

Step 1. Make a Cloud Composer Environment (link)

Spin up a Google Cloud Compose Environment (link)

gcloud composer environments create composer1 \
    --location euope-west2

Determine the storage bucker assosciated with the environment (link)

gcloud composer environments describe compose 1 \
  --location europe-west2 \
  --format="get(config.dagGcsPrefix)"

Step 2. Set up Google Cloud Functions to trigger dags (link)

The google cloud functions needs to be deployed to trigger the dags on any changes in the environment. We create a cloud function called gcs-dag-trigger-function on using the above mentioned guide.

For creating the function, we need the following parameters from the composer environment

  • client_id : Client id (can be fetched by running the scrip get_client.py in the main directory)
  • webserver_id : URL of the web server on which airflow is currently running (here)
  • dag_name: The name of the dag which is triggered (discussed below; here it is called composer_sample_trigger_response_dag schedule)

Step 3. Putting together the DAG definition

Once the above steps are done, the entire dag configuration is defined in the main folder in the file trigger_dag.py with the dag named as composer_sample_trigger_response_dag schedule

To push the latest version of the dag to the composer environment, run the following command in the main folder containing the dag file:

gcloud composer environments storage dags import \
                            --environment composer1 \
                            --location europe-west2 \
                            --source trigger_dag.py 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.