| @@ -63,7 +63,7 @@ public class DevEnvironment implements Serializable { | |||
| /** | |||
| * 备用字段2 | |||
| */ | |||
| private String codePath; | |||
| private String codeConfig; | |||
| /** | |||
| * 创建者 | |||
| */ | |||
| @@ -1,6 +1,6 @@ | |||
| package com.ruoyi.platform.service.impl; | |||
| import cn.hutool.core.util.ObjectUtil; | |||
| import cn.hutool.core.bean.BeanUtil; | |||
| import com.ruoyi.common.core.utils.DateUtils; | |||
| import com.ruoyi.common.security.utils.SecurityUtils; | |||
| import com.ruoyi.platform.domain.CodeConfig; | |||
| @@ -10,8 +10,8 @@ import com.ruoyi.platform.mapper.DevEnvironmentDao; | |||
| import com.ruoyi.platform.service.*; | |||
| import com.ruoyi.platform.utils.DVCUtils; | |||
| import com.ruoyi.platform.utils.JacksonUtil; | |||
| import com.ruoyi.platform.utils.JsonUtils; | |||
| import com.ruoyi.platform.vo.DevEnvironmentVo; | |||
| import com.ruoyi.platform.vo.GitProjectVo; | |||
| import com.ruoyi.platform.vo.PodStatusVo; | |||
| import com.ruoyi.system.api.constant.Constant; | |||
| import com.ruoyi.system.api.model.LoginUser; | |||
| @@ -120,7 +120,8 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { | |||
| //插入预备,此时不需要判断版本重复 | |||
| DevEnvironment devEnvironment = new DevEnvironment(); | |||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | |||
| String localPath = cloneCode(devEnvironmentVo.getCodeConfigId()); | |||
| Map<String, Object> codeConfig = devEnvironmentVo.getCodeConfig(); | |||
| cloneCodePath(codeConfig); | |||
| devEnvironment.setName(devEnvironmentVo.getName()); | |||
| //状态先设为未知 | |||
| devEnvironment.setStatus(Constant.Unknown); | |||
| @@ -140,7 +141,7 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { | |||
| devEnvironment.setUpdateTime(new Date()); | |||
| devEnvironment.setCreateTime(new Date()); | |||
| devEnvironment.setState(Constant.State_valid); | |||
| devEnvironment.setCodePath(localPath); | |||
| devEnvironment.setCodeConfig(JsonUtils.mapToJson(codeConfig)); | |||
| this.devEnvironmentDao.insert(devEnvironment); | |||
| return devEnvironment; | |||
| } | |||
| @@ -198,32 +199,26 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { | |||
| /** | |||
| * 保存代码数据并返回保存路径 | |||
| * @param codeConfigId | |||
| * | |||
| * @param codeMap | |||
| * @return | |||
| */ | |||
| private String cloneCode(Long codeConfigId) { | |||
| String localPath = null; | |||
| try { | |||
| CodeConfig codeConfig = codeConfigService.queryById(codeConfigId); | |||
| if (ObjectUtil.isEmpty(codeConfig)) { | |||
| log.info("[returnCodeConfig error,codeConfigId={}]", codeConfigId); | |||
| return localPath; | |||
| } | |||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | |||
| String gitLinkUsername = loginUser.getSysUser().getUserName(); | |||
| String ci4sUsername = Boolean.TRUE.equals(codeConfig.getIsPublic()) ? Constant.Item_Public : loginUser.getUsername(); | |||
| private void cloneCodePath(Map<String, Object> codeMap) { | |||
| CodeConfig codeConfig = BeanUtil.copyProperties(codeMap, CodeConfig.class); | |||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | |||
| String gitLinkUsername = loginUser.getSysUser().getUserName(); | |||
| String ci4sUsername = Boolean.TRUE.equals(codeConfig.getIsPublic()) ? Constant.Item_Public : loginUser.getUsername(); | |||
| String gitLinkPassword = decrypt(loginUser.getSysUser().getOriginPassword()); | |||
| String repositoryName = ci4sUsername + "_code_" + DateUtils.dateTimeNow(); | |||
| String gitLinkPassword = decrypt(loginUser.getSysUser().getOriginPassword()); | |||
| String repositoryName = ci4sUsername + "_code_" + DateUtils.dateTimeNow(); | |||
| String relatePath = ci4sUsername + "/code/" + repositoryName + "/" + codeConfig.getGitBranch(); | |||
| localPath = localPathlocal + relatePath; | |||
| String relatePath = ci4sUsername + "/code/" + repositoryName + "/" + codeConfig.getGitBranch(); | |||
| String localPath = localPathlocal + relatePath; | |||
| try { | |||
| dvcUtils.gitClone(localPath, codeConfig.getGitUrl(), codeConfig.getGitBranch(), gitLinkUsername, gitLinkPassword); | |||
| } catch (Exception e) { | |||
| log.error("[returnCodeConfig error,e={},codeConfigId={}]",e.getMessage(),codeConfigId); | |||
| log.error("[returnCodeConfig error,e={},codeConfigId={}]", e.getMessage(), codeConfig.getId()); | |||
| } | |||
| return localPath; | |||
| codeMap.put("path", localPath); | |||
| } | |||
| } | |||
| @@ -97,6 +97,10 @@ public class JupyterServiceImpl implements JupyterService { | |||
| // String modelPath = "argo-workflow" + "/" + model.get("path"); | |||
| String modelPath = (String) model.get("path"); | |||
| Map<String, Object> code = JacksonUtil.parseJSONStr2Map(devEnvironment.getCodeConfig()); | |||
| // String modelPath = "argo-workflow" + "/" + model.get("path"); | |||
| String codePath = (String) code.get("path"); | |||
| //构造pod名称 | |||
| String podName = devEnvironment.getCreateBy() + "-editor-pod" + "-" + id; | |||
| //新建编辑器的pvc | |||
| @@ -105,7 +109,7 @@ public class JupyterServiceImpl implements JupyterService { | |||
| // 调用修改后的 createPod 方法,传入额外的参数 | |||
| // Integer podPort = k8sClientUtil.createConfiguredPod(podName, namespace, port, mountPath, pvc, devEnvironment, minioPvcName, datasetPath, modelPath); | |||
| Integer podPort = k8sClientUtil.createConfiguredPod(podName, namespace, port, mountPath, null, devEnvironment, minioPvcName, datasetPath, modelPath,devEnvironment.getCodePath()); | |||
| Integer podPort = k8sClientUtil.createConfiguredPod(podName, namespace, port, mountPath, null, devEnvironment, minioPvcName, datasetPath, modelPath,codePath); | |||
| String url = masterIp + ":" + podPort; | |||
| redisService.setCacheObject(podName, masterIp + ":" + podPort); | |||
| devEnvironment.setStatus(Constant.Pending); | |||
| @@ -32,10 +32,6 @@ public class DevEnvironmentVo implements Serializable { | |||
| */ | |||
| private String envVariable; | |||
| /** | |||
| * 代码配置ID | |||
| */ | |||
| private Long codeConfigId; | |||
| /** | |||
| * 所用镜像 | |||
| */ | |||
| @@ -49,4 +45,9 @@ public class DevEnvironmentVo implements Serializable { | |||
| */ | |||
| private Map<String,Object> model; | |||
| /** | |||
| * 代码配置 | |||
| */ | |||
| private Map<String,Object> codeConfig; | |||
| } | |||
| @@ -4,7 +4,7 @@ | |||
| <!--查询单个--> | |||
| <select id="queryById" resultType="com.ruoyi.platform.domain.DevEnvironment"> | |||
| select | |||
| id,name,status,computing_resource,computing_resource_id, standard,env_variable,image,dataset,model,url,code_path,create_by,create_time,update_by,update_time,state | |||
| id,name,status,computing_resource,computing_resource_id, standard,env_variable,image,dataset,model,url,code_config,create_by,create_time,update_by,update_time,state | |||
| from dev_environment | |||
| where id = #{id} and state = 1 | |||
| </select> | |||
| @@ -12,7 +12,7 @@ | |||
| <!--查询指定行数据--> | |||
| <select id="queryAllByLimit" resultType="com.ruoyi.platform.domain.DevEnvironment"> | |||
| select | |||
| id,name,status,computing_resource,computing_resource_id,standard,env_variable,image,dataset,model,url,code_path,create_by,create_time,update_by,update_time,state | |||
| id,name,status,computing_resource,computing_resource_id,standard,env_variable,image,dataset,model,url,code_config,create_by,create_time,update_by,update_time,state | |||
| from dev_environment | |||
| <where> | |||
| state = 1 | |||
| @@ -46,8 +46,8 @@ | |||
| <if test="devEnvironment.url != null and devEnvironment.url != ''"> | |||
| and url = #{devEnvironment.url} | |||
| </if> | |||
| <if test="devEnvironment.codePath != null and devEnvironment.codePath != ''"> | |||
| and code_path = #{devEnvironment.codePath} | |||
| <if test="devEnvironment.codeConfig != null and devEnvironment.codeConfig != ''"> | |||
| and code_config = #{devEnvironment.codeConfig} | |||
| </if> | |||
| <if test="devEnvironment.createBy != null and devEnvironment.createBy != ''"> | |||
| and create_by = #{devEnvironment.createBy} | |||
| @@ -105,8 +105,8 @@ | |||
| <if test="devEnvironment.url != null and devEnvironment.url != ''"> | |||
| and url = #{devEnvironment.url} | |||
| </if> | |||
| <if test="devEnvironment.codePath != null and devEnvironment.codePath != ''"> | |||
| and code_path = #{devEnvironment.codePath} | |||
| <if test="devEnvironment.codeConfig != null and devEnvironment.codeConfig != ''"> | |||
| and code_config = #{devEnvironment.codeConfig} | |||
| </if> | |||
| <if test="devEnvironment.createBy != null and devEnvironment.createBy != ''"> | |||
| and create_by = #{devEnvironment.createBy} | |||
| @@ -132,7 +132,7 @@ | |||
| <!--新增所有列--> | |||
| <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | |||
| insert into dev_environment(name,status,computing_resource,computing_resource_id,standard,env_variable,image,dataset,model,url,code_path,create_by,create_time,update_by,update_time,state) | |||
| insert into dev_environment(name,status,computing_resource,computing_resource_id,standard,env_variable,image,dataset,model,url,code_config,create_by,create_time,update_by,update_time,state) | |||
| values (#{devEnvironment.name}, | |||
| #{devEnvironment.status}, | |||
| #{devEnvironment.computingResource}, | |||
| @@ -143,7 +143,7 @@ | |||
| #{devEnvironment.dataset}, | |||
| #{devEnvironment.model}, | |||
| #{devEnvironment.url}, | |||
| #{devEnvironment.codePath}, | |||
| #{devEnvironment.codeConfig}, | |||
| #{devEnvironment.createBy}, | |||
| #{devEnvironment.createTime}, | |||
| #{devEnvironment.updateBy}, | |||
| @@ -186,8 +186,8 @@ | |||
| <if test="devEnvironment.url != null and devEnvironment.url != ''"> | |||
| url = #{devEnvironment.url}, | |||
| </if> | |||
| <if test="devEnvironment.codePath != null and devEnvironment.codePath != ''"> | |||
| code_path = #{devEnvironment.codePath}, | |||
| <if test="devEnvironment.codeConfig != null and devEnvironment.codeConfig != ''"> | |||
| code_config = #{devEnvironment.codeConfig}, | |||
| </if> | |||
| <if test="devEnvironment.createBy != null and devEnvironment.createBy != ''"> | |||
| create_by = #{devEnvironment.createBy}, | |||