Name | h2o-mlops JSON |
Version |
1.1.2
JSON |
| download |
home_page | None |
Summary | Python client for H2O MLOps. |
upload_time | 2024-11-27 12:40:54 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | Apache v2 |
keywords |
h2o
mlops
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# An H2O MLOps Python Client for Regular Folks
This project is a work in progress and the API may change. Please send questions or feedback to support@h2o.ai.
## Example
```
import h2o_mlops
import httpx
import time
```
First we have to connect to MLOps. In this example the client is detecting credentials and configuration options from the environment.
```
mlops = h2o_mlops.Client()
```
### Everything Starts with a Project
A project is the main base of operations for most MLOps activities.
```
project = mlops.projects.create(name="demo")
```
```
mlops.projects.list(name="demo")
```
| name | uid
----+--------+--------------------------------------
0 | demo | 45e5a888-ec1f-4f9c-85ca-817465344b1f
You can also do `project = mlops.projects.get(...)`.
### Upload an Experiment
```
experiment = project.experiments.create(
data="/Users/jgranados/Downloads/GBM_model_python_1649367037255_1.zip",
name="experiment-from-client"
)
```
Some experiment attributes of interest.
```
experiment.scoring_artifact_types
```
['h2o3_mojo']
```
experiment.uid
```
'e307aa9f-895f-4b07-9404-b0728d1b7f03'
Existing experiments can be viewed and retrieved.
```
project.experiments.list()
```
| name | uid | tags
----+------------------------+--------------------------------------+--------
0 | experiment-from-client | e307aa9f-895f-4b07-9404-b0728d1b7f03 |
You can also do `experiment = projects.experiments.get(...)`.
### Create a Model
```
model = project.models.create(name="model-from-client")
```
Existing models can be viewed and retrieved.
```
project.models.list()
```
| name | uid
----+-------------------+--------------------------------------
0 | model-from-client | d18a677f-b800-4a4b-8642-0f59e202d225
You can also do `model = projects.models.get(...)`.
### Register an Experiment to a Model
In order to deploy a model, it needs to have experiments registered to it.
```
model.register(experiment=experiment)
```
```
model.versions()
```
| version | experiment_uid
----+-----------+--------------------------------------
0 | 1 | e307aa9f-895f-4b07-9404-b0728d1b7f03
```
model.get_experiment(model_version="latest").name
```
'experiment-from-client'
### Deployment
#### What is needed for a single model deployment?
- project
- model
- environment
- scoring runtime
- name for deployment
We already have a `project` and `model`. Let us look at how to get the `environment`.
```
project.environments.list()
```
| name | uid
----+--------+--------------------------------------
0 | DEV | a6af758e-4a98-4ae2-94bf-1c84e5e5a3ed
1 | PROD | f98afa18-91f9-4a97-a031-4924018a8b8f
```
environment = project.environments.list(name="DEV")[0]
```
You can also do `project.environments.get(...)`.
Next we'll get the `scoring_runtime` for our model type. Notice we're using the artifact type from the experiment to filter runtimes.
```
mlops.runtimes.scoring.list(artifact_type=model.get_experiment().scoring_artifact_types[0])
```
| name | artifact_type | uid
----+-------------------+-----------------+-------------------
0 | H2O-3 MOJO scorer | h2o3_mojo | h2o3_mojo_runtime
```
scoring_runtime = mlops.runtimes.scoring.list(
artifact_type=model.get_experiment().scoring_artifact_types[0]
)[0]
```
Now we can create a deployment.
```
deployment = environment.deployments.create_single(
name = "deployment-from-client",
model = model,
scoring_runtime = scoring_runtime
)
while not deployment.is_healthy():
deployment.raise_for_failure()
time.sleep(5)
deployment.status()
```
'HEALTHY'
### Score
Once you have a deployment, you can score with it through the HTTP protocol.
```
response = httpx.post(
url=deployment.url_for_scoring,
json=deployment.get_sample_request()
)
response.json()
```
{'fields': ['C11.0', 'C11.1'],
'id': 'e307aa9f-895f-4b07-9404-b0728d1b7f03',
'score': [['0.49786656666743145', '0.5021334333325685']]}
Raw data
{
"_id": null,
"home_page": null,
"name": "h2o-mlops",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "h2o, mlops",
"author": null,
"author_email": "\"H2O.ai\" <support@h2o.ai>",
"download_url": null,
"platform": null,
"description": "# An H2O MLOps Python Client for Regular Folks\n\nThis project is a work in progress and the API may change. Please send questions or feedback to support@h2o.ai.\n\n## Example\n\n\n```\nimport h2o_mlops\nimport httpx\nimport time\n```\n\nFirst we have to connect to MLOps. In this example the client is detecting credentials and configuration options from the environment. \n\n\n```\nmlops = h2o_mlops.Client()\n```\n\n### Everything Starts with a Project\n\nA project is the main base of operations for most MLOps activities.\n\n\n```\nproject = mlops.projects.create(name=\"demo\")\n```\n\n\n```\nmlops.projects.list(name=\"demo\")\n```\n\n\n\n\n | name | uid\n ----+--------+--------------------------------------\n 0 | demo | 45e5a888-ec1f-4f9c-85ca-817465344b1f\n\n\n\nYou can also do `project = mlops.projects.get(...)`.\n\n### Upload an Experiment\n\n\n```\nexperiment = project.experiments.create(\n data=\"/Users/jgranados/Downloads/GBM_model_python_1649367037255_1.zip\",\n name=\"experiment-from-client\"\n)\n```\n\nSome experiment attributes of interest.\n\n\n```\nexperiment.scoring_artifact_types\n```\n\n\n\n\n ['h2o3_mojo']\n\n\n\n\n```\nexperiment.uid\n```\n\n\n\n\n 'e307aa9f-895f-4b07-9404-b0728d1b7f03'\n\n\n\nExisting experiments can be viewed and retrieved.\n\n\n```\nproject.experiments.list()\n```\n\n\n\n\n | name | uid | tags\n ----+------------------------+--------------------------------------+--------\n 0 | experiment-from-client | e307aa9f-895f-4b07-9404-b0728d1b7f03 |\n\n\n\nYou can also do `experiment = projects.experiments.get(...)`.\n\n### Create a Model\n\n\n```\nmodel = project.models.create(name=\"model-from-client\")\n```\n\nExisting models can be viewed and retrieved.\n\n\n```\nproject.models.list()\n```\n\n\n\n\n | name | uid\n ----+-------------------+--------------------------------------\n 0 | model-from-client | d18a677f-b800-4a4b-8642-0f59e202d225\n\n\n\nYou can also do `model = projects.models.get(...)`.\n\n### Register an Experiment to a Model\n\nIn order to deploy a model, it needs to have experiments registered to it.\n\n\n```\nmodel.register(experiment=experiment)\n```\n\n\n```\nmodel.versions()\n```\n\n\n\n\n | version | experiment_uid\n ----+-----------+--------------------------------------\n 0 | 1 | e307aa9f-895f-4b07-9404-b0728d1b7f03\n\n\n\n\n```\nmodel.get_experiment(model_version=\"latest\").name\n```\n\n\n\n\n 'experiment-from-client'\n\n\n\n### Deployment\n\n#### What is needed for a single model deployment?\n- project\n- model\n- environment\n- scoring runtime\n- name for deployment\n\nWe already have a `project` and `model`. Let us look at how to get the `environment`.\n\n\n```\nproject.environments.list()\n```\n\n\n\n\n | name | uid\n ----+--------+--------------------------------------\n 0 | DEV | a6af758e-4a98-4ae2-94bf-1c84e5e5a3ed\n 1 | PROD | f98afa18-91f9-4a97-a031-4924018a8b8f\n\n\n\n\n```\nenvironment = project.environments.list(name=\"DEV\")[0]\n```\n\nYou can also do `project.environments.get(...)`.\n\nNext we'll get the `scoring_runtime` for our model type. Notice we're using the artifact type from the experiment to filter runtimes.\n\n\n```\nmlops.runtimes.scoring.list(artifact_type=model.get_experiment().scoring_artifact_types[0])\n```\n\n\n\n\n | name | artifact_type | uid\n ----+-------------------+-----------------+-------------------\n 0 | H2O-3 MOJO scorer | h2o3_mojo | h2o3_mojo_runtime\n\n\n\n\n```\nscoring_runtime = mlops.runtimes.scoring.list(\n artifact_type=model.get_experiment().scoring_artifact_types[0]\n)[0]\n```\n\nNow we can create a deployment.\n\n\n```\ndeployment = environment.deployments.create_single(\n name = \"deployment-from-client\",\n model = model,\n scoring_runtime = scoring_runtime\n)\n\nwhile not deployment.is_healthy():\n deployment.raise_for_failure()\n time.sleep(5)\n \ndeployment.status()\n```\n\n\n\n\n 'HEALTHY'\n\n\n\n### Score\n\nOnce you have a deployment, you can score with it through the HTTP protocol.\n\n\n```\nresponse = httpx.post( \n url=deployment.url_for_scoring,\n json=deployment.get_sample_request()\n)\n\nresponse.json()\n```\n\n\n\n\n {'fields': ['C11.0', 'C11.1'],\n 'id': 'e307aa9f-895f-4b07-9404-b0728d1b7f03',\n 'score': [['0.49786656666743145', '0.5021334333325685']]}\n",
"bugtrack_url": null,
"license": "Apache v2",
"summary": "Python client for H2O MLOps.",
"version": "1.1.2",
"project_urls": {
"Changelog": "https://docs.h2o.ai/mlops/py-client/changelog",
"Documentation": "https://docs.h2o.ai/mlops/py-client/install"
},
"split_keywords": [
"h2o",
" mlops"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9a9a47909c00f338b3e4ab3cee532c70859d9b10cb3ad6be500a0db80cea2fa5",
"md5": "f2c4faba408b47a25e7e262bb7759e0f",
"sha256": "3698f245c6e9ccaedec1c61db872aa8162b7feeac15da3dbf101f9e00216bd7b"
},
"downloads": -1,
"filename": "h2o_mlops-1.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f2c4faba408b47a25e7e262bb7759e0f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 782479,
"upload_time": "2024-11-27T12:40:54",
"upload_time_iso_8601": "2024-11-27T12:40:54.897889Z",
"url": "https://files.pythonhosted.org/packages/9a/9a/47909c00f338b3e4ab3cee532c70859d9b10cb3ad6be500a0db80cea2fa5/h2o_mlops-1.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-27 12:40:54",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "h2o-mlops"
}