Search code examples
h2osparkling-water

How to change port of web UI with pysparkling


I'm just trying to get pysparkling working, but change the port of the web UI. I've looked in the help files and they seem to reference old versions of sparkling water. Currently am running

from pysparkling import *

hc = H2OContext.getOrCreate(spark)

and is starting up on the default 54321 port. I see there is a conf object to pass in, but am unsure of how to set this correctly. Any help would be appreciated.


Solution

  • This is the script you can use the launch the H2O cluster on a different port:

    ## Importing Libraries
    from pysparkling import *
    import h2o
    
    ## Setting H2O Conf Object
    h2oConf = H2OConf(sc)
    h2oConf
    
    ## Setting H2O Conf for different port
    h2oConf.set_client_port_base(54300)
    h2oConf.set_node_base_port(54300)
    
    ## Gett H2O Conf Object to see the configuration
    h2oConf
    
    ## Launching H2O Cluster
    hc = H2OContext.getOrCreate(spark, h2oConf)
    
    ## Getting H2O Cluster status
    h2o.cluster_status()
    

    I have also written a blog post to explain it in details.