Connect to a Driverless AI server created by AI Enginer Manager in H2O AI Cloud¶
Prerequisites¶
h2o
CLI- Download the h2o cli from https://h2oai-cloud-release.s3.amazonaws.com/releases/ai/h2o/h2o-cloud/latest/index.html
- Move the h2o cli to
/usr/local/bin
- Update permission of h2o cli
chmod +x /usr/local/bin/h2o
- Python environment with
h2o-engine-manager
andh2o-authn
pip install h2o-authn~=1.0 h2o-engine-manager
H2O CLI configuration setup¶
- Run
h2o config setup
and enter the Endpoint URL, OIDC URL, and Client ID from your cloud-qa account. (Visit https://cloud-qa.h2o.ai/cli-and-api-access#cli-info) - To update the platform token, run
h2o config update-platform-token
. - You can have multiple config files for different cloud environments (https://docs.h2o.ai/h2o-ai-cloud/developerguide/cli#using-multiple-config-files).
In [1]:
Copied!
import h2o_engine_manager
# Log in to AI Engine Manager (AIEM)
aiem = h2o_engine_manager.login(
config_path="/path/to/.h2oai/h2o-cli-config.toml"
)
import h2o_engine_manager
# Log in to AI Engine Manager (AIEM)
aiem = h2o_engine_manager.login(
config_path="/path/to/.h2oai/h2o-cli-config.toml"
)
In [2]:
Copied!
# List DAI engines at AIEM
aiem.dai_engine_client.list_engines()
# List DAI engines at AIEM
aiem.dai_engine_client.list_engines()
Out[2]:
{'engines': [{'annotations': {}, 'api_url': 'https://enginemanager.cloud-qa.h2o.ai/workspaces/default/daiEngines/python-client-test', 'client_info': <h2o_engine_manager.clients.dai_engine.client_info.ClientInfo object at 0x7fb8d29dd950>, 'config': {}, 'cpu': 2, 'create_time': datetime.datetime(2023, 5, 18, 11, 55, 48, tzinfo=tzutc()), 'creator': 'users/e5c28181-4e61-4b40-a9eb-6f214c80bf0c', 'creator_display_name': 'muraleetharan.mathanraj@h2o.ai', 'delete_time': None, 'display_name': 'python-client-test', 'engine_id': 'python-client-test', 'gpu': 0, 'login_url': 'https://enginemanager.cloud-qa.h2o.ai/workspaces/default/daiEngines/python-client-test/oidc/login', 'max_idle_duration': '1h', 'max_running_duration': '5d', 'memory_bytes': '8Gi', 'name': 'workspaces/default/daiEngines/python-client-test', 'reconciling': False, 'resume_time': datetime.datetime(2023, 5, 18, 11, 55, 48, tzinfo=tzutc()), 'state': <DAIEngineState.STATE_RUNNING: 'STATE_RUNNING'>, 'storage_bytes': '8Gi', 'uid': '9beb60fd-3b31-44cf-9b55-89cc12520fbb', 'update_time': None, 'upgrade_available': False, 'version': '1.10.5', 'workspace_id': 'default'}], 'next_page_token': '', 'total_size': 1}
In [3]:
Copied!
# Get DAI engine at AIEM using indentifier
dai_engine_client = aiem.dai_engine_client
dai_engine = dai_engine_client.get_engine("python-client-test")
# Get DAI engine at AIEM using indentifier
dai_engine_client = aiem.dai_engine_client
dai_engine = dai_engine_client.get_engine("python-client-test")
In [4]:
Copied!
# Connect to dai engine and get client
dai_client = dai_engine.connect()
# Connect to dai engine and get client
dai_client = dai_engine.connect()
In [5]:
Copied!
# Perform any driverlessai python client operation using the client
# (Example) Create dataset
data_key = dai_client.datasets.create("~/datasets/BostonHousing_JpCols.csv", force=True)
# Perform any driverlessai python client operation using the client
# (Example) Create dataset
data_key = dai_client.datasets.create("~/datasets/BostonHousing_JpCols.csv", force=True)
Complete 100.00% - [4/4] Computed stats for column 犯罪率
In [6]:
Copied!
# (Example) List datasets
dai_client.datasets.list()
# (Example) List datasets
dai_client.datasets.list()
Out[6]:
| Type | Key | Name ----+---------+--------------------------------------+-------------------------- 0 | Dataset | 5332f63a-f573-11ed-b32e-d644a294ba9c | BostonHousing_JpCols.csv
In [ ]:
Copied!