Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HWORKS-927] Support canary serving deployments #1102

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 39 additions & 17 deletions files/default/sql/ddl/3.8.0__initial_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1247,36 +1247,28 @@ CREATE TABLE `rstudio_settings` (
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `serving` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`local_port` int(11) DEFAULT NULL,
`cid` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`project_id` int(11) NOT NULL,
`creator` int(11) DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`name` varchar(255) COLLATE latin1_general_cs NOT NULL,
`description` varchar(1000) COLLATE latin1_general_cs DEFAULT NULL,
`model_path` varchar(255) COLLATE latin1_general_cs NOT NULL,
`artifact_version` int(11) DEFAULT NULL,
`predictor` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`transformer` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`model_name` varchar(255) COLLATE latin1_general_cs NOT NULL,
`model_version` int(11) NOT NULL,
`model_framework` int(11) NOT NULL,
`deployed` timestamp DEFAULT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deployed field is already in line 1275. No need to add it here.

`local_port` int(11) DEFAULT NULL,
`local_dir` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`batching_configuration` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`optimized` tinyint(4) NOT NULL DEFAULT '0',
`instances` int(11) NOT NULL DEFAULT '0',
`transformer_instances` int(11) DEFAULT NULL,
`creator` int(11) DEFAULT NULL,
`cid` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`lock_ip` varchar(15) COLLATE latin1_general_cs DEFAULT NULL,
`lock_timestamp` bigint(20) DEFAULT NULL,
`serving_tool` int(11) NOT NULL DEFAULT '0',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serving_tool is already in line 1274. No need to add it here.

`specification` int(11) NOT NULL,
`canary_spec` int(11) DEFAULT NULL,
`canary_traffic_percentage` TINYINT DEFAULT NULL,
`kafka_topic_id` int(11) DEFAULT NULL,
`inference_logging` int(11) DEFAULT NULL,
`model_server` int(11) NOT NULL DEFAULT '0',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

model_server is on the serving_spec table. We should remove it from here.

`serving_tool` int(11) NOT NULL DEFAULT '0',
`deployed` timestamp DEFAULT NULL,
`deployed_by` int(11) DEFAULT NULL,
`revision` varchar(8) DEFAULT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revision is on the serving_spec table. We should remove it from here also

`predictor_resources` varchar(1000) COLLATE latin1_general_cs DEFAULT NULL,
`transformer_resources` varchar(1000) COLLATE latin1_general_cs DEFAULT NULL,
`api_protocol` TINYINT(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `Serving_Constraint` (`project_id`,`name`),
Expand All @@ -1287,7 +1279,37 @@ CREATE TABLE `serving` (
CONSTRAINT `user_fk_serving` FOREIGN KEY (`creator`) REFERENCES `users` (`uid`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `deployed_by_fk_serving` FOREIGN KEY (`deployed_by`) REFERENCES `users` (`uid`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `kafka_fk` FOREIGN KEY (`kafka_topic_id`) REFERENCES `project_topics` (`id`) ON DELETE SET NULL ON UPDATE NO ACTION,
CONSTRAINT `FK_284_315` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this constraint removed?

CONSTRAINT unique_specification UNIQUE (specification),
CONSTRAINT unique_canary_spec UNIQUE (canary_spec),
Comment on lines +1282 to +1283
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the missing quotes in the constraint names and the column names?

CONSTRAINT `specification_fk` FOREIGN KEY (`specification`) REFERENCES `serving_spec` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `canary_spec_fk` FOREIGN KEY (`canary_spec`) REFERENCES `serving_spec` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Table structure for table `serving_spec`
--

/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `serving_spec` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`model_path` varchar(255) COLLATE latin1_general_cs NOT NULL,
`artifact_version` int(11) DEFAULT NULL,
`predictor` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`transformer` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`model_name` varchar(255) COLLATE latin1_general_cs NOT NULL,
`model_version` int(11) NOT NULL,
`model_framework` int(11) NOT NULL,
`batching_configuration` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`optimized` tinyint(4) NOT NULL DEFAULT '0',
`instances` int(11) NOT NULL DEFAULT '0',
`transformer_instances` int(11) DEFAULT NULL,
`model_server` int(11) NOT NULL DEFAULT '0',
`revision` varchar(8) DEFAULT NULL,
`predictor_resources` varchar(1000) COLLATE latin1_general_cs DEFAULT NULL,
`transformer_resources` varchar(1000) COLLATE latin1_general_cs DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;
/*!40101 SET character_set_client = @saved_cs_client */;

Expand Down
46 changes: 46 additions & 0 deletions files/default/sql/ddl/updates/3.8.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,49 @@ ALTER TABLE `hopsworks`.`feature_store_jdbc_connector`
ALTER TABLE `hopsworks`.`serving` ADD COLUMN `deployed_by` int(11) DEFAULT NULL;
ALTER TABLE `hopsworks`.`serving` ADD KEY `deployed_by_fk` (`deployed_by`);
ALTER TABLE `hopsworks`.`serving` ADD CONSTRAINT `deployed_by_fk_serving` FOREIGN KEY (`deployed_by`) REFERENCES `users` (`uid`) ON DELETE CASCADE ON UPDATE NO ACTION;

-- HWORKS-927
ALTER TABLE `hopsworks`.`serving`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also drop revision

DROP COLUMN `model_path`,
DROP COLUMN `artifact_version`,
DROP COLUMN `predictor`,
DROP COLUMN `transformer`,
DROP COLUMN `model_name`,
DROP COLUMN `model_version`,
DROP COLUMN `model_framework`,
DROP COLUMN `batching_configuration`,
DROP COLUMN `optimized`,
DROP COLUMN `instances`,
DROP COLUMN `transformer_instances`,
DROP COLUMN `model_server`,
DROP COLUMN `predictor_resources`,
DROP COLUMN `transformer_resources`;

ALTER TABLE `hopsworks`.`serving` ADD COLUMN `specification` int(11) NOT NULL,
ADD COLUMN `canary_spec` int(11) DEFAULT NULL,
ADD COLUMN `canary_traffic_percentage` TINYINT DEFAULT NULL;
ALTER TABLE `hopsworks`.`serving` ADD CONSTRAINT unique_specification UNIQUE (specification);
ALTER TABLE `hopsworks`.`serving` ADD CONSTRAINT unique_canary_spec UNIQUE (canary_spec);

CREATE TABLE `serving_spec` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`model_path` varchar(255) COLLATE latin1_general_cs NOT NULL,
`artifact_version` int(11) DEFAULT NULL,
`predictor` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`transformer` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`model_name` varchar(255) COLLATE latin1_general_cs NOT NULL,
`model_version` int(11) NOT NULL,
`model_framework` int(11) NOT NULL,
`batching_configuration` varchar(255) COLLATE latin1_general_cs DEFAULT NULL,
`optimized` tinyint(4) NOT NULL DEFAULT '0',
`instances` int(11) NOT NULL DEFAULT '0',
`transformer_instances` int(11) DEFAULT NULL,
`model_server` int(11) NOT NULL DEFAULT '0',
`revision` varchar(8) DEFAULT NULL,
`predictor_resources` varchar(1000) COLLATE latin1_general_cs DEFAULT NULL,
`transformer_resources` varchar(1000) COLLATE latin1_general_cs DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 COLLATE=latin1_general_cs;

ALTER TABLE `hopsworks`.`serving` ADD CONSTRAINT `specification_fk` FOREIGN KEY (`specification`) REFERENCES `serving_spec` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;
ALTER TABLE `hopsworks`.`serving` ADD CONSTRAINT `canary_spec_fk` FOREIGN KEY (`canary_spec`) REFERENCES `serving_spec` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION;