diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /app/models/ml | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'app/models/ml')
-rw-r--r-- | app/models/ml/candidate.rb | 17 | ||||
-rw-r--r-- | app/models/ml/candidate_metadata.rb | 14 | ||||
-rw-r--r-- | app/models/ml/experiment.rb | 1 | ||||
-rw-r--r-- | app/models/ml/experiment_metadata.rb | 14 |
4 files changed, 45 insertions, 1 deletions
diff --git a/app/models/ml/candidate.rb b/app/models/ml/candidate.rb index f7da4418624..f24161d598f 100644 --- a/app/models/ml/candidate.rb +++ b/app/models/ml/candidate.rb @@ -11,6 +11,7 @@ module Ml belongs_to :user has_many :metrics, class_name: 'Ml::CandidateMetric' has_many :params, class_name: 'Ml::CandidateParam' + has_many :metadata, class_name: 'Ml::CandidateMetadata' has_many :latest_metrics, -> { latest }, class_name: 'Ml::CandidateMetric', inverse_of: :candidate attribute :iid, default: -> { SecureRandom.uuid } @@ -18,7 +19,21 @@ module Ml scope :including_metrics_and_params, -> { includes(:latest_metrics, :params) } def artifact_root - "/ml_candidate_#{iid}/-/" + "/#{package_name}/#{package_version}/" + end + + def artifact + ::Packages::Generic::PackageFinder.new(experiment.project).execute!(package_name, package_version) + rescue ActiveRecord::RecordNotFound + nil + end + + def package_name + "ml_candidate_#{iid}" + end + + def package_version + '-' end class << self diff --git a/app/models/ml/candidate_metadata.rb b/app/models/ml/candidate_metadata.rb new file mode 100644 index 00000000000..06b893c211f --- /dev/null +++ b/app/models/ml/candidate_metadata.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Ml + class CandidateMetadata < ApplicationRecord + validates :candidate, presence: true + validates :name, + length: { maximum: 250 }, + presence: true, + uniqueness: { scope: :candidate, message: ->(candidate, _) { "'#{candidate.name}' already taken" } } + validates :value, length: { maximum: 5000 }, presence: true + + belongs_to :candidate, class_name: 'Ml::Candidate' + end +end diff --git a/app/models/ml/experiment.rb b/app/models/ml/experiment.rb index 05b238b960d..0a326b0e005 100644 --- a/app/models/ml/experiment.rb +++ b/app/models/ml/experiment.rb @@ -10,6 +10,7 @@ module Ml belongs_to :project belongs_to :user has_many :candidates, class_name: 'Ml::Candidate' + has_many :metadata, class_name: 'Ml::ExperimentMetadata' has_internal_id :iid, scope: :project diff --git a/app/models/ml/experiment_metadata.rb b/app/models/ml/experiment_metadata.rb new file mode 100644 index 00000000000..93496807e1a --- /dev/null +++ b/app/models/ml/experiment_metadata.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Ml + class ExperimentMetadata < ApplicationRecord + validates :experiment, presence: true + validates :name, + length: { maximum: 250 }, + presence: true, + uniqueness: { scope: :experiment, message: ->(exp, _) { "'#{exp.name}' already taken" } } + validates :value, length: { maximum: 5000 }, presence: true + + belongs_to :experiment, class_name: 'Ml::Experiment' + end +end |