Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation on how to connect to H2O cluster by Name #6811

Closed
exalate-issue-sync bot opened this issue Apr 28, 2023 · 4 comments
Closed

Add documentation on how to connect to H2O cluster by Name #6811

exalate-issue-sync bot opened this issue Apr 28, 2023 · 4 comments
Assignees

Comments

@exalate-issue-sync
Copy link

No description provided.

@exalate-issue-sync
Copy link
Author

Wendy Wong commented: Please add this from Megan:

Hi Sateesh,

Here is how you can connect through the name in a programmatic way:

Script 1

Start a cluster and save the cluster information.

{noformat}# Create cluster called 'second-cluster'
cluster_name = 'second-cluster'
import h2o
h2o.init(name=cluster_name)

import json
def save_cluster_details(cluster):
    cluster_details = cluster.get_status().as_data_frame().iloc[0]
    name = cluster_details.H2O_cluster_name
    url = cluster_details.H2O_connection_url
    
    file_path = '{}.json'.format(name)
    with open(file_path, 'w') as fp:
        json.dump(url, fp)

    return file_path

save_cluster_details(h2o.cluster())
'second-cluster.json'{noformat}

Script 2

Connect to cluster by importing the cluster details that were saved.

{noformat}import h2o
import json

cluster_name = 'second-cluster'

Load the url

with open('{}.json'.format(cluster_name), 'r') as fp:
    url = json.load(fp)

connect via the url

h2o.connect(url=url){noformat}

Essentially what is happening is that we are saving the connection details where the file name is the cluster name. The connection details are then programmatically picked up by the cluster name.

Let me know if this would work for your scenario.  

Thanks!

Megan

@wendycwong
Copy link
Contributor

Done.

@h2o-ops
Copy link
Collaborator

h2o-ops commented May 10, 2023

JIRA Issue Details

Jira Issue: PUBDEV-8990
Assignee: hannah.tillman
Reporter: Wendy Wong
State: Resolved
Fix Version: 3.40.0.2
Attachments: N/A
Development PRs: Available

@h2o-ops
Copy link
Collaborator

h2o-ops commented May 10, 2023

Linked PRs from JIRA

#6488

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants