0

If I start H2O using Jetty HashLoginService (i.e. -hash_login -login_conf realm.properties) in order to protect my H2O instance with password, I cannot convert H2O object into R object.

For example in the following as.data.frame will not work, as if would work if I didn't use HashLoginService:

> require(h2o)
> h2o.init(port     = 54324,  startH2O = F, 
           password = "pass", username = "uname")
 Connection successful!

R is connected to the H2O cluster: 
    H2O cluster uptime:         5 days 15 hours 
    H2O cluster version:        3.9.1.3405 
    H2O cluster name:           uname 
    H2O cluster total nodes:    1 
    H2O cluster total memory:   22.19 GB 
    H2O cluster total cores:    8 
    H2O cluster allowed cores:  2 
    H2O cluster healthy:        TRUE 
    H2O Connection ip:          localhost 
    H2O Connection port:        54324 
    H2O Connection proxy:       NA 
    R Version:                  R version 3.1.1 (2014-07-10)

> packageVersion("h2o")
[1] ‘3.9.1.3405’

> df  <- data.frame(a = c(0.2, 0.3, 0.1, 0.5, 0.1, 0.2),
                    b = c(0.1, 0.1, 0.7, 0.3, 0.2, 0.9))

> h2o_df <- as.h2o(df, "h2o_df")
  |==============================================================================| 100%

> head(h2o_df)
     a    b
1  0.2  0.1
2  0.3  0.1
3  0.1  0.7
4  0.5  0.3
5  0.1  0.2
6  0.2  0.9

> class(h2o_df)
[1] "H2OFrame"

> as.data.frame(h2o_df)
                                                                X.html.
1                                                                <head>
2  <meta http-equiv=Content-Type content=text/html;charset=ISO-8859-1/>
3                                 <title>Error 401 Unauthorized</title>
4                                                               </head>
5                                                                <body>
6                                              <h2>HTTP ERROR: 401</h2>
7                      <p>Problem accessing /3/DownloadDataset. Reason:
8                                       <pre>    Unauthorized</pre></p>
9                       <hr /><i><small>Powered by Jetty://</small></i>
10                                                                     
11                                                                     
12                                                                     
13                                                                     
14                                                                     
15                                                                     
16                                                                     
17                                                                     
18                                                                     
19                                                                     
20                                                                     
21                                                                     
22                                                                     
23                                                                     
24                                                                     
25                                                                     
26                                                                     
27                                                                     
28                                                                     
29                                                                     
30                                                              </body>
31                                                              </html>
Warning message:
In read.table(file = file, header = header, sep = sep, quote = quote,  :
  cols = 1 != length(data) = 11

Any idea how to resolve this problem?


UPDATE

This is a bug and you can track it here: https://0xdata.atlassian.net/browse/PUBDEV-2968

4
  • are you passing the username and password parameters to h2o.init()? Commented May 31, 2016 at 7:25
  • @MateuszDymczyk Yes! I edited the question.
    – A.GH
    Commented May 31, 2016 at 7:47
  • seems it might be a bug in as.data.frame (looks like it might not be using the credentials) - will consult the the team and get back to you! Commented May 31, 2016 at 8:15
  • @MateuszDymczyk since I needed a solution right now, I wrote a workaround, see my answer below. It might be helpful for the developer team fixing the bug.
    – A.GH
    Commented May 31, 2016 at 9:58

1 Answer 1

0

So far seems to be a bug.

In as.data.frame.H2OFrame function getURL (from RCurl package) is called to retrieve the data from H2O server.

This function is used without passing any credentials.

One workaround would be to alter this function and replace getURL(url) with

ttt <- getURL(url, userpwd=paste0(conn@username,':',conn@password), httpauth = 1L)

Or check if username is given use the latter otherwise use the former.

A complete example how to use it is given here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.