H2O Cloud Discovery Python CLient
Project description
h2o-cloud-discovery
H2O Cloud Discovery Client.
Installation
pip install h2o-cloud-discovery
Usage
Package provides two main functions. Synchronous h2o_discovery.discover()
and asynchronous h2o_discovery.discover_async()
. Both functions return
a discovery object that can be used to obtain the information the H2O Cloud
environment, its services and clients.
Both accept a environment
argument that can be used to specify the H2O Cloud
environment for which the discovery should be performed. It's handy when for
local development.
Alternatively, the H2O_CLOUD_ENVIRONMENT
environment variable can be used.
import h2o_discovery
discovery = h2o_discovery.discover()
# Print the H2O Cloud environment that was discovered.
print(discovery.environment.h2o_cloud_environment)
# Connect to the my service.
my_service_client = my_service.client(address=discovery.services["my-service"].uri)
Examples
Example: Use with H2O.ai MLOps Python Client within the Wave App
import h2o_authn
import h2o_discovery
import h2o_mlops_client as mlops
from h2o_wave import Q, app, ui
from h2o_wave import main
@app("/")
async def serve(q: Q):
discovery = await h2o_discovery.discover_async()
token_provider = h2o_authn.AsyncTokenProvider(
refresh_token=q.auth.refresh_token,
issuer_url=discovery.environment.issuer_url,
client_id=discovery.clients["platform"].oauth2_client_id,
)
mlops_client = mlops.Client(
gateway_url=discovery.services["mlops-api"].uri,
token_provider=token_provider,
)
...
Development
Project is managed using Hatch.
Testing
For quick development tests use:
hatch run devtest:pytest
Full test matrix can be run using:
hatch env remove test && hatch run test:pytest
Linting
hatch run lint:check
Formating and imports can be fixed using:
hatch run lint:fix
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file h2o_cloud_discovery-1.1.0.tar.gz
.
File metadata
- Download URL: h2o_cloud_discovery-1.1.0.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a9236bf5a12f9b7b06d0fd542704faee1f853e37dc7994945ede0464d119981 |
|
MD5 | 5662234b4afa8bdd0180008e4e59e046 |
|
BLAKE2b-256 | bb3b19b97e0de8767df7685d488491b5f2f6fe86d6331957f210216e8334a391 |
File details
Details for the file h2o_cloud_discovery-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: h2o_cloud_discovery-1.1.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84dfe008400698b697e7266db7c750621427622380e8cd53fbc422e0a17ab20b |
|
MD5 | c2abe35d009b3754701eb970c62bb696 |
|
BLAKE2b-256 | e7ad08b7dd686e57a74d6e3c5a8ae376978d56b51c5fd247c442ad797c91cd2e |