debian-mirror-gitlab/app/controllers/projects/ml/experiments_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.5 KiB
Ruby
Raw Normal View History

2023-01-13 00:05:48 +05:30
# frozen_string_literal: true
module Projects
module Ml
class ExperimentsController < ::Projects::ApplicationController
2023-04-23 21:23:45 +05:30
include Projects::Ml::ExperimentsHelper
2023-01-13 00:05:48 +05:30
before_action :check_feature_flag
feature_category :mlops
2023-03-17 16:20:25 +05:30
MAX_EXPERIMENTS_PER_PAGE = 20
MAX_CANDIDATES_PER_PAGE = 30
2023-01-13 00:05:48 +05:30
def index
2023-04-23 21:23:45 +05:30
paginator = ::Ml::Experiment.by_project_id(@project.id)
.with_candidate_count
.keyset_paginate(cursor: params[:cursor], per_page: MAX_EXPERIMENTS_PER_PAGE)
@experiments = paginator.records
@page_info = page_info(paginator)
2023-01-13 00:05:48 +05:30
end
def show
@experiment = ::Ml::Experiment.by_project_id_and_iid(@project.id, params[:id])
return redirect_to project_ml_experiments_path(@project) unless @experiment.present?
2023-04-23 21:23:45 +05:30
find_params = params
.transform_keys(&:underscore)
.permit(:name, :order_by, :sort, :order_by_type)
2023-03-17 16:20:25 +05:30
2023-04-23 21:23:45 +05:30
paginator = CandidateFinder
.new(@experiment, find_params)
.execute
.keyset_paginate(cursor: params[:cursor], per_page: MAX_CANDIDATES_PER_PAGE)
2023-03-17 16:20:25 +05:30
2023-04-23 21:23:45 +05:30
@candidates = paginator.records.each(&:artifact_lazy)
@page_info = page_info(paginator)
2023-01-13 00:05:48 +05:30
end
private
def check_feature_flag
render_404 unless Feature.enabled?(:ml_experiment_tracking, @project)
end
end
end
end