本页介绍了存储 Cloud Composer 中使用的经过修补的 Apache Airflow 代码的代码库。
代码库简介
Composer-Airflow 代码库是一个只读代码库,其中包含在 Cloud Composer 中运行的经过修补的 Apache Airflow 代码。
Cloud Composer 中特定版本的 Apache Airflow 并不总是与上游 Airflow 中的相应版本完全匹配,因为 Cloud Composer 使用的是 Airflow 的修补版本。此代码库包含 Cloud Composer 中使用的每个 Airflow 修补版本的代码。如需了解 Cloud Composer 中找到的 Airflow 版本,请参阅 Cloud Composer 版本列表。
投稿
此代码不是 Apache Airflow 的分支。此代码库中的代码直接来自 Apache Airflow 代码库,但其时间轴与常规 Apache Airflow 版本不同。
如果您想为此代码库做贡献,请改为直接向 Airflow 贡献。请勿在此代码库中执行此操作,因为该代码库不接受拉取请求。
问题和支持
- 如果您在使用此代码库中的代码时遇到问题,可以直接在 Airflow 代码库中创建问题。
- 如果您在使用 Cloud Composer 时遇到问题,请使用 Cloud Composer 支持渠道。
浏览代码库
对于 Cloud Composer 中可用的每个 Airflow 版本,此代码库都有一个分支。并非所有版本的 Airflow 都受 Cloud Composer 支持。您可以在 Cloud Composer 版本列表中查看特定 Cloud Composer 版本支持哪些 Airflow 版本。
用法示例
本部分列出了该代码库的使用示例。
此提交是否来自我的 Cloud Composer 版本中的 Airflow 代码库?
Composer-Airflow 代码库中的提交 SHA1 与上游 Airflow 代码库中的提交 SHA1 不对应。搜索特定提交的方法之一是查找相应的提交消息。
您无法使用 GitHub 界面在默认分支以外的分支中搜索提交消息,但可以使用 git
CLI 执行此操作。如需在此代码库中搜索特定提交,您需要安装 git
。
如需使用 git
CLI 搜索提交消息,请执行以下操作:
使用以下命令克隆代码库并切换到代码库目录:
git clone git@github.com:GoogleCloudPlatform/composer-airflow.git && \ cd composer-airflow
搜索提交消息:
git log --source --grep="COMMIT_MESSAGE" --all
在此命令中:
--source
显示在其中找到提交的分支--grep
指定必须在日志中搜索的消息--all
会在所有分支中搜索
分支位于每个结果第一行中的提交哈希值旁边。如果该命令返回提交,则表示该提交来自您的 Cloud Composer 版本。此外,如果您环境中的 Airflow 版本高于该分支版本,则该提交会在您环境的 Airflow 版本中使用。
例如,如果要搜索提交消息 Force explicit choice on GPL dependency
,则命令为:
git log --source --grep="Force explicit choice on GPL dependency" --all
如果有匹配的提交,则结果将如下所示的输出示例所示。可能有多个结果。
commit 64ff1089e30e80b08bf5155edd9e49f5293ebbe4 refs/heads/<strong>1.10.2</strong>
Author: example_airflow_committer <example_airflow_committer@users.noreply.github.com>
Date: Wed Aug 1 11:25:31 2018 +0200
[AIRFLOW-2817] Force explicit choice on GPL dependency (#3660)
By default one of Apache Airflow's dependencies pulls in a GPL
library. Airflow should not install (and upgrade) without an explicit choice.
This is part of the Apache requirements as we cannot depend on Category X
software.
(cherry picked from commit c37fc0b6ba19e3fe5656ae37cef9b59cef3c29e8)
Signed-off-by: Example Airflow Committer <example_airflow_committer@users.noreply.github.com>
(cherry picked from commit b39e4532d9d1086c60b31553d08972bcc68df641)
Signed-off-by: Example Airflow Committer <example_airflow_committer@users.noreply.github.com>
GitOrigin-RevId: cefcf4c61f64be3792cbfed509b82a9eb4cc47be
此 Airflow 操作符在我的 Cloud Composer 版本中是什么样的?
Airflow 运算符和随附的代码与 PyPI 软件包中的核心 Airflow 分开封装和发布,称为提供程序软件包。
Cloud Composer 中默认安装了其中一些软件包。如需了解您的环境中安装了哪个版本,请查看版本列表中您环境的 Cloud Composer 版本的软件包列表。
GitHub 界面
如需查看特定提供程序软件包版本中 Operator 的代码,请执行以下操作:
在 GitHub 搜索栏中输入要搜索的 Operator 的名称。
如果返回多个文件,请点击路径以
airflow/providers
开头的代码文件。例如,如果您搜索
GoogleCloudStorageCreateBucketOperator
,请选择airflow/providers/google/cloud/operators/gcs.py
。点击分支选择器,这会打开切换分支/标记下拉列表。
点击代码标签页。
对于
providers
软件包,请在下拉列表的搜索栏中输入以下内容,搜索提供程序的名称和版本:providers-PROVIDER_NAME/PROVIDER_VERSION
PROVIDER_NAME
PROVIDER_VERSION
,其中PROVIDER_NAME
是提供程序的名称,PROVIDER_VERSION
是要查找的版本的名称。例如,如果要查看
apache-airflow-providers-google
软件包的版本10.0.0
,则搜索providers-google/10.0.0
。对于在 Airflow 1 中使用的
backport-providers
软件包,请在下拉列表的搜索栏中搜索backport-providers-PROVIDER_VERSION
。例如,如果要查看
apache-airflow-backport-providers-google
软件包的版本2021.3.3
,则搜索backport-providers-2021.3.3
。点击与您的查询匹配的结果。
屏幕上的代码就是您的 Operator 版本中运行的代码。您还可以点击 History 查看到目前为止的提交历史记录。
git CLI
如需查看特定提供程序软件包版本中 Operator 的代码,请执行以下操作:
对于
providers
软件包,请运行git checkout providers-PROVIDER_NAME/PROVIDER_VERSION
,其中PROVIDER_NAME
是提供程序的名称,PROVIDER_VERSION
是要查找的版本的名称。例如,如果要查看
apache-airflow-providers-google
软件包的版本10.0.0
,则运行git checkout providers-google/10.0.0
。对于在 Airflow 1 中使用的
backport-providers
软件包,请运行git checkout backport-providers-PROVIDER_VERSION
。例如,如果要查看
apache-airflow-backport-providers-google
软件包的版本2021.3.3
,则运行git checkout backport-providers-2021.3.3
。如果您不知道运算符的文件路径,可以使用
git grep
命令进行搜索。以下示例演示了如何搜索 GoogleCloudStorageCreateBucketOperator。git grep GoogleCloudStorageCreateBucketOperator
输出是一个文件列表,可在其中找到字符串(在本例中为 Operator 的名称)。从该列表导航到相应文件并进一步检查其内容。
airflow/contrib/operators/gcs_operator.py:class GoogleCloudStorageCreateBucketOperator(BaseOperator): airflow/contrib/operators/gcs_operator.py: CreateBucket = GoogleCloudStorageCreateBucketOperator( airflow/contrib/operators/gcs_operator.py: super( GoogleCloudStorageCreateBucketOperator, self).__init__(*args, **kwargs) docs/code.rst:.. autoclass:: airflow.contrib.operators.gcs_operator.Google CloudStorageCreateBucketOperator docs/integration.rst:- :ref:`GoogleCloudStorageCreateBucketOperator` : Creates a new cloud storage bucket. docs/integration.rst:.. _GoogleCloudStorageCreateBucketOperator: docs/integration.rst:GoogleCloudStorageCreateBucketOperator docs/integration.rst:.. autoclass:: airflow.contrib.operators.gcs_operator .GoogleCloudStorageCreateBucketOperator tests/contrib/operators/test_gcs_operator.py:from airflow.contrib.operators.gcs_operator import GoogleCloudStorageCreateBucketOperator tests/contrib/operators/test_gcs_operator.py: operator = GoogleCloudStorageCreateBucketOperator(
后续步骤
- 使用 Composer 本地开发 CLI 工具运行本地 Airflow 环境