我想从我的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和RStudio1.2.1578中运行h2o版本3.26.0.2。(我在本地服务器上的Docker中使用rocker/tidyverse:latest,FYI运行Rstudio服务器。)
如果有人能指导我完成H2O身份验证的步骤,以便它可以直接访问GCS bucket,我将不胜感激。我知道我可以使用cloudml或googleCloudStorageR作为变通方法,但我希望能够直接使用H2O,这样我就可以更容易地从本地H2O集群切换到云H2O集群。
发布于 2019-10-07 07:15:18
我找到了这个身份验证问题的一个解决方案:因为我在Docker swarm中运行h2o,所以我可以在Docker Compose中为容器设置一个环境变量。
docker组合文件的相关部分如下所示:
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。
https://stackoverflow.com/questions/58051432
复制相似问题