Skip to main content

Manage Model Metadata

Introduction

This page covers the Gravitino API for models and model versions. For what a model catalog is, how versions and aliases work, and how several URIs on one version behave, see Model Catalog. For creating the catalog and schema a model lives in, see Manage Catalogs and Schemas.

Model Operations

Register a Model

Registering creates the model with no versions. It needs a name, and can carry a comment and properties.

curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"name": "churn_predictor",
"comment": "Customer churn model",
"properties": {"team": "risk"}
}' http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models

Get a Model

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor

Alter a Model

ChangeJSONJava
Rename{"@type":"rename","newName":"churn_v2"}ModelChange.rename("churn_v2")
Update the comment{"@type":"updateComment","newComment":"new_comment"}ModelChange.updateComment("new_comment")
Set a property{"@type":"setProperty","property":"key1","value":"value1"}ModelChange.setProperty("key1", "value1")
Remove a property{"@type":"removeProperty","property":"key1"}ModelChange.removeProperty("key1")
curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"updates": [
{"@type": "setProperty", "property": "default-uri-name", "value": "us"}
]
}' http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor

List and Delete Models

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models

curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor

Deleting a model deletes all of its versions.

Model Version Operations

Linking creates a version of an existing model. The version number is assigned in sequence starting at zero.

curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"uri": "s3a://models/churn/v0",
"aliases": ["production"],
"comment": "First release",
"properties": {"framework": "xgboost"}
}' http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor/versions

To give a version several named URIs, send uris as a map instead of a single uri, and set default-uri-name to pick the one returned when a caller does not name one. In Java the same linkModelVersion takes a map; in Python it is link_model_version_with_multiple_uris.

curl -X POST -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"uris": {
"us": "s3a://models-us/churn/v0",
"eu": "s3a://models-eu/churn/v0"
},
"aliases": ["production"],
"properties": {"default-uri-name": "us"}
}' http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor/versions

Get a Version

A version is fetched by number or by alias, and its URI can be fetched directly.

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor/versions/0

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor/aliases/production

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor/aliases/production/uri

Alter a Version

Aliases move between versions with updateAliases, which adds and removes in one call. URIs are added, updated, and removed by name.

ChangeJSONJava
Update the comment{"@type":"updateComment","newComment":"new_comment"}ModelVersionChange.updateComment("new_comment")
Set a property{"@type":"setProperty","property":"key1","value":"value1"}ModelVersionChange.setProperty("key1", "value1")
Remove a property{"@type":"removeProperty","property":"key1"}ModelVersionChange.removeProperty("key1")
Update the URI{"@type":"updateUri","newUri":"s3a://models/churn/v1"}ModelVersionChange.updateUri(...)
Add a named URI{"@type":"addUri","uriName":"eu","uri":"s3a://models-eu/churn/v0"}ModelVersionChange.addUri("eu", ...)
Remove a named URI{"@type":"removeUri","uriName":"eu"}ModelVersionChange.removeUri("eu")
Move aliases{"@type":"updateAliases","aliasesToAdd":["production"],"aliasesToRemove":[]}ModelVersionChange.updateAliases(...)
curl -X PUT -H "Accept: application/vnd.gravitino.v1+json" \
-H "Content-Type: application/json" -d '{
"updates": [
{"@type": "updateAliases", "aliasesToAdd": ["production"], "aliasesToRemove": []}
]
}' http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor/versions/1

Moving an alias onto a new version removes it from the version that held it, since an alias belongs to one version at a time.

List and Delete Versions

curl -X GET -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor/versions

curl -X DELETE -H "Accept: application/vnd.gravitino.v1+json" \
http://localhost:8090/api/metalakes/example/catalogs/models/schemas/customer/models/churn_predictor/versions/0