Model registry
This example demonstrates how to use the eScorer Python client to interact with the model registry. You can download the complete example here.
List all models
The model.list
method fetches the list of models stored in the model registry. Subsequent calls to this method will
return the model list from the cache.
models = await client.model.list()
[Model(name='pipeline-telco.mojo', version='1.10.4.1', id='be1c5024-a170-11ed-a236-aa09dd2aa20a'),
Model(name='pipelineSF.mojo', version='1.8.4.1', id='87ab50b8-6a04-11ea-a272-0242ac110002'),
Model(name='gbm.zip', version='3.20.0.5', id='-949234640338551712'),
Model(name='riskmodel.mojo', version='1.9.0', id='0a4bbd12-dcad-11ea-ab05-0242ac110002'),
Model(name='credit_card_pipeline.mojo', version='1.10.4.1', id='a96fe76a-9916-11ed-8835-36e42284ede4')]
To force a refresh of the model list, set the force_refresh
parameter to True
.
models = await client.model.list(force_refresh=True)
If you want the client to only fetch model details when required, set the lazy_load
parameter to True
.
models = await client.model.list(lazy_load=True)
Get model details
The model_registry.get
method fetches the details of a specific model from the model registry.
model = await client.model_registry.get('riskmodel.mojo')
model
Model(name='riskmodel.mojo', version='1.9.0', id='0a4bbd12-dcad-11ea-ab05-0242ac110002')
In addition to the id
, name
, and version
, the model
object also contains the features
attributes which
provides the list of features and their data types used by the model.
model.features
[Feature(name='loan_amnt', type='Float32'),
Feature(name='term', type='Str'),
Feature(name='int_rate', type='Float32'),
Feature(name='installment', type='Float32'),
Feature(name='emp_length', type='Float32'),
Feature(name='annual_inc', type='Float32'),
Feature(name='verification_status', type='Str'),
Feature(name='addr_state', type='Str'),
Feature(name='dti', type='Float32'),
Feature(name='inq_last_6mths', type='Float32'),
Feature(name='revol_bal', type='Float32'),
Feature(name='revol_util', type='Float32'),
Feature(name='total_acc', type='Float32')]
Upload a model
The model_registry.upload
method uploads a model to the model registry and returns the model object.
model = await client.model_registry.upload(
model_path="/path/to/riskmodel.mojo",
model_name="riskmodel.mojo",
validate=True,
replace=True,
)
model_name
is optional and defaults to the model file name.
If validate
is set to True
, the client will validate the model before uploading it.
If replace
is set to True
, the client will replace the existing model with the same name.
Rename a model
The model_registry.rename
method renames a model in the model registry.
model = await client.model_registry.rename(
model_name="riskmodel.mojo",
new_model_name="riskmodel_v1.mojo",
)
Delete a model
The model_registry.delete
method deletes a model from the model registry.
await client.model_registry.delete("riskmodel.mojo")
- Submit and view feedback for this page
- Send feedback about H2O eScorer to cloud-feedback@h2o.ai