【问题标题】:How to import a file from Google Cloud Storage to H2O running in R如何将文件从 Google Cloud Storage 导入在 R 中运行的 H2O
【发布时间】:2020-01-22 20:58:31
【问题描述】:

我想将我的 Google Cloud Storage 存储桶中的 csv 文件导入在本地 R 中运行的 H2O (h2o.init(ip = "localhost"))。

我尝试按照http://docs.h2o.ai/h2o/latest-stable/h2o-docs/cloud-integration/gcs.html?highlight=environment 的说明进行操作。

我已经可以使用 R 包 cloudml 将 csv 文件从 R 上传到 GCS,反之亦然。所以我有理由确定我的授权设置正确。

我尝试过使用Sys.setenv(GOOGLE_APPLICATION_CREDENTIALS = "/full/path/to/auth.json")。我尝试使用 Rstudio 的终端来做同样的事情:export GOOGLE_APPLICATION_CREDENTIALS="/full/path/to/auth.json"。我还使用 Rstudio 的终端尝试了gcloud auth application-default login

但在任何情况下,我都无法在 Rstudio 中完成这项工作:

h2o.init()
h2o::h2o.importFile(path = "gs://[gcs_bucket]/[tbl.csv], 
                    destination_frame = "tbl_from_gcs")

H2O 抛出错误:

Error in h2o.importFolder(path, pattern = "", destination_frame = destination_frame,  : 
   all files failed to import

如果我打开日志记录 (h2o::h2o.startLogging("logfile")),它会显示:

GET       http://localhost:54321/3/ImportFiles?path=gs%3A%2F%2F[gcs_bucket]%2F[tbl.csv]&pattern=
postBody: 

curlError:         FALSE
curlErrorMessage:  
httpStatusCode:    200
httpStatusMessage: OK
millis:            182

{"__meta":{"schema_version":3,"schema_name":"ImportFilesV3","schema_type":"ImportFiles"},"_exclude_fields":"","path":"gs://[gcs_bucket]/[tbl.csv]","pattern":"","files":[],"destination_frames":[],"fails":["gs://[gcs_bucket]/[tbl.csv]"],"dels":[]}

(显然,我更改了存储桶名称和表名称,但希望您明白。)

我在 R 3.6.1 和 Rstudio 1.2.1578 中运行 h2o 版本 3.26.0.2。 (我在本地服务器上的 Docker 中运行 Rstudio 服务器,使用的是 rocker/tidyverse:latest,仅供参考。)

如果有人可以指导我完成对 H2O 进行身份验证的步骤,以便它可以直接访问 GCS 存储桶,我将不胜感激。我知道我可以使用 cloudml 或 googleCloudStorageR 作为解决方法,但我希望能够直接使用 H2O,这样我就可以更轻松地从本地 H2O 集群切换到云 H2O 集群。

【问题讨论】:

    标签: google-cloud-storage h2o


    【解决方案1】:

    我找到了一个解决这个身份验证问题的方法:因为我在 Docker swarm 中运行 h2o,所以我可以在 Docker Compose 中为容器设置一个环境变量。

    docker compose 文件的相关部分如下所示:

    environment:
      - GOOGLE_APPLICATION_CREDENTIALS=/run/secrets/google_auth_secret
    secrets:
      - google_auth_secret
    ...
    
    secrets:
      google_auth_secret:
        file: ./gcloud_auth.json
    

    其中 gcloud_auth.json 是为您的 GCS 存储桶描述的凭据文件 here

    【讨论】:

      猜你喜欢
      • 2021-08-03
      • 2023-04-08
      • 2021-07-27
      • 2019-06-04
      • 2012-01-02
      • 1970-01-01
      • 2020-12-01
      • 2020-05-05
      • 1970-01-01
      相关资源
      最近更新 更多