是否可以在 Google Cloud Composer 上安装 github 存储库

Is it possible to install github repository on Google Cloud Composer

如题,我们可以在requirements.txt文件中设置pypi包,使用命令

gcloud beta composer environments update env_name --update-pypi-packages-from-file requirements.txt --location location

更新云作曲家环境。

但是它支持在 requirements.txt 中安装自定义 github 存储库吗?我试过添加 link 像:

pkg_name @ git+ssh://git@github.com/my_account/pkg_repo.git#master

它不起作用。

谢谢!

更新: 我有一个解决方法是将库放入插件中。但在我们的案例中,最好的策略是我认为从 github 安装一个包。

不,它不支持以这种方式安装自定义库。 In docs here you can see how --update-pypi-packages is intended to be used only with libraries which are in the Python Package Index:

You can install Python dependencies from the Python Package Index through the Google Cloud Platform Console or by making a partial update request to the environment using the gcloud command-line tool.

您有三个备选方案:

Install a local Python library.

Use the plugins feature.

Use the KubernetesPodOperator.

使用 local Python library 安装非常简单: 1. 在您的 Composer GCS 存储桶中,在 dags 文件夹中创建一个 dependencies 文件夹并在其中添加您的库模块(不要忘记添加必要的“init.py “文件)。 2. 然后简单地做这样的事情:

from dependencies import your_module