Skip to content

Commit

Permalink
[HWORKS-135] Models backend should store metadata in tables instead o…
Browse files Browse the repository at this point in the history
…f opensearch (logicalclocks#1023)
  • Loading branch information
robzor92 authored Dec 18, 2023
1 parent d6b8661 commit 9325e26
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 4 deletions.
29 changes: 28 additions & 1 deletion files/default/sql/ddl/3.7.0__initial_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2347,4 +2347,31 @@ CREATE TABLE IF NOT EXISTS `embedding_feature` (
PRIMARY KEY (`id`),
KEY `embedding_id` (`embedding_id`),
CONSTRAINT `embedding_feature_fk` FOREIGN KEY (`embedding_id`) REFERENCES `embedding` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;

CREATE TABLE IF NOT EXISTS `model` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`project_id` int(11) NOT NULL,
UNIQUE KEY `project_unique_name` (`name`, `project_id`),
PRIMARY KEY (`id`),
CONSTRAINT `model_project_fk` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;

CREATE TABLE IF NOT EXISTS `model_version` (
`model_id` int(11) NOT NULL,
`version` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`description` VARCHAR(1000) DEFAULT NULL,
`metrics` VARCHAR(3000) DEFAULT NULL,
`program` VARCHAR(1000) DEFAULT NULL,
`framework` VARCHAR(128) DEFAULT NULL,
`environment` VARCHAR(1000) DEFAULT NULL,
`experiment_id` VARCHAR(128) DEFAULT NULL,
`experiment_project_name` VARCHAR(128) DEFAULT NULL,
PRIMARY KEY (`model_id`, `version`),
CONSTRAINT `user_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`uid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `model_fk` FOREIGN KEY (`model_id`) REFERENCES `model` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;

32 changes: 29 additions & 3 deletions files/default/sql/ddl/updates/3.7.0.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- FSTORE-1047
CREATE TABLE IF NOT EXISTS `embedding` (
CREATE TABLE IF NOT EXISTS `hopsworks`.`embedding` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`feature_group_id` int(11) NOT NULL,
`col_prefix` varchar(255) NULL,
Expand All @@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS `embedding` (
CONSTRAINT `feature_group_embedding_fk` FOREIGN KEY (`feature_group_id`) REFERENCES `feature_group` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;

CREATE TABLE IF NOT EXISTS `embedding_feature` (
CREATE TABLE IF NOT EXISTS `hopsworks`.`embedding_feature` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`embedding_id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
Expand All @@ -18,4 +18,30 @@ CREATE TABLE IF NOT EXISTS `embedding_feature` (
PRIMARY KEY (`id`),
KEY `embedding_id` (`embedding_id`),
CONSTRAINT `embedding_feature_fk` FOREIGN KEY (`embedding_id`) REFERENCES `embedding` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;

CREATE TABLE IF NOT EXISTS `hopsworks`.`model` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` VARCHAR(255) NOT NULL,
`project_id` int(11) NOT NULL,
UNIQUE KEY `project_unique_name` (`name`, `project_id`),
PRIMARY KEY (`id`),
CONSTRAINT `model_project_fk` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;

CREATE TABLE IF NOT EXISTS `hopsworks`.`model_version` (
`model_id` int(11) NOT NULL,
`version` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`description` VARCHAR(1000) DEFAULT NULL,
`metrics` VARCHAR(3000) DEFAULT NULL,
`program` VARCHAR(1000) DEFAULT NULL,
`framework` VARCHAR(128) DEFAULT NULL,
`environment` VARCHAR(1000) DEFAULT NULL,
`experiment_id` VARCHAR(128) DEFAULT NULL,
`experiment_project_name` VARCHAR(128) DEFAULT NULL,
PRIMARY KEY (`model_id`, `version`),
CONSTRAINT `user_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`uid`) ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `model_fk` FOREIGN KEY (`model_id`) REFERENCES `model` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
3 changes: 3 additions & 0 deletions templates/default/expat-site.xml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@
<version-35>
io.hops.hopsworks.expat.migrations.airflow.DagsMigration
</version-35>
<version-37>
io.hops.hopsworks.expat.migrations.models.OpenSearchToRonDBMigration
</version-37>
</expat>

0 comments on commit 9325e26

Please sign in to comment.