在 Google Cloud 功能中使用 eccodes

问题描述 投票:0回答:1

我编写了一个使用 Xarray 和 Cfgrib 打开 .grib2 文件的 Python 程序。 Cfgrib 有 eccodes 作为依赖项。可以使用 conda 安装 ECcodes,但我无法在 Google Cloud Function 中使用该方法。 eccodes pip 包仅包含绑定,实际包必须手动安装:https://confluence.ecmwf.int/display/ECC/ecCodes+installation。我能够在本地构建和安装 eccodes(使用 conda 和手动 install+pip 绑定),但我一直在尝试在 Google Cloud 中安装 eccodes。

预先感谢您的帮助!

python google-cloud-platform pip google-cloud-functions
1个回答
0
投票

Cloud Functions 不支持无法使用

pip
安装或与代码一起打包的自定义包。

Cloud Run 会更适合您的要求,因为它允许使用 Dockerfile,您可以在其中指定自定义操作来安装 ecCode 依赖项。生成的服务可以具有与云功能相同的特征(缩放到零、http/pubSub/eventarc 触发器等)

示例 Dockerfile 片段

ARG ECBUILD_VERSION=3.3.2
RUN set -eux \
    && mkdir -p /src/ \
    && cd /src \
    && git clone https://github.com/ecmwf/ecbuild.git \
    && cd ecbuild \
    && git checkout ${ECBUILD_VERSION} \
    && mkdir -p /build/ecbuild \
    && cd /build/ecbuild \
    && cmake /src/ecbuild -DCMAKE_BUILD_TYPE=Release \
    && make -j4 \
    && make install

示例项目:https://github.com/DeutscherWetterdienst/python-eccodes/blob/master/Dockerfile

部署命令

gcloud run deploy SERVICE_NAME --source .
© www.soinside.com 2019 - 2024. All rights reserved.