Skip to content

Changes model candidates to use ml_model packages

What does this MR do and why?

Changes model candidates to use ml_model packages

Since model registry is now default enabled and on beta, candidates that belong to models can now use the ml_model package type, which requires some changes to upload and download routes enabling usage with MLflow client.

There a currently 0 cases that would be affected by this change on GitLab.com, since Model registry is a feature recently moved into beta. Until 17.1 it was default disabled.

gitlabhq_dblab=# SELECT count(1)
from ml_candidates
join ml_experiments on ml_candidates.experiment_id=ml_experiments.id
where ml_experiments.model_id != NULL
  and ml_candidates.model_version_id = NULL
  and ml_candidates.package_id != NULL;
 count
-------
     0
(1 row)

database

Update query:

UPDATE "ml_candidates" 
  SET "updated_at" = '2024-06-04 12:49:31.057124', "package_id" = 5041 
  WHERE "ml_candidates"."id" = 5076

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Create a candidate for a model and fetch the link

    p = Project.find_by_id(1)
    m = Ml::CreateModelService.new(p, "model_1").execute
    c = Ml::CreateCandidateService.new(m.default_experiment, {}).execute
    c.iid
  2. Create an access token, and choose a project. Create a simple file:

    echo 'blah' > blah.txt
  3. Upload a file to ml_models. It should return {"message":"201 Created"} with feature flag enabled, 404 if feature flag disabled.

    curl  --header "Authorization: Bearer $GLAB_TOKEN" --upload-file ./README.md "http://localhost:3000/api/v4/projects/1/packages/ml_models/candidate:<candidate_iid>/files/path/to/file.md"
  4. Visit Deploy > Model Registry and select your model, than the candidate created under Candidates. Select Artifacts. Verify the file was uploaded.

image

  1. Download the file:
    curl  --header "Authorization: Bearer $GLAB_TOKEN" "http://localhost:3000/api/v4/projects/1/packages/ml_models/candidate:<candidate_iid>/files/path/to/file.md"
Edited by Eduardo Bonet

Merge request reports