Class: Ml::Experiment
Constant Summary
collapse
- PACKAGE_PREFIX =
'ml_experiment_'
AtomicInternalId::MissingValueError
ApplicationRecord::MAX_PLUCK
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
group_init, #internal_id_read_scope, #internal_id_scope_attrs, #internal_id_scope_usage, namespace_init, project_init, scope_attrs, scope_usage
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
#serializable_hash
Class Method Details
.by_project_id(project_id) ⇒ Object
50
51
52
|
# File 'app/models/ml/experiment.rb', line 50
def by_project_id(project_id)
where(project_id: project_id).order(id: :desc)
end
|
.by_project_id_and_iid(project_id, iid) ⇒ Object
42
43
44
|
# File 'app/models/ml/experiment.rb', line 42
def by_project_id_and_iid(project_id, iid)
find_by(project_id: project_id, iid: iid)
end
|
.by_project_id_and_name(project_id, name) ⇒ Object
46
47
48
|
# File 'app/models/ml/experiment.rb', line 46
def by_project_id_and_name(project_id, name)
find_by(project_id: project_id, name: name)
end
|
.find_or_create(project, name, user) ⇒ Object
62
63
64
|
# File 'app/models/ml/experiment.rb', line 62
def find_or_create(project, name, user)
create_with(user: user).find_or_create_by(project: project, name: name)
end
|
.package_for_experiment?(package_name) ⇒ Boolean
54
55
56
57
58
59
60
|
# File 'app/models/ml/experiment.rb', line 54
def package_for_experiment?(package_name)
return false unless package_name&.starts_with?(PACKAGE_PREFIX)
iid = package_name.delete_prefix(PACKAGE_PREFIX)
numeric?(iid)
end
|
Instance Method Details
#package_name ⇒ Object
28
29
30
|
# File 'app/models/ml/experiment.rb', line 28
def package_name
"#{PACKAGE_PREFIX}#{iid}"
end
|
#stop_destroy ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'app/models/ml/experiment.rb', line 32
def stop_destroy
return unless model_id
errors[:base] << "Cannot delete an experiment associated to a model"
throw :abort end
|