Skip to content

Adds grapqhl mappings for Ml::Candidate

What does this MR do and why?

Adds grapqhl mappings for Ml::Candidate

First mappings for Candidate type, to be used in the model registry.

How to set up and validate locally

  1. In rails console enable the feature flag

    Feature.enable(:model_registry)
  2. Create a model and a bunch of candidates

    p = Project.find_by_id(1)
    m = Ml::FindOrCreateModelService.new(p, "model_1").execute
    20.times { |i| Ml::CreateCandidateService.new(m.default_experiment, {}).execute }
  3. Open /-/graphql_explorer, the following query should work (replace MODEL_ID):

     {
       mlModel(id: "gid://gitlab/Ml::Model/MODEL_ID") {
         id
         candidates(first: 10) {
           count
           nodes {
             id
             name
             createdAt
             _links {
               showPath
             }
           }
           pageInfo {
             hasNextPage
             hasPreviousPage
             endCursor
             startCursor
           }
         }
       }
     }

Database

Ml::Candidate.without_model_version.take(10)
SELECT
    "ml_candidates".*
FROM
    "ml_candidates"
WHERE
    "ml_candidates"."model_version_id" IS NULL
Seq Scan on ml_candidates  (cost=0.00..5.62 rows=155 width=139) (actual time=0.015..0.084 rows=155 loops=1)
  Filter: (model_version_id IS NULL)
  Rows Removed by Filter: 7
Planning Time: 1.944 ms
Execution Time: 0.358 ms

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Eduardo Bonet

Merge request reports