Skip to content

Uses ModelPresenter instead of ModelIndexPresenter

Eduardo Bonet requested to merge 385061-model-registry-ui-model-list-1 into master

What does this MR do and why?

Uses ModelPresenter instead of ModelIndexPresenter

Since ModelsController now handles Ml::Model, we can add a presenter to Ml::Model. This presenter is more generic, and not directly associated to the Index call. The view model is now created directly on the view.

Previous discussion about using the presenter: !124833 (comment 1456798500)

No visual changes.

Why using a view component?

Summary from this slack thread (internal)

The view is entirely rendered in a Vue component, the only goal is to setup the data for that component and create a mounting point for initSimpleApp helper to mount it.

I could have done it in a helper, or on a controller, but using a ViewComponent encapsulates this logic well, allows easy testing of the rendered html, keeps the controller clean and just a glue, and avoids cluttered helpers.

How to set up and validate locally

  1. Enable the feature flag

    echo "Feature.enable(:model_registry)" | bundle exec rails c
  2. Create data on rails console

    p = Project.find_by_id(19) # or the id of your project
    models = Array.new(10) { |i| Ml::Model.create!(name: "model_#{i}", project: p, default_experiment: Ml::Experiment.create!(name: "model_#{i}", project: p)) }
    models.take(5).each { |m| 2.times {|i| m.versions.create!(project: p, version: "1.0.#{i}") } }
    mv = models[0].latest_version
    package = Packages::Package.create!(name: mv.name, version: mv.version, project: p, package_type: :ml_model)
    mv.update!(package_id: package.id)
  3. Navigate to <your_project>/-/ml/models. Note that some of the of the versions are not showing (they don't exist) or links don't work (packages do not exist). UI improvements are not in the scope of this MR. image

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