Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/ml')
-rw-r--r--app/models/ml/candidate.rb17
-rw-r--r--app/models/ml/candidate_metadata.rb14
-rw-r--r--app/models/ml/experiment.rb1
-rw-r--r--app/models/ml/experiment_metadata.rb14
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