Skip to content

Adds Candidate Detail

What does this MR do and why?

Adds UI for details on the Machine Learning Candidate.

Note for backend reviewer

I commented out the N+1 tests on purpose. the method `artifact` on ML:Candidate causes N+1 when loading a list of candidates, 
and we are working on fixing this on the follow up MR. However, this feature is still behind a feature flag for internal test 
only, with only a handful of users, so performance shouldn't be a problem until it is fixed. 

!104166 (merged)

Database

::Ml::Candidate::artifact

SELECT "ml_experiments".* 
FROM "ml_experiments" 
WHERE "ml_experiments"."id" = 7 LIMIT 1 

https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/13290/commands/46606

SELECT "projects".* 
FROM "projects" 
WHERE "projects"."id" = 22 LIMIT 1

https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/13290/commands/46607

SELECT "packages_packages".* 
FROM "packages_packages" 
WHERE "packages_packages"."project_id" = 22 
    AND "packages_packages"."package_type" = 7 
    AND "packages_packages"."status" IN (0, 1) 
    AND "packages_packages"."name" = 'ml_candidate_303f4dea-3c90-4530-9805-f73662488be3' 
    AND "packages_packages"."version" = '-' LIMIT 1

https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/13290/commands/46608

Screenshots

  • Candidates List / Experiment Detail

    image

  • Candidate Detail

    image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Enable the feature flag

    echo "Feature.enable(:ml_experiment_tracking)" | bundle exec rails c
  2. Create an Experiment, Run and Logs (use project id for a chosen project):

    experiments = 3.times.map { |v| Ml::Experiment.create!(name: "Gitlab Experiment #{v}", user_id: user_id, project_id: project_id) }
    exp = experiments[0]
    5.times.each { |i| exp.candidates.create!(user_id: user_id, start_time: 0) }
    exp.candidates.each_with_index { |c, i| c.metrics.create!(name: "auc", value: i*0.1 , tracked_at: Time.zone.now, step: 1)} 
    exp.candidates.each_with_index { |c, i| c.metrics.create!(name: "accuracy", value: i* 0.1+0.1 , tracked_at: Time.zone.now, step: 1)} 
    exp.candidates.each { |c| c.params.create!(name: "algorithm", value: ["LogisticRegression", "DecisionTree"].sample )}
    puts(exp.candidates[0].iid)
  3. Navigate to <your project>/-/ml/experiments

    image

  4. Click on Gitlab Experiment 0, it should lead you to the experiment candidate list:

    image

  5. Create an artifact for one of the candidates (the id was outputted at the end of the creation script above):

    export PROJECT_ID=<Your Project Id>
    export GITLAB_PAT=<your api token>
    export CANDIDATE_ID=<candidate id>
    
    echo "hello" > hello.txt
    curl -X PUT -H "Authorization: Bearer $GITLAB_PAT" --upload-file hello.txt "http://gdk.test:3000/api/v4/projects/$PROJECT_ID/packages/generic/ml_candidate_$CANDIDATE_ID/-/hello.txt"
  6. Refresh the candidate list page, it should show one of the Candidates has a link to artifacts image

  7. Clicking on Artifacts should lead you to the Generic Package Page

  8. Clicking on Details should lead you to the Candidate Detail Page 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 #370480 (closed)

Edited by Eduardo Bonet

Merge request reports