2

通过以下方式导入运算符:

from airflow.contrib.operators.gcs_download_operator import GoogleCloudStorageDownloadOperator

然后尝试在 DAG 中使用它:

download_file =  GoogleCloudStorageDownloadOperator(bucket='us-central1-scale-training-d7d12089-bucket',
    google_cloud_storage_conn_id='google_cloud_default',
    object='params.json',
    filename='params.json')  

收到此错误:

未定义“GoogleCloudStorageDownloadOperator”

编辑:我使用的是 Google Cloud Composer,所以我假设安装了相关的依赖项。

4

1 回答 1

1

如果您还没有,您还需要将 GCP 依赖项添加到 Airflow:

pip install apache-airflow[gcp_api]

文档中有更多关于安装的信息:https ://airflow.apache.org/installation.html

于 2018-09-10T16:21:57.123 回答