Cloud Composer 的 Airflow 程式碼存放區

本頁面說明儲存修補 Apache Airflow 程式碼的存放區,這些程式碼用於 Cloud Composer。

關於存放區

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 貢獻心力。請勿在這個存放區中執行這項操作,因為系統不接受其中的提取要求。

問題與支援

這個存放區的每個分支都對應一個 Cloud Composer 提供的 Airflow 版本。Cloud Composer 不支援所有版本的 Airflow。如要查看特定 Cloud Composer 版本支援的 Airflow 版本,請參閱 Cloud Composer 版本清單

使用範例

本節列出存放區的使用範例。

這個 Cloud Composer 版本是否包含 Airflow 存放區的這項提交內容?

Composer-Airflow 存放區中的修訂版本 SHA1 不對應至上游 Airflow 存放區中的修訂版本 SHA1。如要搜尋特定修訂版本,其中一種方法是尋找相應的修訂版本訊息。

您無法使用 GitHub UI 搜尋預設分支以外的分支中的提交訊息,但可以使用 git CLI 執行這項操作。如要在這個存放區中搜尋特定提交,您需要git

如要使用 git CLI 搜尋提交訊息,請按照下列步驟操作:

  1. 使用下列指令複製存放區,並切換至存放區目錄:

    git clone git@github.com:GoogleCloudPlatform/composer-airflow.git && \
    cd composer-airflow
    
  2. 搜尋修訂訊息:

    git log --source --grep="COMMIT_MESSAGE" --all
    

    在這個指令中:

    • --source 會顯示找到該提交內容的分支
    • --grep:指定要在記錄中搜尋的訊息
    • --all 會在所有分支中搜尋
  3. 分支位於每個結果的第一行,與提交雜湊相鄰。如果指令傳回提交內容,表示該提交內容位於您的 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 使用者介面

如要查看特定供應商套件版本的運算子程式碼,請按照下列步驟操作:

  1. 前往上游 Airflow 存放區

  2. 在 GitHub 搜尋列中輸入要搜尋的運算子名稱。

  3. 如果傳回多個檔案,請按一下路徑開頭為 airflow/providers 的程式碼檔案。

    舉例來說,如果搜尋 GoogleCloudStorageCreateBucketOperator,然後選擇 airflow/providers/google/cloud/operators/gcs.py

  4. 按一下分支選取器,開啟「切換分支/標記」下拉式清單。

  5. 按一下「標記」分頁標籤。

  6. 如要尋找 providers 套件,請在下拉式清單的搜尋列中輸入 providers-PROVIDER_NAME/PROVIDER_VERSION,其中 PROVIDER_NAME 是供應商名稱,PROVIDER_VERSION 則是您要尋找的版本名稱。

    舉例來說,如要查看 apache-airflow-providers-google 套件的 10.0.0 版本,請搜尋 providers-google/10.0.0

  7. 如要使用 Airflow 1 中的 backport-providers 套件,請在下拉式清單的搜尋列中搜尋 backport-providers-PROVIDER_VERSION

    舉例來說,如要查看 apache-airflow-backport-providers-google 套件的 2021.3.3 版本,請搜尋 backport-providers-2021.3.3

  8. 按一下與查詢相符的結果。

  9. 畫面上的程式碼是該運算子版本中執行的內容。您也可以按一下「記錄」,查看此時間點之前的修訂記錄。

git CLI

如要查看特定供應商套件版本的運算子程式碼,請按照下列步驟操作:

  1. 複製上游 Airflow 存放區

  2. 如果是 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

  3. 如要使用 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

  4. 如果您不知道運算子的檔案路徑,可以使用 git grep 指令搜尋。以下範例說明如何搜尋 GoogleCloudStorageCreateBucketOperator。

    git grep GoogleCloudStorageCreateBucketOperator
    

    輸出內容會列出含有該字串 (在本例中為運算子名稱) 的檔案。從該清單中找出檔案,並進一步檢查內容。

    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(
    

後續步驟