简体   繁体   中英

How to connect to H2O Deep Water Docker Image from Python?

sorry, yet another real beginner question:

I downloaded the H2O Deep Water Docker container as explained in the Deep Water Booklet ( http://docs.h2o.ai/h2o/latest-stable/h2o-docs/booklets/DeepWaterBooklet.pdf ):

docker run -it --rm -p 54321:54321 -p 8080:8080 -v $PWD:/host opsh2oai/h2o-deepwater-cpu

java -jar /opt/h2o.jar

I started H2O successfully and can access it with Flow UI in my local browser via localhost:54321.

I want to do the MNIST Python example from the above booklet. I use Anaconda and Spyder IDE with Python 2.7.

I think instead of using init(), I assume I have to use the connect() method. Either way does not work, I get TimeOut, Connection Error or HTTP Exception depending on what I try... I tried several IPs (including localhost), eg:

from h2o.estimators.deepwater import H2ODeepWaterEstimator
# Start or connect to H2O
#h2o.init()
h2o.connect(ip="127.0.0.1", port=54321)

My startup logs show the following.

root@d54b0501b7c1:/# java -jar /opt/h2o.jar
08-11 08:46:32.904 172.17.0.2:54321      9      main      INFO: Found XGBoost backend with library: xgboost4j
08-11 08:46:32.926 172.17.0.2:54321      9      main      INFO: ----- H2O started  -----
08-11 08:46:32.928 172.17.0.2:54321      9      main      INFO: Build git branch: (HEAD detached at 0c917c766)
08-11 08:46:32.928 172.17.0.2:54321      9      main      INFO: Build git hash: 0c917c766f28860a19ff3f110e1f405eb9f41623
08-11 08:46:32.928 172.17.0.2:54321      9      main      INFO: Build git describe: jenkins-master-3971
08-11 08:46:32.928 172.17.0.2:54321      9      main      INFO: Build project version: 3.13.0.356 (latest version: 3.14.0.1)
08-11 08:46:32.928 172.17.0.2:54321      9      main      INFO: Build age: 12 days
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Built by: 'jenkins'
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Built on: '2017-07-29 13:31:58'
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Watchdog Build git branch: (unknown)
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Watchdog Build git hash: (unknown)
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Watchdog Build git describe: (unknown)
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Watchdog Build project version: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: Watchdog Built by: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: Watchdog Built on: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: XGBoost Build git branch: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: XGBoost Build git hash: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: XGBoost Build git describe: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: XGBoost Build project version: (unknown)
08-11 08:46:32.931 172.17.0.2:54321      9      main      INFO: XGBoost Built by: (unknown)
08-11 08:46:32.931 172.17.0.2:54321      9      main      INFO: XGBoost Built on: (unknown)
08-11 08:46:32.931 172.17.0.2:54321      9      main      INFO: Processed H2O arguments: []
08-11 08:46:32.931 172.17.0.2:54321      9      main      INFO: Java availableProcessors: 2
08-11 08:46:32.931 172.17.0.2:54321      9      main      INFO: Java heap totalMemory: 31.0 MB
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: Java heap maxMemory: 444.5 MB
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: Java version: Java 1.8.0_131 (from Oracle Corporation)
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: JVM launch parameters: []
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: OS version: Linux 4.9.36-moby (amd64)
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: Machine physical memory: 1.95 GB
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: X-h2o-cluster-id: 1502441188713
08-11 08:46:32.933 172.17.0.2:54321      9      main      INFO: User name: 'root'
08-11 08:46:32.933 172.17.0.2:54321      9      main      INFO: IPv6 stack selected: false
08-11 08:46:32.933 172.17.0.2:54321      9      main      INFO: Possible IP Address: eth0 (eth0), 172.17.0.2
08-11 08:46:32.933 172.17.0.2:54321      9      main      INFO: Possible IP Address: lo (lo), 127.0.0.1
08-11 08:46:32.933 172.17.0.2:54321      9      main      INFO: H2O node running in unencrypted mode.
08-11 08:46:32.943 172.17.0.2:54321      9      main      INFO: Internal communication uses port: 54322
08-11 08:46:32.943 172.17.0.2:54321      9      main      INFO: Listening for HTTP and REST traffic on http://172.17.0.2:54321/
08-11 08:46:32.945 172.17.0.2:54321      9      main      INFO: H2O cloud name: 'root' on /172.17.0.2:54321, discovery address /225.53.128.226:57653
08-11 08:46:32.946 172.17.0.2:54321      9      main      INFO: If you have trouble connecting, try SSH tunneling from your local machine (e.g., via port 55555):
08-11 08:46:32.946 172.17.0.2:54321      9      main      INFO:   1. Open a terminal and run 'ssh -L 55555:localhost:54321 root@172.17.0.2'
08-11 08:46:32.946 172.17.0.2:54321      9      main      INFO:   2. Point your browser to http://localhost:55555
08-11 08:46:32.955 172.17.0.2:54321      9      main      INFO: Log dir: '/tmp/h2o-root/h2ologs'
08-11 08:46:32.957 172.17.0.2:54321      9      main      INFO: Cur dir: '/'
08-11 08:46:33.072 172.17.0.2:54321      9      main      INFO: HDFS subsystem successfully initialized
08-11 08:46:33.085 172.17.0.2:54321      9      main      INFO: S3 subsystem successfully initialized
08-11 08:46:33.088 172.17.0.2:54321      9      main      INFO: Flow dir: '/root/h2oflows'
08-11 08:46:33.142 172.17.0.2:54321      9      main      INFO: Cloud of size 1 formed [/172.17.0.2:54321]
08-11 08:46:33.166 172.17.0.2:54321      9      main      INFO: Registered parsers: [GUESS, ARFF, XLS, SVMLight, AVRO, PARQUET, CSV]
08-11 08:46:33.167 172.17.0.2:54321      9      main      INFO: Watchdog extension initialized
08-11 08:46:33.168 172.17.0.2:54321      9      main      INFO: XGBoost extension initialized
08-11 08:46:33.171 172.17.0.2:54321      9      main      INFO: Registered 2 core extensions in: 341ms
08-11 08:46:33.172 172.17.0.2:54321      9      main      INFO: Registered H2O core extensions: [Watchdog, XGBoost]
08-11 08:46:33.184 172.17.0.2:54321      9      main      INFO: Found XGBoost backend with library: xgboost4j
08-11 08:46:33.702 172.17.0.2:54321      9      main      INFO: Registered: 160 REST APIs in: 529ms
08-11 08:46:33.711 172.17.0.2:54321      9      main      INFO: Registered REST API extensions: [XGBoost, Algos, AutoML, Core V3, Core V4]
08-11 08:46:34.073 172.17.0.2:54321      9      main      INFO: Registered: 230 schemas in 354ms
08-11 08:46:34.073 172.17.0.2:54321      9      main      INFO: H2O started in 5343ms
08-11 08:46:34.073 172.17.0.2:54321      9      main      INFO: 
08-11 08:46:34.075 172.17.0.2:54321      9      main      INFO: Open H2O Flow in your web browser: http://172.17.0.2:54321

What is the right Python code or missing configuration on my Mac / in the Docker container to connect to this H2O Deep Water Docker container?

Seems to be a security / Docker config issue???

h2o.connect(ip="127.0.0.1", port=54321)
Connecting to H2O server at http://127.0.0.1:54321...Traceback (most recent call last):

  File "<ipython-input-12-e78edc3b0d61>", line 1, in <module>
    h2o.connect(ip="127.0.0.1", port=54321)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/h2o.py", line 74, in connect
    cluster_id=cluster_id, cookies=cookies, verbose=verbose)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/connection.py", line 175, in open
    conn._cluster = conn._test_connection(retries, messages=_msgs)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/connection.py", line 414, in _test_connection
    cld = self.request("GET /3/Cloud")

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/connection.py", line 259, in request
    return self._process_response(resp, save_to)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/connection.py", line 574, in _process_response
    data = response.json(object_pairs_hook=H2OResponse)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/requests/models.py", line 877, in json
    self.content.decode(encoding), **kwargs

  File "/Users/kai.waehner/anaconda/lib/python2.7/json/__init__.py", line 352, in loads
    return cls(encoding=encoding, **kw).decode(s)

  File "/Users/kai.waehner/anaconda/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

  File "/Users/kai.waehner/anaconda/lib/python2.7/json/decoder.py", line 380, in raw_decode
    obj, end = self.scan_once(s, idx)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/connection.py", line 691, in __new__
    if schema == "CloudV3": return H2OCluster.from_kvs(keyvals)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/cluster.py", line 47, in from_kvs
    raise AttributeError("Attribute %s cannot be set on H2OCluster (= %r)" % (k, v))

AttributeError: Attribute internal_security_enabled cannot be set on H2OCluster (= False)

Thanks for help.

When you start h2o inside the docker image, and use -p 54321:54321, h2o will be running at localhost:54321 on the machine where you run docker. You can then connect in the normal way with h2o.init(). When init starts it will look for a running h2o -- which you then have -- and connect to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM