debian-mirror-gitlab/app/helpers/projects/ml/experiments_helper.rb

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

25 lines
663 B
Ruby
Raw Normal View History

2023-01-13 00:05:48 +05:30
# frozen_string_literal: true
module Projects
module Ml
module ExperimentsHelper
require 'json'
include ActionView::Helpers::NumberHelper
def candidates_table_items(candidates)
items = candidates.map do |candidate|
{
**candidate.params.to_h { |p| [p.name, p.value] },
**candidate.latest_metrics.to_h { |m| [m.name, number_with_precision(m.value, precision: 4)] }
}
end
Gitlab::Json.generate(items)
end
def unique_logged_names(candidates, &selector)
Gitlab::Json.generate(candidates.flat_map(&selector).map(&:name).uniq)
end
end
end
end