Skip to content

Add ml_models table

What does this MR do and why?

Adds the table ml_models and the Ml::Model entity.

A Ml::Model has:

  • name, which will be used to reference Packages::Package by package_name (follow up: a table packages_ml_model_metadata will be added to add an association for a package of type ml_model to a model). name must be a valid ml_model package_name. Name is unique per project and acts as an iid of sorts.
  • project, project which the model belongs to
  • default_experiment, an Ml::Experiment with the same name as the model. When creating the model, and an experiment with the same name exists, that is set as the default_experiment. Otherwise a new experiment is created. An experiment that is the default experiment cannot be destroyed.

Database

Migrations

Up:

❯ rails db:migrate
main: == [advisory_lock_connection] object_id: 223460, pg_backend_pid: 18147
main: == 20230705092150 CreateMlModels: migrating ===================================
main: -- create_table(:ml_models)
main: -- quote_column_name(:name)
main:    -> 0.0000s
main:    -> 0.0099s
main: == 20230705092150 CreateMlModels: migrated (0.1222s) ==========================

main: == [advisory_lock_connection] object_id: 223460, pg_backend_pid: 18147
main: == [advisory_lock_connection] object_id: 223760, pg_backend_pid: 18149
main: == 20230706130217 AddColumnModelIdToMlExperiments: migrating ==================
main: -- add_reference(:ml_experiments, :model, {:index=>true, :null=>true, :unique=>true, :foreign_key=>{:on_delete=>:cascade, :to_table=>:ml_models}})
main:    -> 0.0047s
main: == 20230706130217 AddColumnModelIdToMlExperiments: migrated (0.0082s) =========

main: == [advisory_lock_connection] object_id: 223760, pg_backend_pid: 18149

Down:

❯ rails db:rollback:main STEP=2 RAILS_ENV=development
main: == [advisory_lock_connection] object_id: 223280, pg_backend_pid: 17506
main: == 20230706130217 AddColumnModelIdToMlExperiments: reverting ==================
main: -- remove_reference(:ml_experiments, :model, {:index=>true, :null=>true, :unique=>true, :foreign_key=>{:on_delete=>:cascade, :to_table=>:ml_models}})
main:    -> 0.0865s
main: == 20230706130217 AddColumnModelIdToMlExperiments: reverted (0.0920s) =========

main: == 20230705092150 CreateMlModels: reverting ===================================
main: -- drop_table(:ml_models)
main:    -> 0.0014s
main: == 20230705092150 CreateMlModels: reverted (0.0041s) ==========================

main: == [advisory_lock_connection] object_id: 223280, pg_backend_pid: 17506

Queries

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #410130 (closed)

Edited by Eduardo Bonet

Merge request reports