代码之家  ›  专栏  ›  技术社区  ›  JY2k

云生成器解析json

  •  0
  • JY2k  · 技术社区  · 7 年前

    我导入了一个简单的json file into the data folder

    1 回复  |  直到 7 年前
        1
  •  1
  •   Aurélien Valade    7 年前

    gs://composer bucket/data文件夹融合到airlow的/home/airlow/gcs/data目录(如此处所指定 https://cloud.google.com/composer/docs/concepts/cloud-storage#folders_in_the_storage_name_bucket )

    例如,如果需要将其加载到某个PythonOperator任务定义中,可以使用非常简单的以下代码:

    import json
    with open('/home/airflow/gcs/data/my_file.json', 'r') as f:
        d = json.load(f)
    

    这是你能做到的一种方法。

    根据需要加载的内容和使用方式,您可能还需要查看airlow变量,而不是JSON文件。( https://airflow.apache.org/concepts.html#variables )

    推荐文章