Added MLFLow API to get latest model version
What does this MR do and why?
Continuing on the work to build the MLFlow Registered Models API, this MR adds an endpoint to get the latest version for a given registered model name.
The Get Latest ModelVersions API accepts a name
and it returns an array ModelVersion
s, or an error message if the validation fails.
Note: the MLFlow API also supports a stages
param, which we are ignoring for the time being.
Example response payload:
{
"model_versions": [
{
"name": "model_2",
"version": "1.2.2",
"creation_timestamp": 1698776142,
"last_updated_timestamp": 1698776142,
"user_id": null,
"current_stage": "development",
"description": "",
"source": "api/v4/projects/(id)/packages/ml_models/model_2/model_version/",
"run_id": "",
"status": "READY",
"status_message": "",
"metadata": [],
"run_link": "",
"aliases": []
}
]
}
How to set up and validate locally
-
In the Rails console, ensure the feature flag is enabled
Feature.enable(:ml_experiment_tracking)
-
In the Rails console, run the following to create a model and some model versions:
project = Project.last # or find a project locally you want to use model = Ml::CreateModelService.new(project, 'my-model').execute model.versions.create(version: '1.0.0', project: project) model.versions.create(version: '2.0.0', project: project)
-
Use the following cURL command to return the latest model version from the API
curl -X "POST" "http://GDKHOST/api/v4/projects/PROJECT_ID/ml/mlflow/api/2.0/mlflow/registered-models/get-latest-versions" \ -H 'Authorization: Bearer PERSONAL_ACCESS_TOKEN' \ -H 'Content-Type: application/json; charset=utf-8' \ -d $'{ "name": "my-model" }'
The request should return version
2.0.0
of the model
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.