Initialization
To interact with the H2O Notebook Labs, you need to authenticate first. There are several options available:
Using the H2O Notebook Labs
If you are using the H2O Notebook Labs, your environment is already configured.
import h2o_notebook
clients = h2o_notebook.login()
Using the H2O CLI
On your local machine, the recommended way is to download and configure the H2O CLI. Visit the CLI & API Access section of H2O AI Cloud to get started. For more information, see Using the H2O CLI in the AI App Store documentation.
Verify your installation by running:
h2o platform token-info
With the H2O AI Cloud CLI configured, you can log in without providing any arguments.
import h2o_notebook
clients = h2o_notebook.login()
If your H2O AI Cloud CLI configuration file is in a non-standard location, you can pass the path using config_file
argument.
import h2o_notebook
clients = h2o_notebook.login(config_path="/path/to/h2o-cli-config.toml")
Using the Platform Token
Log in to the H2O AI Cloud and visit the CLI & API Access section. This page will allow you to generate a platform token and provide a code example for you.
In a Wave app
Production
For Wave version 0.25.2 and later when deploying to H2O AI Cloud, use:
from h2o_wave import app, Q, main
import h2o_notebook
@app('/')
async def serve(q: Q):
clients = await q.run(h2o_notebook.login,
token_provider=q.auth.ensure_fresh_token_sync,
)
Development
For a local development of Wave apps, follow the Using the H2O CLI instructions above.
Custom
You can log in manually using the login_custom
function.
This is useful if you want to authenticate outside the H2O AI Cloud environment.
import h2o_notebook
clients = h2o_notebook.login_custom(
endpoint="https://notebook.cloud-dev.h2o.ai",
refresh_token="my-secret-refresh-token",
client_id="oidc-app-client-id",
client_secret="oidc-app-secret",
issuer_url="https://auth.cloud-dev.h2o.ai/auth/realms/hac-dev"
)
- Submit and view feedback for this page
- Send feedback about H2O Notebook Labs to cloud-feedback@h2o.ai