This is an automated email from the ASF dual-hosted git repository.
pingsutw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git
The following commit(s) were added to refs/heads/master by this push:
new b2dc35d SUBMARINE-978. Add model management database service.
b2dc35d is described below
commit b2dc35db0a6ed07ceda6e28c2db4e7f9f7696a04
Author: jeff-901 <[email protected]>
AuthorDate: Mon Aug 16 13:47:21 2021 +0800
SUBMARINE-978. Add model management database service.
### What is this PR for?
Create model service for later serving and other model management REST api.
### What type of PR is it?
Feature
### Todos
### What is the Jira issue?
https://issues.apache.org/jira/browse/SUBMARINE-978
### How should this be tested?
Call the model service api and see the difference on the mlflow UI.
If you test locally edit the jdbc url ip address in ModelBatisUtil.java
and modelbatis-config.xml.
I will add formal test on
https://issues.apache.org/jira/browse/SUBMARINE-983.
### Screenshots (if appropriate)
### Questions:
* Do the license files need updating? No
* Are there breaking changes for older versions? No
* Does this need new documentation? No
Author: jeff-901 <[email protected]>
Signed-off-by: Kevin <[email protected]>
Closes #712 from jeff-901/SUBMARINE-978 and squashes the following commits:
6f4cdf15 [jeff-901] edit url ip
335f8c25 [jeff-901] fix checkstyle
68ed369b [jeff-901] create model service
---
.../server/database/utils/ModelBatisUtil.java | 82 ++++++++++
.../server/model/database/ModelService.java | 181 +++++++++++++++++++++
.../database/entities/ModelVersionEntity.java | 159 ++++++++++++++++++
.../entities/RegisteredModelNameEntity.java | 74 +++++++++
.../model/database/mappers/ModelVersionMapper.java | 32 ++++
.../mappers/RegisteredModelNameMapper.java | 34 ++++
.../src/main/resources/modelbatis-config.xml | 60 +++++++
.../database/mappers/ModelVersionMapper.xml | 75 +++++++++
.../database/mappers/RegisteredModelNameMapper.xml | 68 ++++++++
9 files changed, 765 insertions(+)
diff --git
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/database/utils/ModelBatisUtil.java
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/database/utils/ModelBatisUtil.java
new file mode 100644
index 0000000..9483854
--- /dev/null
+++
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/database/utils/ModelBatisUtil.java
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.submarine.server.database.utils;
+
+import org.apache.ibatis.io.Resources;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.apache.ibatis.session.SqlSessionFactoryBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Properties;
+
+public class ModelBatisUtil {
+ private static final Logger LOG =
LoggerFactory.getLogger(ModelBatisUtil.class);
+
+ private static SqlSessionFactory sqlSessionFactory;
+
+ static {
+ Reader reader = null;
+ try {
+ try {
+ reader = Resources.getResourceAsReader("modelbatis-config.xml");
+ } catch (IOException e) {
+ LOG.error(e.getMessage(), e);
+ throw new RuntimeException(e.getMessage());
+ }
+
+ String jdbcClassName = "com.mysql.jdbc.Driver";
+ String jdbcUrl = "jdbc:mysql://127.0.0.1:3306/mlflowdb";
+ String jdbcUserName = "mlflow";
+ String jdbcPassword = "password";
+ LOG.info("MyBatisUtil -> jdbcClassName: {}, jdbcUrl: {}, jdbcUserName:
{}, jdbcPassword: {}",
+ jdbcClassName, jdbcUrl, jdbcUserName, jdbcPassword);
+
+ Properties props = new Properties();
+ props.setProperty("jdbc.driverClassName", jdbcClassName);
+ props.setProperty("jdbc.url", jdbcUrl);
+ props.setProperty("jdbc.username", jdbcUserName);
+ props.setProperty("jdbc.password", jdbcPassword);
+
+ sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader, props);
+ } finally {
+ try {
+ if (null != reader) {
+ reader.close();
+ }
+ } catch (IOException e) {
+ LOG.error(e.getMessage(), e);
+ }
+ }
+ }
+
+ /**
+ * Get Session
+ *
+ * @return
+ */
+ public static SqlSession getSqlSession() {
+ return sqlSessionFactory.openSession();
+ }
+
+
+}
diff --git
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/ModelService.java
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/ModelService.java
new file mode 100644
index 0000000..e524318
--- /dev/null
+++
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/ModelService.java
@@ -0,0 +1,181 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.submarine.server.model.database;
+
+import org.apache.ibatis.session.SqlSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import java.util.List;
+import org.apache.submarine.commons.utils.exception.SubmarineRuntimeException;
+import org.apache.submarine.server.database.utils.ModelBatisUtil;
+import
org.apache.submarine.server.model.database.entities.RegisteredModelNameEntity;
+import org.apache.submarine.server.model.database.entities.ModelVersionEntity;
+import
org.apache.submarine.server.model.database.mappers.RegisteredModelNameMapper;
+import org.apache.submarine.server.model.database.mappers.ModelVersionMapper;
+
+public class ModelService {
+
+ private static final Logger
+ LOG =
LoggerFactory.getLogger(org.apache.submarine.server.model.database.ModelService.class);
+
+ public List<RegisteredModelNameEntity> selectAllRegisteredModelName() throws
SubmarineRuntimeException {
+ LOG.info("Registered Model Name selectAll");
+ List<RegisteredModelNameEntity> entities;
+ try (SqlSession sqlSession = ModelBatisUtil.getSqlSession()) {
+ RegisteredModelNameMapper mapper =
sqlSession.getMapper(RegisteredModelNameMapper.class);
+ entities = mapper.selectAll();
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new SubmarineRuntimeException("Unable to get registered model name
entities from database");
+ }
+ return entities;
+ }
+
+ public RegisteredModelNameEntity selectRegisteredModelName(String name)
throws SubmarineRuntimeException {
+ LOG.info("Registered Model Name select " + name);
+ RegisteredModelNameEntity entity;
+ try (SqlSession sqlSession = ModelBatisUtil.getSqlSession()) {
+ RegisteredModelNameMapper mapper =
sqlSession.getMapper(RegisteredModelNameMapper.class);
+ entity = mapper.select(name);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new SubmarineRuntimeException("Unable to get registered model name
entity from database");
+ }
+ return entity;
+ }
+
+ public boolean insertRegisteredModelName(RegisteredModelNameEntity entity)
+ throws SubmarineRuntimeException {
+ LOG.info("Registered Model Name insert " + entity.getName());
+ try (SqlSession sqlSession = ModelBatisUtil.getSqlSession()) {
+ RegisteredModelNameMapper mapper =
sqlSession.getMapper(RegisteredModelNameMapper.class);
+ mapper.insert(entity);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new SubmarineRuntimeException("Unable to insert registered model
name entity from database");
+ }
+ return true;
+ }
+
+ public boolean updateRegisteredModelName(RegisteredModelNameEntity entity)
+ throws SubmarineRuntimeException {
+ LOG.info("Registered Model Name update " + entity.getName());
+ try (SqlSession sqlSession = ModelBatisUtil.getSqlSession()) {
+ RegisteredModelNameMapper mapper =
sqlSession.getMapper(RegisteredModelNameMapper.class);
+ mapper.update(entity);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new SubmarineRuntimeException("Unable to update registered model
name entity from database");
+ }
+ return true;
+ }
+
+ public boolean deleteRegisteredModelName(String name) throws
SubmarineRuntimeException {
+ LOG.info("Registered Model Name delete " + name);
+ try (SqlSession sqlSession = ModelBatisUtil.getSqlSession()) {
+ RegisteredModelNameMapper mapper =
sqlSession.getMapper(RegisteredModelNameMapper.class);
+ mapper.delete(name);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new SubmarineRuntimeException("Unable to delete registered model
name entity from database");
+ }
+ return true;
+ }
+
+ public List<ModelVersionEntity> listModelVersion(String name) throws
SubmarineRuntimeException {
+ LOG.info("Model Version list " + name);
+ List<ModelVersionEntity> entities;
+ try (SqlSession sqlSession = ModelBatisUtil.getSqlSession()) {
+ ModelVersionMapper mapper =
sqlSession.getMapper(ModelVersionMapper.class);
+ entities = mapper.list(name);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new SubmarineRuntimeException("Unable to get model version
entities from database");
+ }
+ return entities;
+ }
+
+ public ModelVersionEntity selectModelVersion(String name, Integer version)
+ throws SubmarineRuntimeException {
+ LOG.info("Model Version select " + name + " " + version.toString());
+ ModelVersionEntity entity = new ModelVersionEntity();
+ entity.setName(name);
+ entity.setVersion(version);
+ try (SqlSession sqlSession = ModelBatisUtil.getSqlSession()) {
+ ModelVersionMapper mapper =
sqlSession.getMapper(ModelVersionMapper.class);
+ entity = mapper.select(entity);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new SubmarineRuntimeException("Unable to get model version entity
from database");
+ }
+ return entity;
+ }
+
+ public boolean insertModelVersion(ModelVersionEntity entity) throws
SubmarineRuntimeException {
+ LOG.info("Model Version insert " + entity.getName());
+ try (SqlSession sqlSession = ModelBatisUtil.getSqlSession()) {
+ ModelVersionMapper mapper =
sqlSession.getMapper(ModelVersionMapper.class);
+ mapper.insert(entity);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new SubmarineRuntimeException("Unable to insert model version
entity from database");
+ }
+ return true;
+ }
+
+
+ public boolean deleteModelVersion(String name, Integer version) throws
SubmarineRuntimeException {
+ LOG.info("Model Version delete " + name + " " + version.toString());
+ ModelVersionEntity entity = new ModelVersionEntity();
+ entity.setName(name);
+ entity.setVersion(version);
+ try (SqlSession sqlSession = ModelBatisUtil.getSqlSession()) {
+ ModelVersionMapper mapper =
sqlSession.getMapper(ModelVersionMapper.class);
+ mapper.delete(entity);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new SubmarineRuntimeException("Unable to delete model version
entity from database");
+ }
+ return true;
+ }
+
+ public boolean deleteAllModelVersion(String name) throws
SubmarineRuntimeException {
+ LOG.info("Model Version delete all " + name);
+ try (SqlSession sqlSession = ModelBatisUtil.getSqlSession()) {
+ ModelVersionMapper mapper =
sqlSession.getMapper(ModelVersionMapper.class);
+ mapper.deleteAll(name);
+ sqlSession.commit();
+ } catch (Exception e) {
+ LOG.error(e.getMessage(), e);
+ throw new SubmarineRuntimeException("Unable to delete model version
entity from database");
+ }
+ return true;
+ }
+
+}
diff --git
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/entities/ModelVersionEntity.java
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/entities/ModelVersionEntity.java
new file mode 100644
index 0000000..7c7cb3b
--- /dev/null
+++
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/entities/ModelVersionEntity.java
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.submarine.server.model.database.entities;
+
+public class ModelVersionEntity {
+ private String name;
+
+ private Integer version;
+
+ private Long createTime;
+
+ private Long lastUpdatedTime;
+
+ private String description;
+
+ private String userId;
+
+ private String currentStage;
+
+ private String source;
+
+ private String runId;
+
+ private String status;
+
+ private String statusMessage;
+
+ private String runLink;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Integer getVersion() {
+ return version;
+ }
+
+ public void setVersion(Integer version) {
+ this.version = version;
+ }
+
+ public Long getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Long createTime) {
+ this.createTime = createTime;
+ }
+
+ public Long getLastUpdatedTime() {
+ return lastUpdatedTime;
+ }
+
+ public void setLastUpdatedTime(Long lastUpdatedTime) {
+ this.lastUpdatedTime = lastUpdatedTime;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getCurrentStage() {
+ return currentStage;
+ }
+
+ public void setCurrentStage(String currentStage) {
+ this.currentStage = currentStage;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public String getRunId() {
+ return runId;
+ }
+
+ public void setRunId(String runId) {
+ this.runId = runId;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public String getStatusMessage() {
+ return statusMessage;
+ }
+
+ public void setStatusMessage(String statusMessage) {
+ this.statusMessage = statusMessage;
+ }
+
+ public String getRunLink() {
+ return runLink;
+ }
+
+ public void setRunLink(String runLink) {
+ this.runLink = runLink;
+ }
+
+ public String toString() {
+ return "ModelVersionEntity{" +
+ "name='" + name + '\'' +
+ ",version='" + version + '\'' +
+ ", createTime='" + createTime + '\'' +
+ ", lastUpdatedTime=" + lastUpdatedTime + '\'' +
+ ", description='" + description + '\'' +
+ ", userId='" + userId + '\'' +
+ ", currentStage='" + currentStage + '\'' +
+ ", source='" + source + '\'' +
+ ", runLink='" + runLink + '\'' +
+ ", runId='" + runId + '\'' +
+ ", status='" + status + '\'' +
+ ", statusMessage='" + statusMessage + '\'' +
+ '}';
+ }
+}
diff --git
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/entities/RegisteredModelNameEntity.java
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/entities/RegisteredModelNameEntity.java
new file mode 100644
index 0000000..b92045b
--- /dev/null
+++
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/entities/RegisteredModelNameEntity.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.submarine.server.model.database.entities;
+
+public class RegisteredModelNameEntity {
+
+ private String name;
+
+ private Long createTime;
+
+ private Long lastUpdatedTime;
+
+ private String description;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Long getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Long createTime) {
+ this.createTime = createTime;
+ }
+
+ public Long getLastUpdatedTime() {
+ return lastUpdatedTime;
+ }
+
+ public void setLastUpdatedTime(Long lastUpdatedTime) {
+ this.lastUpdatedTime = lastUpdatedTime;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public RegisteredModelNameEntity() {}
+
+ public String toString() {
+ return "RegisteredModelNameEntity{" +
+ "name='" + name + '\'' +
+ ", createTime='" + createTime + '\'' +
+ ", lastUpdatedTime=" + lastUpdatedTime + '\'' +
+ ", description='" + description + '\'' +
+ '}';
+ }
+}
diff --git
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/mappers/ModelVersionMapper.java
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/mappers/ModelVersionMapper.java
new file mode 100644
index 0000000..d39fba8
--- /dev/null
+++
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/mappers/ModelVersionMapper.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.submarine.server.model.database.mappers;
+
+import java.util.List;
+import org.apache.submarine.server.model.database.entities.ModelVersionEntity;
+
+public interface ModelVersionMapper {
+ List<ModelVersionEntity> list(String name);
+ ModelVersionEntity select(ModelVersionEntity modelVersionEntity);
+
+ int insert(ModelVersionEntity modelVersionEntity);
+ int delete(ModelVersionEntity modelVersionEntity);
+ int deleteAll(String name);
+}
diff --git
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/mappers/RegisteredModelNameMapper.java
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/mappers/RegisteredModelNameMapper.java
new file mode 100644
index 0000000..2ebc53d
--- /dev/null
+++
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/mappers/RegisteredModelNameMapper.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.submarine.server.model.database.mappers;
+
+import java.util.List;
+import
org.apache.submarine.server.model.database.entities.RegisteredModelNameEntity;
+
+public interface RegisteredModelNameMapper {
+ List<RegisteredModelNameEntity> selectAll();
+ RegisteredModelNameEntity select(String name);
+
+ int insert(RegisteredModelNameEntity registeredmodelNameEntity);
+ int update(RegisteredModelNameEntity registeredmodelNameEntity);
+ int delete(String name);
+
+
+}
diff --git
a/submarine-server/server-core/src/main/resources/modelbatis-config.xml
b/submarine-server/server-core/src/main/resources/modelbatis-config.xml
new file mode 100644
index 0000000..04352c4
--- /dev/null
+++ b/submarine-server/server-core/src/main/resources/modelbatis-config.xml
@@ -0,0 +1,60 @@
+<?xml version='1.0' encoding='UTF-8' ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<!DOCTYPE configuration PUBLIC '-//mybatis.org//DTD Config 3.0//EN'
+ 'http://mybatis.org/dtd/mybatis-3-config.dtd'>
+<configuration>
+ <settings>
+ <setting name="cacheEnabled" value="true"/>
+ <setting name="lazyLoadingEnabled" value="false"/>
+ <setting name="aggressiveLazyLoading" value="true"/>
+ <setting name="logImpl" value="STDOUT_LOGGING"/>
+ </settings>
+
+ <typeAliases>
+ <package name="com.github.pagehelper.model"/>
+ </typeAliases>
+
+ <plugins>
+ <plugin interceptor="com.github.pagehelper.PageInterceptor">
+ <property name="helperDialect" value="mysql"/>
+ <property name="offsetAsPageNum" value="true"/>
+ <property name="rowBoundsWithCount" value="true"/>
+ </plugin>
+ </plugins>
+
+ <environments default="development">
+ <environment id="development">
+ <transactionManager type="JDBC"/>
+ <dataSource type="POOLED">
+ <property name="driver" value="com.mysql.jdbc.Driver"/>
+ <property name="url"
value="jdbc:mysql://127.0.0.1:3306/mlflowdb?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&failOverReadOnly=false&zeroDateTimeBehavior=convertToNull&useSSL=false"/>
+ <property name="username" value="mlflow"/>
+ <property name="password" value="password"/>
+ <property name="poolPingQuery" value="SELECT NOW()"/>
+ <property name="poolPingEnabled" value="true"/>
+ </dataSource>
+ </environment>
+ </environments>
+
+ <mappers>
+ <mapper
resource='org/apache/submarine/database/mappers/RegisteredModelNameMapper.xml'/>
+ <mapper
resource='org/apache/submarine/database/mappers/ModelVersionMapper.xml'/>
+ </mappers>
+</configuration>
diff --git
a/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/ModelVersionMapper.xml
b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/ModelVersionMapper.xml
new file mode 100644
index 0000000..9344f71
--- /dev/null
+++
b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/ModelVersionMapper.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper
namespace="org.apache.submarine.server.model.database.mappers.ModelVersionMapper">
+ <resultMap id="resultMap"
type="org.apache.submarine.server.model.database.entities.ModelVersionEntity">
+ <result column="name" property="name" />
+ <result column="version" property="version" />
+ <result column="creation_time" property="createTime" />
+ <result column="last_updated_time" property="lastUpdatedTime" />
+ <result column="description" property="description" />
+ <result column="user_id" property="userId" />
+ <result column="current_stage" property="currentStage" />
+ <result column="source" property="source" />
+ <result column="run_id" property="runId" />
+ <result column="status" property="status" />
+ <result column="status_message" property="statusMessage" />
+ <result column="run_link" property="runLink" />
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ name, version, creation_time, last_updated_time, description, user_id,
current_stage,
+ source, run_id, status, status_message, run_link
+ </sql>
+
+ <select id="list" parameterType="java.lang.String" resultMap="resultMap">
+ select
+ <include refid="Base_Column_List" />
+ from model_versions
+ where name = #{name,jdbcType=VARCHAR}
+ </select>
+
+ <select id="select"
parameterType="org.apache.submarine.server.model.database.entities.ModelVersionEntity"
resultMap="resultMap">
+ select
+ <include refid="Base_Column_List" />
+ from model_versions
+ where name = #{name,jdbcType=VARCHAR} and version =
#{version,jdbcType=INTEGER}
+ </select>
+
+ <delete id="delete"
parameterType="org.apache.submarine.server.model.database.entities.ModelVersionEntity">
+ delete from model_versions
+ where name = #{name,jdbcType=VARCHAR} and version =
#{version,jdbcType=INTEGER}
+ </delete>
+
+ <delete id="deleteAll" parameterType="java.lang.String">
+ delete from model_versions
+ where name = #{name,jdbcType=VARCHAR}
+ </delete>
+
+ <insert id="insert"
parameterType="org.apache.submarine.server.model.database.entities.ModelVersionEntity">
+ insert into model_versions (name, version, creation_time,
last_updated_time, description, user_id,
+ current_stage, source, run_id, status,
status_message, run_link)
+ values (#{name,jdbcType=VARCHAR}, #{version,jdbcType=INTEGER}, now(),
now(),
+ #{description,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR},
#{currentStage,jdbcType=VARCHAR},
+ #{source,jdbcType=VARCHAR}, #{runId,jdbcType=VARCHAR},
#{status,jdbcType=VARCHAR},
+ #{statusMessage,jdbcType=VARCHAR}, #{runLink,jdbcType=VARCHAR})
+ </insert>
+
+</mapper>
diff --git
a/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/RegisteredModelNameMapper.xml
b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/RegisteredModelNameMapper.xml
new file mode 100644
index 0000000..1ea332a
--- /dev/null
+++
b/submarine-server/server-core/src/main/resources/org/apache/submarine/database/mappers/RegisteredModelNameMapper.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper
namespace="org.apache.submarine.server.model.database.mappers.RegisteredModelNameMapper">
+ <resultMap id="resultMap"
type="org.apache.submarine.server.model.database.entities.RegisteredModelNameEntity">
+ <result column="name" property="name" />
+ <result column="creation_time" property="createTime" />
+ <result column="last_updated_time" property="lastUpdatedTime" />
+ <result column="description" property="description" />
+ </resultMap>
+
+ <sql id="Base_Column_List">
+ name, creation_time, last_updated_time, description
+ </sql>
+
+ <select id="selectAll" resultMap="resultMap">
+ select
+ <include refid="Base_Column_List" />
+ from registered_models
+ </select>
+
+ <select id="select" parameterType="java.lang.String" resultMap="resultMap">
+ select
+ <include refid="Base_Column_List" />
+ from registered_models
+ where name = #{name,jdbcType=VARCHAR}
+ </select>
+
+ <delete id="delete" parameterType="java.lang.String">
+ delete from registered_models
+ where name = #{name,jdbcType=VARCHAR}
+ </delete>
+
+ <insert id="insert"
parameterType="org.apache.submarine.server.model.database.entities.RegisteredModelNameEntity">
+ insert into registered_models (name, creation_time, last_updated_time,
description)
+ values (#{name,jdbcType=VARCHAR}, now(), now(),
#{description,jdbcType=VARCHAR})
+ </insert>
+
+ <update id="update"
parameterType="org.apache.submarine.server.model.database.entities.RegisteredModelNameEntity">
+ update registered_models
+ <set>
+ <if test="description != null">
+ description = #{description,jdbcType=VARCHAR},
+ </if>
+ last_updated_time = now()
+ </set>
+ where name = #{name,jdbcType=VARCHAR}
+ </update>
+
+
+</mapper>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]