Class: Ml::Model
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Ml::Model
- Includes:
- CacheMarkdownField, Presentable, Sortable
- Defined in:
- app/models/ml/model.rb
Constant Summary collapse
- EXPERIMENT_NAME_PREFIX =
'[model]'
Constants included from CacheMarkdownField
CacheMarkdownField::INVALIDATED_BY
Constants inherited from ApplicationRecord
Constants included from HasCheckConstraints
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
Constants included from ResetOnColumnErrors
ResetOnColumnErrors::MAX_RESET_PERIOD
Instance Attribute Summary
Attributes included from CacheMarkdownField
#skip_markdown_cache_validation
Class Method Summary collapse
- .by_project_id_and_id(project_id, id) ⇒ Object
- .by_project_id_and_name(project_id, name) ⇒ Object
- .prefixed_experiment(string) ⇒ Object
Instance Method Summary collapse
Methods included from CacheMarkdownField
#attribute_invalidated?, #banzai_render_context, #cached_html_for, #cached_html_up_to_date?, #can_cache_field?, #invalidated_markdown_cache?, #latest_cached_markdown_version, #mentionable_attributes_changed?, #mentioned_filtered_user_ids_for, #parent_user, #refresh_markdown_cache, #refresh_markdown_cache!, #rendered_field_content, #skip_project_check?, #store_mentions!, #store_mentions_after_commit?, #updated_cached_html_for
Methods included from Presentable
Methods inherited from ApplicationRecord
===, cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, nullable_column?, 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 ResetOnColumnErrors
#reset_on_union_error, #reset_on_unknown_attribute_error
Methods included from Gitlab::SensitiveSerializableHash
Class Method Details
.by_project_id_and_id(project_id, id) ⇒ Object
53 54 55 |
# File 'app/models/ml/model.rb', line 53 def self.by_project_id_and_id(project_id, id) find_by(project_id: project_id, id: id) end |
.by_project_id_and_name(project_id, name) ⇒ Object
57 58 59 |
# File 'app/models/ml/model.rb', line 57 def self.by_project_id_and_name(project_id, name) find_by(project_id: project_id, name: name) end |
.prefixed_experiment(string) ⇒ Object
61 62 63 |
# File 'app/models/ml/model.rb', line 61 def self.prefixed_experiment(string) "#{EXPERIMENT_NAME_PREFIX}#{string}" end |
Instance Method Details
#all_packages ⇒ Object
42 43 44 |
# File 'app/models/ml/model.rb', line 42 def all_packages Packages::MlModel::Package.where(project: project, id: versions.select(:package_id)) end |
#valid_default_experiment? ⇒ Boolean
46 47 48 49 50 51 |
# File 'app/models/ml/model.rb', line 46 def valid_default_experiment? return unless default_experiment errors.add(:default_experiment) unless default_experiment.name == self.class.prefixed_experiment(name) errors.add(:default_experiment) unless default_experiment.project_id == project_id end |