You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@submarine.apache.org by GitBox <gi...@apache.org> on 2021/10/09 06:47:26 UTC

[GitHub] [submarine] KUAN-HSUN-LI opened a new pull request #770: SUBMARINE-1052. Create submarine model management service in server

KUAN-HSUN-LI opened a new pull request #770:
URL: https://github.com/apache/submarine/pull/770


   ### What is this PR for?
   Create the model management service in the server for later use in model serving and model management workbench.
   
   ### What type of PR is it?
   [Feature]
   
   ### Todos
   
   
   ### What is the Jira issue?
   https://issues.apache.org/jira/browse/SUBMARINE-1052
   
   ### How should this be tested?
   CI pass.
   All of the tests for new functions are provided under the `submarine-server/server-core/src/test/java/org/apache/submarine/server/model/database` directory.
   
   ### 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
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@submarine.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [submarine] jeff-901 commented on a change in pull request #770: SUBMARINE-1052. Create submarine model management service in server

Posted by GitBox <gi...@apache.org>.
jeff-901 commented on a change in pull request #770:
URL: https://github.com/apache/submarine/pull/770#discussion_r725584013



##########
File path: submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/service/ModelVersionService.java
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.service;
+
+import org.apache.ibatis.session.SqlSession;
+import org.apache.submarine.commons.utils.exception.SubmarineRuntimeException;
+import org.apache.submarine.server.database.utils.MyBatisUtil;
+import org.apache.submarine.server.model.database.entities.ModelVersionEntity;
+import org.apache.submarine.server.model.database.mappers.ModelVersionMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class ModelVersionService {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ModelVersionService.class);
+
+  public List<ModelVersionEntity> selectAllVersions(String name) {
+    LOG.info("Model Version select all versions:" + name);
+    List<ModelVersionEntity> modelVersionEntities;
+    try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
+      ModelVersionMapper mapper = sqlSession.getMapper(ModelVersionMapper.class);
+      modelVersionEntities = mapper.selectAllVersions(name);
+      sqlSession.commit();
+    } catch (Exception e) {
+      LOG.error(e.getMessage(), e);
+      throw new SubmarineRuntimeException("Unable to get model version from database");
+    }
+    return modelVersionEntities;
+  }
+
+  public ModelVersionEntity select(String name, Integer version) {
+    LOG.info("Model Version select:" + name + " " + version.toString());
+    ModelVersionEntity modelVersionEntity;
+    try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
+      ModelVersionMapper mapper = sqlSession.getMapper(ModelVersionMapper.class);
+      modelVersionEntity = mapper.select(name, version);
+      sqlSession.commit();
+    } catch (Exception e) {
+      LOG.error(e.getMessage(), e);
+      throw new SubmarineRuntimeException("Unable to get model version from database");
+    }
+    return modelVersionEntity;
+  }
+  public ModelVersionEntity selectWithTag(String name, Integer version) {
+    LOG.info("Model Version select with tag:" + name + " " + version.toString());
+    ModelVersionEntity modelVersionEntity;
+    try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
+      ModelVersionMapper mapper = sqlSession.getMapper(ModelVersionMapper.class);
+      modelVersionEntity = mapper.selectWithTag(name, version);
+      sqlSession.commit();
+    } catch (Exception e) {
+      LOG.error(e.getMessage(), e);
+      throw new SubmarineRuntimeException("Unable to get model version from database");
+    }
+    return modelVersionEntity;
+  }
+
+  public void insert(ModelVersionEntity modelVersion) {
+    LOG.info("Model Version insert " + modelVersion.getName());
+    try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
+      ModelVersionMapper mapper = sqlSession.getMapper(ModelVersionMapper.class);
+      mapper.insert(modelVersion);
+      sqlSession.commit();
+    } catch (Exception e) {
+      LOG.error(e.getMessage(), e);
+      throw new SubmarineRuntimeException("Unable to insert model version from database");
+    }
+  }
+
+  public void update(ModelVersionEntity modelVersion) {

Review comment:
       @KUAN-HSUN-LI  please remember to add "throws SubmarineRuntimeException", thanks.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@submarine.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [submarine] KUAN-HSUN-LI commented on pull request #770: SUBMARINE-1052. Create submarine model management service in server

Posted by GitBox <gi...@apache.org>.
KUAN-HSUN-LI commented on pull request #770:
URL: https://github.com/apache/submarine/pull/770#issuecomment-939257248


   @jeff-901 Can you help me review this PR? Thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@submarine.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [submarine] pingsutw commented on a change in pull request #770: SUBMARINE-1052. Create submarine model management service in server

Posted by GitBox <gi...@apache.org>.
pingsutw commented on a change in pull request #770:
URL: https://github.com/apache/submarine/pull/770#discussion_r730293542



##########
File path: submarine-server/server-core/src/main/java/org/apache/submarine/server/model/database/service/ModelVersionService.java
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.service;
+
+import org.apache.ibatis.session.SqlSession;
+import org.apache.submarine.commons.utils.exception.SubmarineRuntimeException;
+import org.apache.submarine.server.database.utils.MyBatisUtil;
+import org.apache.submarine.server.model.database.entities.ModelVersionEntity;
+import org.apache.submarine.server.model.database.mappers.ModelVersionMapper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class ModelVersionService {
+
+  private static final Logger LOG = LoggerFactory.getLogger(ModelVersionService.class);
+
+  public List<ModelVersionEntity> selectAllVersions(String name) throws SubmarineRuntimeException {
+    LOG.info("Model Version select all versions:" + name);
+    List<ModelVersionEntity> modelVersionEntities;
+    try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
+      ModelVersionMapper mapper = sqlSession.getMapper(ModelVersionMapper.class);
+      modelVersionEntities = mapper.selectAllVersions(name);
+      sqlSession.commit();
+    } catch (Exception e) {
+      LOG.error(e.getMessage(), e);
+      throw new SubmarineRuntimeException("Unable to get model version from database");
+    }
+    return modelVersionEntities;
+  }
+
+  public ModelVersionEntity select(String name, Integer version) throws SubmarineRuntimeException {
+    LOG.info("Model Version select:" + name + " " + version.toString());
+    ModelVersionEntity modelVersionEntity;
+    try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
+      ModelVersionMapper mapper = sqlSession.getMapper(ModelVersionMapper.class);
+      modelVersionEntity = mapper.select(name, version);
+      sqlSession.commit();
+    } catch (Exception e) {
+      LOG.error(e.getMessage(), e);
+      throw new SubmarineRuntimeException("Unable to get model version from database");
+    }
+    return modelVersionEntity;
+  }
+  public ModelVersionEntity selectWithTag(String name, Integer version) throws SubmarineRuntimeException {
+    LOG.info("Model Version select with tag:" + name + " " + version.toString());
+    ModelVersionEntity modelVersionEntity;
+    try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
+      ModelVersionMapper mapper = sqlSession.getMapper(ModelVersionMapper.class);
+      modelVersionEntity = mapper.selectWithTag(name, version);
+      sqlSession.commit();
+    } catch (Exception e) {
+      LOG.error(e.getMessage(), e);
+      throw new SubmarineRuntimeException("Unable to get model version from database");
+    }
+    return modelVersionEntity;
+  }
+
+  public void insert(ModelVersionEntity modelVersion) throws SubmarineRuntimeException {
+    LOG.info("Model Version insert " + modelVersion.getName());
+    try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
+      ModelVersionMapper mapper = sqlSession.getMapper(ModelVersionMapper.class);
+      mapper.insert(modelVersion);
+      sqlSession.commit();
+    } catch (Exception e) {
+      LOG.error(e.getMessage(), e);
+      throw new SubmarineRuntimeException("Unable to insert model version from database");
+    }
+  }
+
+  public void update(ModelVersionEntity modelVersion) throws SubmarineRuntimeException {
+    LOG.info("Model Version update " + modelVersion.getName());
+    try (SqlSession sqlSession = MyBatisUtil.getSqlSession()) {
+      ModelVersionMapper mapper = sqlSession.getMapper(ModelVersionMapper.class);
+      mapper.update(modelVersion);
+      sqlSession.commit();
+    } catch (Exception e) {
+      LOG.error(e.getMessage(), e);
+      throw new SubmarineRuntimeException("Unable to insert model version from database");

Review comment:
       ```suggestion
         throw new SubmarineRuntimeException("Unable to update model version from database");
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@submarine.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [submarine] asfgit closed pull request #770: SUBMARINE-1052. Create submarine model management service in server

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #770:
URL: https://github.com/apache/submarine/pull/770


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@submarine.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org