使用Airflow-Python从本地系统将文件上传到Google Bucket

时间:2018-09-07 15:14:15

标签: python google-cloud-platform google-cloud-datastore google-cloud-storage airflow

因此我正在以气流方式运行此操作符

from airflow.contrib.operators.file_to_gcs import FileToGoogleCloudStorageOperator

gcp_operator = \
    FileToGoogleCloudStorageOperator(
        task_id='gcp_task',
        src='/Users/john/Documents/tmp',
        dst='gs://constantine-bucket',
        bucket='constantine-bucket',
        google_cloud_storage_conn_id='DataScience',
        mime_type='Folder',
        dag=dag
    )

运行此命令时出现错误

"error": "invalid_scope",
"error_description": "\u0026quot;https://www.googleapis.com/auth/devstorage.read_write\u0026quot; is not a valid audience string

有人知道如何在气流上运行该操作员吗?

1 个答案:

答案 0 :(得分:5)

听起来像缺少依赖项。您应该能够使用以下命令安装GCP挂钩和操作符:

pip install apache-airflow[gcp_api]

有关更多信息,请参阅以下页面:https://airflow.apache.org/installation.html