Class: Ml::ModelVersion

Inherits:
ApplicationRecord show all
Includes:
CacheMarkdownField, Presentable, SemanticVersionable, Sortable
Defined in:
app/models/ml/model_version.rb

Constant Summary

Constants included from CacheMarkdownField

CacheMarkdownField::INVALIDATED_BY

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

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

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?, #store_mentions_after_commit?, #updated_cached_html_for

Methods included from Presentable

#present

Methods inherited from ApplicationRecord

===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, 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 Organizations::Sharding

#sharding_organization

Methods included from ResetOnColumnErrors

#reset_on_union_error, #reset_on_unknown_attribute_error

Methods included from Gitlab::SensitiveSerializableHash

#serializable_hash

Class Method Details

.by_project_id_and_id(project_id, id) ⇒ Object



56
57
58
# File 'app/models/ml/model_version.rb', line 56

def by_project_id_and_id(project_id, id)
  find_by(project_id: project_id, id: id)
end

.by_project_id_name_and_version(project_id, name, version) ⇒ Object



60
61
62
# File 'app/models/ml/model_version.rb', line 60

def by_project_id_name_and_version(project_id, name, version)
  joins(:model).find_by(model: { name: name, project_id: project_id }, project_id: project_id, version: version)
end

Instance Method Details

#add_metadata(metadata_key_value) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/ml/model_version.rb', line 43

def ()
  return unless .present?

  .each do |entry|
    .create!(
      project_id: project_id,
      name: entry[:key],
      value: entry[:value]
    )
  end
end

#version=(value) ⇒ Object



65
66
67
68
# File 'app/models/ml/model_version.rb', line 65

def version=(value)
  self.semver = value
  super(value)
end