本文介绍了在GC Composer DAG中将Cloud Functions用作运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

资深编码员,

对于我有兴趣使用 Google Cloud Composer 的项目来处理多个工作流,这些工作流可以在工作流之间共享的操作的集合.

For a project I'm interested in using Google Cloud Composer to handle several workflows that consist of operations that can be shared between workflows.

在我看来,云功能是在Composer中执行这些操作的理想方法, DAG .

It seems to me that Cloud Functions are a perfect way of performing tasks as these operations in a Composer DAG.

据我所知,我需要一个运算符,该运算符使用特定DAG中任务的特定数据来调用云函数.

For what I understood of it, I would need an operator that invokes a cloud function with data that is specific for the task in the specific DAG.

我在 Airflow文档中找到了Google Cloud Function运算符但是,这些仅用于部署和删除云功能,而不能用于调用它们.

I found a Google Cloud Function operator in the Airflow documentation, however, these are only for deploying and deleting cloud functions, but not for invoking them.

关于从云功能,但是似乎没有关于将云功能用作DAG中的操作的任何文章.

A lot has been written about invoking DAGs from a cloud function, but nothing seems to be written about using cloud functions as operations within a DAG.

用例示例:
每次将文档放在某个存储桶中时,我都想启动DAG工作流程来分析该文档.该DAG可以包含各种任务,例如提取文档的发件人,徽标的分类或搜索特定的单词.对于这些单独的任务,我想创建在DAG中缝合在一起的单独的云功能以组成我的工作流程.

Example use case:
Every time a document is placed in a certain bucket I want to start a DAG workflow to analyse this document.This DAG can consist of various tasks, such as extraction of the sender of the document, classification of a logo, or searching for specific words. For these separate tasks, I want to create separate cloud functions that are stitched together in a DAG to compose my workflows.

问题:
如何在Google Composer DAG中调用云功能?
人们对此有经验还是可以找到示例代码?

Question:
How to invoke cloud functions from within a Google Composer DAG?
Do people have experience with this or have sample code available?

谢谢.

推荐答案

HTTP触发器可用于运行Cloud Functions,因此您可以使用 HTTP运算符. DAG运行的任务(调用Cloud Function触发器)比运行该函数.

HTTP Triggers can be used to run Cloud Functions, so you can invoke them from a DAG using the HTTP operator. The DAG runs the task, that calls the Cloud Function trigger, than runs the function.

这篇关于在GC Composer DAG中将Cloud Functions用作运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 22:03