Class: Ml::Model

Inherits:
ApplicationRecord show all
Includes:
Presentable
Defined in:
app/models/ml/model.rb

Constant Summary

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Presentable

#present

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Class Method Details

.find_or_create(project, name, experiment) ⇒ Object



31
32
33
34
# File 'app/models/ml/model.rb', line 31

def self.find_or_create(project, name, experiment)
  create_with(default_experiment: experiment)
    .find_or_create_by(project: project, name: name)
end

Instance Method Details

#valid_default_experiment?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
# File 'app/models/ml/model.rb', line 24

def valid_default_experiment?
  return unless default_experiment

  errors.add(:default_experiment) unless default_experiment.name == name
  errors.add(:default_experiment) unless default_experiment.project_id == project_id
end