Skip to content

Adds modelCount and versionPath to Models index

Eduardo Bonet requested to merge 385061-ui-list-models-page-backend into master

What does this MR do and why?

Adds modelCount and versionPath to Models index

  • Adds modelCount and versionPath to ModelsIndexComponent
  • Also fixes a bogus test for N+1: additional requires were being hidden under 'not_exceed_query_count' without proper warmup, which would increase the number of queries in the control action

This is the backend counterpart to the frontend changes introduced in !135044 (merged) This branch contain both MRs combined: https://gitlab.com/gitlab-org/gitlab/-/tree/385061-ui-list-models-page-full?ref_type=heads

How to set up and validate locally

  1. checkout the combined branch: https://gitlab.com/gitlab-org/gitlab/-/tree/385061-ui-list-models-page-full

  2. on rails console enable the feature flag, and create a few models and model versions

    Feature.enable("model_registry")
    p = Project.find_by(id: 20) # or whatever project you want to use for testing
    3.times { |i|  Ml::FindOrCreateModelService.new(p, "model_#{i}").execute }
    
    Ml::FindOrCreateModelVersionService.new(p, { model_name: "model_1", version: "1.0.0" }).execute
    3.times { |i| Ml::FindOrCreateModelVersionService.new(p, { model_name: "model_2", version: "1.2.#{i}" }).execute }
  3. Navigate to /ml/models

Database

SELECT
    COUNT(*)
FROM
    "ml_models"
WHERE
    "ml_models"."project_id" = 20
Aggregate  (cost=1.34..1.35 rows=1 width=8) (actual time=0.201..0.202 rows=1 loops=1)
  ->  Index Only Scan using index_ml_models_on_project_id_and_name on ml_models  (cost=0.28..1.33 rows=3 width=0) (actual time=0.192..0.194 rows=3 loops=1)
        Index Cond: (project_id = 20)
        Heap Fetches: 0
Planning Time: 2.848 ms
Execution Time: 0.241 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.

Related to #385061 (closed)

Edited by Eduardo Bonet

Merge request reports

Loading