GET /v1/mlmodels/{id}/versions
import json
from metadata.sdk import configure
from metadata.sdk.entities import MLModels
configure(
host="https://your-company.open-metadata.org/api",
jwt_token="your-jwt-token"
)
# List all versions
versions = MLModels.get_versions("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2")
for v in versions:
version = json.loads(v)
print(f"Version {version['version']}: {version.get('description')}")
# Get a specific version
model_v1 = MLModels.get_specific_version(
"6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2",
"0.1"
)
print(f"Original algorithm: {model_v1.algorithm}")
import org.openmetadata.schema.entity.data.MlModel;
import org.openmetadata.schema.type.EntityHistory;
// client is an initialized OpenMetadataClient.
// List all versions
EntityHistory history = client.mlModels().getVersionList("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2");
for (Object version : history.getVersions()) {
System.out.println("Version: " + version);
}
// Get a specific version
MlModel v1 = client.mlModels().getVersion("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", 0.1);
System.out.println("Description: " + v1.getDescription());
# List all versions
curl "{base_url}/api/v1/mlmodels/6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2/versions" \
-H "Authorization: Bearer {access_token}"
# Get a specific version
curl "{base_url}/api/v1/mlmodels/6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2/versions/0.1" \
-H "Authorization: Bearer {access_token}"
{
"entityType": "mlmodel",
"versions": [
"{\"id\":\"6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2\",\"name\":\"customer_segmentation\",\"fullyQualifiedName\":\"mlflow_svc.customer_segmentation\",\"version\":0.2,\"description\":\"Updated: Customer segmentation using KMeans with 5 clusters\",\"algorithm\":\"KMeans\",\"serviceType\":\"Mlflow\"}",
"{\"id\":\"6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2\",\"name\":\"customer_segmentation\",\"fullyQualifiedName\":\"mlflow_svc.customer_segmentation\",\"version\":0.1,\"algorithm\":\"KMeans\",\"serviceType\":\"Mlflow\"}"
]
}
ML Model Versions
List and retrieve historical versions of an ML model
GET
/
v1
/
mlmodels
/
{id}
/
versions
GET /v1/mlmodels/{id}/versions
import json
from metadata.sdk import configure
from metadata.sdk.entities import MLModels
configure(
host="https://your-company.open-metadata.org/api",
jwt_token="your-jwt-token"
)
# List all versions
versions = MLModels.get_versions("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2")
for v in versions:
version = json.loads(v)
print(f"Version {version['version']}: {version.get('description')}")
# Get a specific version
model_v1 = MLModels.get_specific_version(
"6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2",
"0.1"
)
print(f"Original algorithm: {model_v1.algorithm}")
import org.openmetadata.schema.entity.data.MlModel;
import org.openmetadata.schema.type.EntityHistory;
// client is an initialized OpenMetadataClient.
// List all versions
EntityHistory history = client.mlModels().getVersionList("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2");
for (Object version : history.getVersions()) {
System.out.println("Version: " + version);
}
// Get a specific version
MlModel v1 = client.mlModels().getVersion("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", 0.1);
System.out.println("Description: " + v1.getDescription());
# List all versions
curl "{base_url}/api/v1/mlmodels/6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2/versions" \
-H "Authorization: Bearer {access_token}"
# Get a specific version
curl "{base_url}/api/v1/mlmodels/6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2/versions/0.1" \
-H "Authorization: Bearer {access_token}"
{
"entityType": "mlmodel",
"versions": [
"{\"id\":\"6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2\",\"name\":\"customer_segmentation\",\"fullyQualifiedName\":\"mlflow_svc.customer_segmentation\",\"version\":0.2,\"description\":\"Updated: Customer segmentation using KMeans with 5 clusters\",\"algorithm\":\"KMeans\",\"serviceType\":\"Mlflow\"}",
"{\"id\":\"6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2\",\"name\":\"customer_segmentation\",\"fullyQualifiedName\":\"mlflow_svc.customer_segmentation\",\"version\":0.1,\"algorithm\":\"KMeans\",\"serviceType\":\"Mlflow\"}"
]
}
ML Model Versions
Every change to an ML model entity creates a new version. Use these endpoints to view the version history and retrieve specific versions.List Versions
string
required
UUID of the ML model.
Get Specific Version
UseGET /v1/mlmodels/{id}/versions/{version} to retrieve a specific version.
string
required
UUID of the ML model.
string
required
Version number to retrieve, for example
0.2.GET /v1/mlmodels/{id}/versions
import json
from metadata.sdk import configure
from metadata.sdk.entities import MLModels
configure(
host="https://your-company.open-metadata.org/api",
jwt_token="your-jwt-token"
)
# List all versions
versions = MLModels.get_versions("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2")
for v in versions:
version = json.loads(v)
print(f"Version {version['version']}: {version.get('description')}")
# Get a specific version
model_v1 = MLModels.get_specific_version(
"6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2",
"0.1"
)
print(f"Original algorithm: {model_v1.algorithm}")
import org.openmetadata.schema.entity.data.MlModel;
import org.openmetadata.schema.type.EntityHistory;
// client is an initialized OpenMetadataClient.
// List all versions
EntityHistory history = client.mlModels().getVersionList("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2");
for (Object version : history.getVersions()) {
System.out.println("Version: " + version);
}
// Get a specific version
MlModel v1 = client.mlModels().getVersion("6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2", 0.1);
System.out.println("Description: " + v1.getDescription());
# List all versions
curl "{base_url}/api/v1/mlmodels/6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2/versions" \
-H "Authorization: Bearer {access_token}"
# Get a specific version
curl "{base_url}/api/v1/mlmodels/6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2/versions/0.1" \
-H "Authorization: Bearer {access_token}"
{
"entityType": "mlmodel",
"versions": [
"{\"id\":\"6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2\",\"name\":\"customer_segmentation\",\"fullyQualifiedName\":\"mlflow_svc.customer_segmentation\",\"version\":0.2,\"description\":\"Updated: Customer segmentation using KMeans with 5 clusters\",\"algorithm\":\"KMeans\",\"serviceType\":\"Mlflow\"}",
"{\"id\":\"6b04e1d8-b66d-4f78-ab21-beb5be2cf4f2\",\"name\":\"customer_segmentation\",\"fullyQualifiedName\":\"mlflow_svc.customer_segmentation\",\"version\":0.1,\"algorithm\":\"KMeans\",\"serviceType\":\"Mlflow\"}"
]
}
Returns
List versions returns an object withentityType and a versions array of serialized entity snapshots (newest first).
Get specific version returns the full ML model object as it existed at that version.
Error Handling
| Code | Error Type | Description |
|---|---|---|
401 | UNAUTHORIZED | Invalid or missing authentication token |
404 | NOT_FOUND | ML model or version does not exist |
Was this page helpful?