| @@ -18,6 +18,11 @@ spec: | |||||
| image: ${k8s-5auth-image} | image: ${k8s-5auth-image} | ||||
| ports: | ports: | ||||
| - containerPort: 9200 | - containerPort: 9200 | ||||
| env: | |||||
| - name: TZ | |||||
| value: Asia/Shanghai | |||||
| - name: JAVA_TOOL_OPTIONS | |||||
| value: "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:5005" | |||||
| --- | --- | ||||
| apiVersion: v1 | apiVersion: v1 | ||||
| @@ -28,9 +33,15 @@ metadata: | |||||
| spec: | spec: | ||||
| type: NodePort | type: NodePort | ||||
| ports: | ports: | ||||
| - port: 9200 | |||||
| - name: http | |||||
| port: 9200 | |||||
| nodePort: 31206 | nodePort: 31206 | ||||
| protocol: TCP | protocol: TCP | ||||
| - name: debug | |||||
| nodePort: 31221 | |||||
| port: 5005 | |||||
| protocol: TCP | |||||
| targetPort: 5005 | |||||
| selector: | selector: | ||||
| app: ci4s-auth | app: ci4s-auth | ||||
| @@ -19,8 +19,6 @@ public class Constant { | |||||
| public final static String Computing_Resource_CPU = "CPU"; // 计算资源_CPU | public final static String Computing_Resource_CPU = "CPU"; // 计算资源_CPU | ||||
| public final static String Computing_Resource_GPU = "GPU"; // 计算资源_GPU | public final static String Computing_Resource_GPU = "GPU"; // 计算资源_GPU | ||||
| public final static int Git_Category_Id = 39; | |||||
| public final static String Topic_Dataset = "dataset"; | public final static String Topic_Dataset = "dataset"; | ||||
| public final static String Topic_model = "model"; | public final static String Topic_model = "model"; | ||||
| @@ -30,7 +28,7 @@ public class Constant { | |||||
| public final static String Source_Hand_Export = "hand_export"; | public final static String Source_Hand_Export = "hand_export"; | ||||
| public final static String Source_Add = "add"; | public final static String Source_Add = "add"; | ||||
| public final static String Building = "building"; | |||||
| public final static String Building = "Building"; | |||||
| public final static String Running = "Running"; | public final static String Running = "Running"; | ||||
| public final static String Failed = "Failed"; | public final static String Failed = "Failed"; | ||||
| @@ -42,7 +40,10 @@ public class Constant { | |||||
| public final static String Error = "Error"; | public final static String Error = "Error"; | ||||
| public final static String Unknown = "Unknown"; | public final static String Unknown = "Unknown"; | ||||
| public final static String Available = "available"; | |||||
| public final static String Available = "Available"; | |||||
| public final static String Ready = "Ready"; | |||||
| public final static String True = "True"; | |||||
| public final static String Type_Train = "train"; | public final static String Type_Train = "train"; | ||||
| public final static String Type_Evaluate = "evaluate"; | public final static String Type_Evaluate = "evaluate"; | ||||
| @@ -62,16 +63,20 @@ public class Constant { | |||||
| public final static String TaskType_ActiveLearn = "active_learn"; | public final static String TaskType_ActiveLearn = "active_learn"; | ||||
| public final static String TaskType_Service = "service"; | public final static String TaskType_Service = "service"; | ||||
| public final static String TaskType_ML = "machine_learn"; | public final static String TaskType_ML = "machine_learn"; | ||||
| public final static String TaskType_TextClassification = "text_classification"; | |||||
| public final static String ML_CSV = "auto_ml"; | public final static String ML_CSV = "auto_ml"; | ||||
| public final static String ML_TextClassification = "text_classification"; | public final static String ML_TextClassification = "text_classification"; | ||||
| public final static String ML_VideoClassification = "video_classification"; | public final static String ML_VideoClassification = "video_classification"; | ||||
| public final static String AL_PYTORCH = "pytorch"; | |||||
| public final static String AL_SKLEARN = "sklearn"; | |||||
| public final static String AL_KERAS = "keras"; | |||||
| public final static String DelFlag = "2"; | public final static String DelFlag = "2"; | ||||
| public final static String Code = "123123"; | public final static String Code = "123123"; | ||||
| public final static String Sex_Men = "0"; | public final static String Sex_Men = "0"; | ||||
| public final static String Admin = "admin"; | |||||
| } | } | ||||
| @@ -4,6 +4,8 @@ import java.util.Set; | |||||
| import javax.validation.constraints.NotBlank; | import javax.validation.constraints.NotBlank; | ||||
| import javax.validation.constraints.NotNull; | import javax.validation.constraints.NotNull; | ||||
| import javax.validation.constraints.Size; | import javax.validation.constraints.Size; | ||||
| import com.ruoyi.system.api.constant.Constant; | |||||
| import org.apache.commons.lang3.builder.ToStringBuilder; | import org.apache.commons.lang3.builder.ToStringBuilder; | ||||
| import org.apache.commons.lang3.builder.ToStringStyle; | import org.apache.commons.lang3.builder.ToStringStyle; | ||||
| import com.ruoyi.common.core.annotation.Excel; | import com.ruoyi.common.core.annotation.Excel; | ||||
| @@ -12,230 +14,225 @@ import com.ruoyi.common.core.web.domain.BaseEntity; | |||||
| /** | /** | ||||
| * 角色表 sys_role | * 角色表 sys_role | ||||
| * | |||||
| * | |||||
| * @author ruoyi | * @author ruoyi | ||||
| */ | */ | ||||
| public class SysRole extends BaseEntity | |||||
| { | |||||
| public class SysRole extends BaseEntity { | |||||
| private static final long serialVersionUID = 1L; | private static final long serialVersionUID = 1L; | ||||
| /** 角色ID */ | |||||
| /** | |||||
| * 角色ID | |||||
| */ | |||||
| @Excel(name = "角色序号", cellType = ColumnType.NUMERIC) | @Excel(name = "角色序号", cellType = ColumnType.NUMERIC) | ||||
| private Long roleId; | private Long roleId; | ||||
| /** 角色名称 */ | |||||
| /** | |||||
| * 角色名称 | |||||
| */ | |||||
| @Excel(name = "角色名称") | @Excel(name = "角色名称") | ||||
| private String roleName; | private String roleName; | ||||
| /** 角色权限 */ | |||||
| /** | |||||
| * 角色权限 | |||||
| */ | |||||
| @Excel(name = "角色权限") | @Excel(name = "角色权限") | ||||
| private String roleKey; | private String roleKey; | ||||
| /** 角色排序 */ | |||||
| /** | |||||
| * 角色排序 | |||||
| */ | |||||
| @Excel(name = "角色排序") | @Excel(name = "角色排序") | ||||
| private Integer roleSort; | private Integer roleSort; | ||||
| /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */ | |||||
| /** | |||||
| * 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) | |||||
| */ | |||||
| @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") | @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") | ||||
| private String dataScope; | private String dataScope; | ||||
| /** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */ | |||||
| /** | |||||
| * 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) | |||||
| */ | |||||
| private boolean menuCheckStrictly; | private boolean menuCheckStrictly; | ||||
| /** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */ | |||||
| /** | |||||
| * 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) | |||||
| */ | |||||
| private boolean deptCheckStrictly; | private boolean deptCheckStrictly; | ||||
| /** 角色状态(0正常 1停用) */ | |||||
| /** | |||||
| * 角色状态(0正常 1停用) | |||||
| */ | |||||
| @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") | @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") | ||||
| private String status; | private String status; | ||||
| /** 删除标志(0代表存在 2代表删除) */ | |||||
| /** | |||||
| * 删除标志(0代表存在 2代表删除) | |||||
| */ | |||||
| private String delFlag; | private String delFlag; | ||||
| /** 用户是否存在此角色标识 默认不存在 */ | |||||
| /** | |||||
| * 用户是否存在此角色标识 默认不存在 | |||||
| */ | |||||
| private boolean flag = false; | private boolean flag = false; | ||||
| /** 菜单组 */ | |||||
| /** | |||||
| * 菜单组 | |||||
| */ | |||||
| private Long[] menuIds; | private Long[] menuIds; | ||||
| /** 部门组(数据权限) */ | |||||
| /** | |||||
| * 部门组(数据权限) | |||||
| */ | |||||
| private Long[] deptIds; | private Long[] deptIds; | ||||
| /** 角色菜单权限 */ | |||||
| /** | |||||
| * 角色菜单权限 | |||||
| */ | |||||
| private Set<String> permissions; | private Set<String> permissions; | ||||
| public SysRole() | |||||
| { | |||||
| public SysRole() { | |||||
| } | } | ||||
| public SysRole(Long roleId) | |||||
| { | |||||
| public SysRole(Long roleId) { | |||||
| this.roleId = roleId; | this.roleId = roleId; | ||||
| } | } | ||||
| public Long getRoleId() | |||||
| { | |||||
| public Long getRoleId() { | |||||
| return roleId; | return roleId; | ||||
| } | } | ||||
| public void setRoleId(Long roleId) | |||||
| { | |||||
| public void setRoleId(Long roleId) { | |||||
| this.roleId = roleId; | this.roleId = roleId; | ||||
| } | } | ||||
| public boolean isAdmin() | |||||
| { | |||||
| return isAdmin(this.roleId); | |||||
| public boolean isAdmin() { | |||||
| return isAdmin(this.roleKey); | |||||
| } | } | ||||
| public static boolean isAdmin(Long roleId) | |||||
| { | |||||
| return roleId != null && 1L == roleId; | |||||
| public static boolean isAdmin(String roleKey) { | |||||
| return Constant.Admin.equals(roleKey); | |||||
| } | } | ||||
| @NotBlank(message = "角色名称不能为空") | @NotBlank(message = "角色名称不能为空") | ||||
| @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符") | @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符") | ||||
| public String getRoleName() | |||||
| { | |||||
| public String getRoleName() { | |||||
| return roleName; | return roleName; | ||||
| } | } | ||||
| public void setRoleName(String roleName) | |||||
| { | |||||
| public void setRoleName(String roleName) { | |||||
| this.roleName = roleName; | this.roleName = roleName; | ||||
| } | } | ||||
| @NotBlank(message = "权限字符不能为空") | @NotBlank(message = "权限字符不能为空") | ||||
| @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") | @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") | ||||
| public String getRoleKey() | |||||
| { | |||||
| public String getRoleKey() { | |||||
| return roleKey; | return roleKey; | ||||
| } | } | ||||
| public void setRoleKey(String roleKey) | |||||
| { | |||||
| public void setRoleKey(String roleKey) { | |||||
| this.roleKey = roleKey; | this.roleKey = roleKey; | ||||
| } | } | ||||
| @NotNull(message = "显示顺序不能为空") | @NotNull(message = "显示顺序不能为空") | ||||
| public Integer getRoleSort() | |||||
| { | |||||
| public Integer getRoleSort() { | |||||
| return roleSort; | return roleSort; | ||||
| } | } | ||||
| public void setRoleSort(Integer roleSort) | |||||
| { | |||||
| public void setRoleSort(Integer roleSort) { | |||||
| this.roleSort = roleSort; | this.roleSort = roleSort; | ||||
| } | } | ||||
| public String getDataScope() | |||||
| { | |||||
| public String getDataScope() { | |||||
| return dataScope; | return dataScope; | ||||
| } | } | ||||
| public void setDataScope(String dataScope) | |||||
| { | |||||
| public void setDataScope(String dataScope) { | |||||
| this.dataScope = dataScope; | this.dataScope = dataScope; | ||||
| } | } | ||||
| public boolean isMenuCheckStrictly() | |||||
| { | |||||
| public boolean isMenuCheckStrictly() { | |||||
| return menuCheckStrictly; | return menuCheckStrictly; | ||||
| } | } | ||||
| public void setMenuCheckStrictly(boolean menuCheckStrictly) | |||||
| { | |||||
| public void setMenuCheckStrictly(boolean menuCheckStrictly) { | |||||
| this.menuCheckStrictly = menuCheckStrictly; | this.menuCheckStrictly = menuCheckStrictly; | ||||
| } | } | ||||
| public boolean isDeptCheckStrictly() | |||||
| { | |||||
| public boolean isDeptCheckStrictly() { | |||||
| return deptCheckStrictly; | return deptCheckStrictly; | ||||
| } | } | ||||
| public void setDeptCheckStrictly(boolean deptCheckStrictly) | |||||
| { | |||||
| public void setDeptCheckStrictly(boolean deptCheckStrictly) { | |||||
| this.deptCheckStrictly = deptCheckStrictly; | this.deptCheckStrictly = deptCheckStrictly; | ||||
| } | } | ||||
| public String getStatus() | |||||
| { | |||||
| public String getStatus() { | |||||
| return status; | return status; | ||||
| } | } | ||||
| public void setStatus(String status) | |||||
| { | |||||
| public void setStatus(String status) { | |||||
| this.status = status; | this.status = status; | ||||
| } | } | ||||
| public String getDelFlag() | |||||
| { | |||||
| public String getDelFlag() { | |||||
| return delFlag; | return delFlag; | ||||
| } | } | ||||
| public void setDelFlag(String delFlag) | |||||
| { | |||||
| public void setDelFlag(String delFlag) { | |||||
| this.delFlag = delFlag; | this.delFlag = delFlag; | ||||
| } | } | ||||
| public boolean isFlag() | |||||
| { | |||||
| public boolean isFlag() { | |||||
| return flag; | return flag; | ||||
| } | } | ||||
| public void setFlag(boolean flag) | |||||
| { | |||||
| public void setFlag(boolean flag) { | |||||
| this.flag = flag; | this.flag = flag; | ||||
| } | } | ||||
| public Long[] getMenuIds() | |||||
| { | |||||
| public Long[] getMenuIds() { | |||||
| return menuIds; | return menuIds; | ||||
| } | } | ||||
| public void setMenuIds(Long[] menuIds) | |||||
| { | |||||
| public void setMenuIds(Long[] menuIds) { | |||||
| this.menuIds = menuIds; | this.menuIds = menuIds; | ||||
| } | } | ||||
| public Long[] getDeptIds() | |||||
| { | |||||
| public Long[] getDeptIds() { | |||||
| return deptIds; | return deptIds; | ||||
| } | } | ||||
| public void setDeptIds(Long[] deptIds) | |||||
| { | |||||
| public void setDeptIds(Long[] deptIds) { | |||||
| this.deptIds = deptIds; | this.deptIds = deptIds; | ||||
| } | } | ||||
| public Set<String> getPermissions() | |||||
| { | |||||
| public Set<String> getPermissions() { | |||||
| return permissions; | return permissions; | ||||
| } | } | ||||
| public void setPermissions(Set<String> permissions) | |||||
| { | |||||
| public void setPermissions(Set<String> permissions) { | |||||
| this.permissions = permissions; | this.permissions = permissions; | ||||
| } | } | ||||
| @Override | @Override | ||||
| public String toString() { | public String toString() { | ||||
| return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) | |||||
| .append("roleId", getRoleId()) | |||||
| .append("roleName", getRoleName()) | |||||
| .append("roleKey", getRoleKey()) | |||||
| .append("roleSort", getRoleSort()) | |||||
| .append("dataScope", getDataScope()) | |||||
| .append("menuCheckStrictly", isMenuCheckStrictly()) | |||||
| .append("deptCheckStrictly", isDeptCheckStrictly()) | |||||
| .append("status", getStatus()) | |||||
| .append("delFlag", getDelFlag()) | |||||
| .append("createBy", getCreateBy()) | |||||
| .append("createTime", getCreateTime()) | |||||
| .append("updateBy", getUpdateBy()) | |||||
| .append("updateTime", getUpdateTime()) | |||||
| .append("remark", getRemark()) | |||||
| .toString(); | |||||
| return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) | |||||
| .append("roleId", getRoleId()) | |||||
| .append("roleName", getRoleName()) | |||||
| .append("roleKey", getRoleKey()) | |||||
| .append("roleSort", getRoleSort()) | |||||
| .append("dataScope", getDataScope()) | |||||
| .append("menuCheckStrictly", isMenuCheckStrictly()) | |||||
| .append("deptCheckStrictly", isDeptCheckStrictly()) | |||||
| .append("status", getStatus()) | |||||
| .append("delFlag", getDelFlag()) | |||||
| .append("createBy", getCreateBy()) | |||||
| .append("createTime", getCreateTime()) | |||||
| .append("updateBy", getUpdateBy()) | |||||
| .append("updateTime", getUpdateTime()) | |||||
| .append("remark", getRemark()) | |||||
| .toString(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -155,13 +155,13 @@ public class SysUser extends BaseEntity { | |||||
| this.userId = userId; | this.userId = userId; | ||||
| } | } | ||||
| public boolean isAdmin() { | |||||
| return isAdmin(this.userId); | |||||
| } | |||||
| public static boolean isAdmin(Long userId) { | |||||
| return userId != null && 1L == userId; | |||||
| } | |||||
| // public boolean isAdmin() { | |||||
| // return isAdmin(this.userId); | |||||
| // } | |||||
| // | |||||
| // public static boolean isAdmin(Long userId) { | |||||
| // return userId != null && 1L == userId; | |||||
| // } | |||||
| public Long getDeptId() { | public Long getDeptId() { | ||||
| return deptId; | return deptId; | ||||
| @@ -70,12 +70,12 @@ public class DataScopeAspect | |||||
| { | { | ||||
| SysUser currentUser = loginUser.getSysUser(); | SysUser currentUser = loginUser.getSysUser(); | ||||
| // 如果是超级管理员,则不过滤数据 | // 如果是超级管理员,则不过滤数据 | ||||
| if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) | |||||
| { | |||||
| // if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) | |||||
| // { | |||||
| String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), SecurityContextHolder.getPermission()); | String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), SecurityContextHolder.getPermission()); | ||||
| dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), | dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(), | ||||
| controllerDataScope.userAlias(), permission); | controllerDataScope.userAlias(), permission); | ||||
| } | |||||
| // } | |||||
| } | } | ||||
| } | } | ||||
| @@ -50,7 +50,7 @@ public class ActiveLearnController extends BaseController { | |||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除主动学习") | @ApiOperation("删除主动学习") | ||||
| public GenericsAjaxResult<String> deleteActiveLearn(@PathVariable("id") Long id) { | |||||
| public GenericsAjaxResult<String> deleteActiveLearn(@PathVariable("id") Long id) throws Exception { | |||||
| return genericsSuccess(this.activeLearnService.delete(id)); | return genericsSuccess(this.activeLearnService.delete(id)); | ||||
| } | } | ||||
| @@ -35,6 +35,12 @@ public class ActiveLearnInsController extends BaseController { | |||||
| return genericsSuccess(this.activeLearnInsService.insert(activeLearnIns)); | return genericsSuccess(this.activeLearnInsService.insert(activeLearnIns)); | ||||
| } | } | ||||
| @PutMapping | |||||
| @ApiOperation("编辑实验实例") | |||||
| public GenericsAjaxResult<ActiveLearnIns> update(@RequestBody ActiveLearnIns activeLearnIns) { | |||||
| return genericsSuccess(this.activeLearnInsService.update(activeLearnIns)); | |||||
| } | |||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除实验实例") | @ApiOperation("删除实验实例") | ||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | ||||
| @@ -59,10 +65,10 @@ public class ActiveLearnInsController extends BaseController { | |||||
| return genericsSuccess(this.activeLearnInsService.getDetailById(id)); | return genericsSuccess(this.activeLearnInsService.getDetailById(id)); | ||||
| } | } | ||||
| @GetMapping("/getExpMetrics") | |||||
| @PostMapping("/getExpMetrics") | |||||
| @ApiOperation("获取当前实验的指标对比地址") | @ApiOperation("获取当前实验的指标对比地址") | ||||
| @ApiResponse | @ApiResponse | ||||
| public GenericsAjaxResult<String> getExpMetrics(@RequestParam(value = "experiment_ins_id") String experimentInsId) throws Exception { | |||||
| public GenericsAjaxResult<String> getExpMetrics(@RequestBody String experimentInsId) throws Exception { | |||||
| return genericsSuccess(activeLearnInsService.getExpMetrics(experimentInsId)); | return genericsSuccess(activeLearnInsService.getExpMetrics(experimentInsId)); | ||||
| } | } | ||||
| } | } | ||||
| @@ -1,72 +0,0 @@ | |||||
| package com.ruoyi.platform.controller.autoML; | |||||
| import com.ruoyi.common.core.web.controller.BaseController; | |||||
| import com.ruoyi.common.core.web.domain.AjaxResult; | |||||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||||
| import com.ruoyi.platform.domain.AutoMl; | |||||
| import com.ruoyi.platform.service.AutoMlService; | |||||
| import com.ruoyi.platform.vo.AutoMlVo; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.annotation.Resource; | |||||
| import java.io.IOException; | |||||
| @RestController | |||||
| @RequestMapping("autoML") | |||||
| @Api("自动机器学习") | |||||
| public class AutoMlController extends BaseController { | |||||
| @Resource | |||||
| private AutoMlService autoMlService; | |||||
| @GetMapping | |||||
| @ApiOperation("分页查询") | |||||
| public GenericsAjaxResult<Page<AutoMl>> queryByPage(@RequestParam("page") int page, | |||||
| @RequestParam("size") int size, | |||||
| @RequestParam(value = "ml_name", required = false) String mlName) { | |||||
| PageRequest pageRequest = PageRequest.of(page, size); | |||||
| return genericsSuccess(this.autoMlService.queryByPage(mlName, pageRequest)); | |||||
| } | |||||
| @PostMapping | |||||
| @ApiOperation("新增自动机器学习") | |||||
| public GenericsAjaxResult<AutoMl> addAutoMl(@RequestBody AutoMlVo autoMlVo) throws Exception { | |||||
| return genericsSuccess(this.autoMlService.save(autoMlVo)); | |||||
| } | |||||
| @PutMapping | |||||
| @ApiOperation("编辑自动机器学习") | |||||
| public GenericsAjaxResult<String> editAutoMl(@RequestBody AutoMlVo autoMlVo) throws Exception { | |||||
| return genericsSuccess(this.autoMlService.edit(autoMlVo)); | |||||
| } | |||||
| @GetMapping("/getAutoMlDetail") | |||||
| @ApiOperation("获取自动机器学习详细信息") | |||||
| public GenericsAjaxResult<AutoMlVo> getAutoMlDetail(@RequestParam("id") Long id) throws IOException { | |||||
| return genericsSuccess(this.autoMlService.getAutoMlDetail(id)); | |||||
| } | |||||
| @DeleteMapping("{id}") | |||||
| @ApiOperation("删除自动机器学习") | |||||
| public GenericsAjaxResult<String> deleteAutoMl(@PathVariable("id") Long id) { | |||||
| return genericsSuccess(this.autoMlService.delete(id)); | |||||
| } | |||||
| @CrossOrigin(origins = "*", allowedHeaders = "*") | |||||
| @PostMapping("/upload") | |||||
| @ApiOperation(value = "上传数据文件csv", notes = "上传数据文件csv,并将信息存入数据库。") | |||||
| public AjaxResult upload(@RequestParam("file") MultipartFile file, @RequestParam("uuid") String uuid) throws Exception { | |||||
| return AjaxResult.success(this.autoMlService.upload(file, uuid)); | |||||
| } | |||||
| @PostMapping("/run/{id}") | |||||
| @ApiOperation("运行自动机器学习实验") | |||||
| public GenericsAjaxResult<String> runAutoML(@PathVariable("id") Long id) throws Exception { | |||||
| return genericsSuccess(this.autoMlService.runAutoMlIns(id)); | |||||
| } | |||||
| } | |||||
| @@ -1,61 +0,0 @@ | |||||
| package com.ruoyi.platform.controller.autoML; | |||||
| import com.ruoyi.common.core.web.controller.BaseController; | |||||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||||
| import com.ruoyi.platform.domain.AutoMlIns; | |||||
| import com.ruoyi.platform.service.AutoMlInsService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.web.bind.annotation.*; | |||||
| import javax.annotation.Resource; | |||||
| import java.io.IOException; | |||||
| import java.util.List; | |||||
| @RestController | |||||
| @RequestMapping("autoMLIns") | |||||
| @Api("自动机器学习实验实例") | |||||
| public class AutoMlInsController extends BaseController { | |||||
| @Resource | |||||
| private AutoMlInsService autoMLInsService; | |||||
| @GetMapping | |||||
| @ApiOperation("分页查询") | |||||
| public GenericsAjaxResult<Page<AutoMlIns>> queryByPage(AutoMlIns autoMlIns, int page, int size) throws IOException { | |||||
| PageRequest pageRequest = PageRequest.of(page, size); | |||||
| return genericsSuccess(this.autoMLInsService.queryByPage(autoMlIns, pageRequest)); | |||||
| } | |||||
| @PostMapping | |||||
| @ApiOperation("新增实验实例") | |||||
| public GenericsAjaxResult<AutoMlIns> add(@RequestBody AutoMlIns autoMlIns) { | |||||
| return genericsSuccess(this.autoMLInsService.insert(autoMlIns)); | |||||
| } | |||||
| @DeleteMapping("{id}") | |||||
| @ApiOperation("删除实验实例") | |||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | |||||
| return genericsSuccess(this.autoMLInsService.removeById(id)); | |||||
| } | |||||
| @DeleteMapping("batchDelete") | |||||
| @ApiOperation("批量删除实验实例") | |||||
| public GenericsAjaxResult<String> batchDelete(@RequestBody List<Long> ids) { | |||||
| return genericsSuccess(this.autoMLInsService.batchDelete(ids)); | |||||
| } | |||||
| @PutMapping("{id}") | |||||
| @ApiOperation("终止实验实例") | |||||
| public GenericsAjaxResult<Boolean> terminateAutoMlIns(@PathVariable("id") Long id) throws Exception { | |||||
| return genericsSuccess(this.autoMLInsService.terminateAutoMlIns(id)); | |||||
| } | |||||
| @GetMapping("{id}") | |||||
| @ApiOperation("查看实验实例详情") | |||||
| public GenericsAjaxResult<AutoMlIns> getDetailById(@PathVariable("id") Long id) { | |||||
| return genericsSuccess(this.autoMLInsService.getDetailById(id)); | |||||
| } | |||||
| } | |||||
| @@ -30,12 +30,11 @@ public class CodeConfigController extends BaseController { | |||||
| @GetMapping | @GetMapping | ||||
| public GenericsAjaxResult<Page<CodeConfig>> queryByPage(@RequestParam("page") int page, | public GenericsAjaxResult<Page<CodeConfig>> queryByPage(@RequestParam("page") int page, | ||||
| @RequestParam("size") int size, | @RequestParam("size") int size, | ||||
| @RequestParam(value = "code_repo_name", required = false) String codeRepoName, | |||||
| @RequestParam(value = "code_repo_vis", required = false)Integer codeRepoVis) { | |||||
| @RequestParam(value = "code_repo_name", required = false) String codeRepoName | |||||
| ) { | |||||
| PageRequest pageRequest = PageRequest.of(page, size); | PageRequest pageRequest = PageRequest.of(page, size); | ||||
| CodeConfig codeConfig = new CodeConfig(); | CodeConfig codeConfig = new CodeConfig(); | ||||
| codeConfig.setCodeRepoName(codeRepoName); | codeConfig.setCodeRepoName(codeRepoName); | ||||
| codeConfig.setCodeRepoVis(codeRepoVis); | |||||
| return genericsSuccess(this.codeConfigService.queryByPage(codeConfig, pageRequest)); | return genericsSuccess(this.codeConfigService.queryByPage(codeConfig, pageRequest)); | ||||
| } | } | ||||
| @@ -46,7 +45,7 @@ public class CodeConfigController extends BaseController { | |||||
| * @return 单条数据 | * @return 单条数据 | ||||
| */ | */ | ||||
| @GetMapping("{id}") | @GetMapping("{id}") | ||||
| public GenericsAjaxResult<CodeConfig> queryById(@PathVariable("id") Long id) { | |||||
| public GenericsAjaxResult<CodeConfig> queryById(@PathVariable("id") Long id) throws Exception { | |||||
| return genericsSuccess(this.codeConfigService.queryById(id)); | return genericsSuccess(this.codeConfigService.queryById(id)); | ||||
| } | } | ||||
| @@ -100,7 +100,7 @@ public class ComponentController { | |||||
| */ | */ | ||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("根据id删除组件") | @ApiOperation("根据id删除组件") | ||||
| public AjaxResult deleteById(@PathVariable("id") Integer id) { | |||||
| public AjaxResult deleteById(@PathVariable("id") Integer id) throws Exception { | |||||
| return AjaxResult.success(this.componentService.removeById(id)); | return AjaxResult.success(this.componentService.removeById(id)); | ||||
| } | } | ||||
| @@ -118,7 +118,7 @@ public class DatasetVersionController extends BaseController { | |||||
| */ | */ | ||||
| @DeleteMapping({"{id}"}) | @DeleteMapping({"{id}"}) | ||||
| @ApiOperation("删除数据集版本") | @ApiOperation("删除数据集版本") | ||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) { | |||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) throws Exception { | |||||
| return genericsSuccess(this.datasetVersionService.removeById(id)); | return genericsSuccess(this.datasetVersionService.removeById(id)); | ||||
| } | } | ||||
| @@ -132,7 +132,7 @@ public class DatasetVersionController extends BaseController { | |||||
| @DeleteMapping("/deleteVersion") | @DeleteMapping("/deleteVersion") | ||||
| @ApiOperation(value = "逻辑删除模型版本", notes = "根据数据集ID和版本逻辑删除模型版本记录。") | @ApiOperation(value = "逻辑删除模型版本", notes = "根据数据集ID和版本逻辑删除模型版本记录。") | ||||
| public GenericsAjaxResult<Map<Integer, String>> deleteDatasetVersion(@RequestParam("dataset_id") Integer datasetId, | public GenericsAjaxResult<Map<Integer, String>> deleteDatasetVersion(@RequestParam("dataset_id") Integer datasetId, | ||||
| @RequestParam("version") String version) { | |||||
| @RequestParam("version") String version) throws Exception { | |||||
| return genericsSuccess(this.datasetVersionService.deleteDatasetVersion(datasetId, version)); | return genericsSuccess(this.datasetVersionService.deleteDatasetVersion(datasetId, version)); | ||||
| } | } | ||||
| @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -42,8 +43,8 @@ public class ExperimentInsController extends BaseController { | |||||
| @GetMapping | @GetMapping | ||||
| @ApiOperation("分页查询") | @ApiOperation("分页查询") | ||||
| public GenericsAjaxResult<Page<ExperimentIns>> queryByPage(ExperimentIns experimentIns, int page, int size) throws IOException { | public GenericsAjaxResult<Page<ExperimentIns>> queryByPage(ExperimentIns experimentIns, int page, int size) throws IOException { | ||||
| PageRequest pageRequest = PageRequest.of(page,size); | |||||
| return genericsSuccess(this.experimentInsService.queryByPage(experimentIns, pageRequest)); | |||||
| PageRequest pageRequest = PageRequest.of(page, size); | |||||
| return genericsSuccess(this.experimentInsService.queryByPage(experimentIns, pageRequest)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -55,7 +56,7 @@ public class ExperimentInsController extends BaseController { | |||||
| @GetMapping("{id}") | @GetMapping("{id}") | ||||
| @ApiOperation("通过id查询实验实例") | @ApiOperation("通过id查询实验实例") | ||||
| public GenericsAjaxResult<ExperimentIns> queryById(@PathVariable("id") Integer id) throws IOException { | public GenericsAjaxResult<ExperimentIns> queryById(@PathVariable("id") Integer id) throws IOException { | ||||
| return genericsSuccess(this.experimentInsService.queryById(id)); | |||||
| return genericsSuccess(this.experimentInsService.queryById(id)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -67,7 +68,7 @@ public class ExperimentInsController extends BaseController { | |||||
| @GetMapping("/queryByExperimentId/{Experiment_id}") | @GetMapping("/queryByExperimentId/{Experiment_id}") | ||||
| @ApiOperation("通过实验id查询查询实验实例列表") | @ApiOperation("通过实验id查询查询实验实例列表") | ||||
| public GenericsAjaxResult<List<ExperimentIns>> queryByExperimentId(@PathVariable("Experiment_id") Integer experimentId) throws IOException { | public GenericsAjaxResult<List<ExperimentIns>> queryByExperimentId(@PathVariable("Experiment_id") Integer experimentId) throws IOException { | ||||
| return genericsSuccess(this.experimentInsService.getByExperimentId(experimentId)); | |||||
| return genericsSuccess(this.experimentInsService.getByExperimentId(experimentId)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -79,7 +80,7 @@ public class ExperimentInsController extends BaseController { | |||||
| @PostMapping | @PostMapping | ||||
| @ApiOperation("新增实验实例") | @ApiOperation("新增实验实例") | ||||
| public GenericsAjaxResult<ExperimentIns> add(@RequestBody ExperimentIns experimentIns) { | public GenericsAjaxResult<ExperimentIns> add(@RequestBody ExperimentIns experimentIns) { | ||||
| return genericsSuccess(this.experimentInsService.insert(experimentIns)); | |||||
| return genericsSuccess(this.experimentInsService.insert(experimentIns)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -91,7 +92,7 @@ public class ExperimentInsController extends BaseController { | |||||
| @PutMapping | @PutMapping | ||||
| @ApiOperation("编辑实验实例") | @ApiOperation("编辑实验实例") | ||||
| public GenericsAjaxResult<ExperimentIns> edit(@RequestBody ExperimentIns experimentIns) throws IOException { | public GenericsAjaxResult<ExperimentIns> edit(@RequestBody ExperimentIns experimentIns) throws IOException { | ||||
| return genericsSuccess(this.experimentInsService.update(experimentIns)); | |||||
| return genericsSuccess(this.experimentInsService.update(experimentIns)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -102,14 +103,14 @@ public class ExperimentInsController extends BaseController { | |||||
| */ | */ | ||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除实验实例") | @ApiOperation("删除实验实例") | ||||
| public GenericsAjaxResult<String> deleteById( @PathVariable("id") Integer id) { | |||||
| return genericsSuccess(this.experimentInsService.removeById(id)); | |||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) { | |||||
| return genericsSuccess(this.experimentInsService.removeById(id)); | |||||
| } | } | ||||
| @DeleteMapping("batchDelete") | @DeleteMapping("batchDelete") | ||||
| @ApiOperation("批量删除实验实例") | @ApiOperation("批量删除实验实例") | ||||
| public GenericsAjaxResult<String> batchDelete(@RequestBody List<Integer> ids) throws Exception{ | |||||
| return genericsSuccess(this.experimentInsService.batchDelete(ids)); | |||||
| public GenericsAjaxResult<String> batchDelete(@RequestBody List<Integer> ids) throws Exception { | |||||
| return genericsSuccess(this.experimentInsService.batchDelete(ids)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -133,8 +134,8 @@ public class ExperimentInsController extends BaseController { | |||||
| @GetMapping("/log") | @GetMapping("/log") | ||||
| @ApiOperation("查询实例日志") | @ApiOperation("查询实例日志") | ||||
| public GenericsAjaxResult<String> showExperimentInsLog(@RequestParam("id") Integer id, | public GenericsAjaxResult<String> showExperimentInsLog(@RequestParam("id") Integer id, | ||||
| @RequestParam("component_id") String componentId){ | |||||
| return genericsSuccess(this.experimentInsService.showExperimentInsLog(id,componentId)); | |||||
| @RequestParam("component_id") String componentId) { | |||||
| return genericsSuccess(this.experimentInsService.showExperimentInsLog(id, componentId)); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -146,14 +147,14 @@ public class ExperimentInsController extends BaseController { | |||||
| @GetMapping("/pods/log") | @GetMapping("/pods/log") | ||||
| @ApiOperation("获取pod实时日志请求") | @ApiOperation("获取pod实时日志请求") | ||||
| public GenericsAjaxResult<Map<String, Object>> getRealtimePodLog(@RequestParam("pod_name") String podName, | public GenericsAjaxResult<Map<String, Object>> getRealtimePodLog(@RequestParam("pod_name") String podName, | ||||
| @RequestParam("start_time") String startTime){ | |||||
| return genericsSuccess(this.experimentInsService.getRealtimePodLog(podName,startTime)); | |||||
| @RequestParam("start_time") String startTime) { | |||||
| return genericsSuccess(this.experimentInsService.getRealtimePodLog(podName, startTime)); | |||||
| } | } | ||||
| @PostMapping("/pods/realTimeLog") | @PostMapping("/pods/realTimeLog") | ||||
| @ApiOperation("获取pod实时日志请求") | @ApiOperation("获取pod实时日志请求") | ||||
| public GenericsAjaxResult<String> getRealtimePodLogFromPod(@RequestBody PodLogVo podLogVo){ | |||||
| public GenericsAjaxResult<String> getRealtimePodLogFromPod(@RequestBody PodLogVo podLogVo) { | |||||
| return genericsSuccess(this.experimentInsService.getRealtimePodLogFromPod(podLogVo)); | return genericsSuccess(this.experimentInsService.getRealtimePodLogFromPod(podLogVo)); | ||||
| } | } | ||||
| @@ -166,14 +167,11 @@ public class ExperimentInsController extends BaseController { | |||||
| @PostMapping("/realTimeLog") | @PostMapping("/realTimeLog") | ||||
| @ApiOperation("查询实验实例实时日志") | @ApiOperation("查询实验实例实时日志") | ||||
| public GenericsAjaxResult<Map<String, Object>> getRealtimeWorkflowLog(@RequestBody LogRequestVo logRequest){ | |||||
| public GenericsAjaxResult<Map<String, Object>> getRealtimeWorkflowLog(@RequestBody LogRequestVo logRequest) { | |||||
| return genericsSuccess(this.experimentInsService.getRealtimeWorkflowLog(logRequest)); | return genericsSuccess(this.experimentInsService.getRealtimeWorkflowLog(logRequest)); | ||||
| } | } | ||||
| /** | /** | ||||
| * 查询实验节点结果 | * 查询实验节点结果 | ||||
| * | * | ||||
| @@ -184,8 +182,13 @@ public class ExperimentInsController extends BaseController { | |||||
| public GenericsAjaxResult<List> getNodeResult(@RequestBody Map map) throws Exception { | public GenericsAjaxResult<List> getNodeResult(@RequestBody Map map) throws Exception { | ||||
| Integer id = Integer.parseInt((String) map.get("id")); | Integer id = Integer.parseInt((String) map.get("id")); | ||||
| String nodeId = (String) map.get("node_id"); | String nodeId = (String) map.get("node_id"); | ||||
| return genericsSuccess(this.experimentInsService.getNodeResult(id,nodeId)); | |||||
| return genericsSuccess(this.experimentInsService.getNodeResult(id, nodeId)); | |||||
| } | } | ||||
| @GetMapping("/time") | |||||
| @ApiOperation("获取当前时间") | |||||
| public GenericsAjaxResult<Date> getTime() { | |||||
| return genericsSuccess(new Date()); | |||||
| } | |||||
| } | } | ||||
| @@ -114,7 +114,7 @@ public class AssetIconController extends BaseController { | |||||
| */ | */ | ||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除图标") | @ApiOperation("删除图标") | ||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) { | |||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) throws Exception { | |||||
| return genericsSuccess(this.assetIconService.removeById(id)); | return genericsSuccess(this.assetIconService.removeById(id)); | ||||
| } | } | ||||
| @@ -0,0 +1,25 @@ | |||||
| package com.ruoyi.platform.controller.knowledgeGraph; | |||||
| import com.ruoyi.common.core.web.controller.BaseController; | |||||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| @RestController | |||||
| @RequestMapping("/knowledgeGraph") | |||||
| @Api("knowledgeGraph service") | |||||
| public class KnowledgeGraphController extends BaseController { | |||||
| @Value("${knowledgeGraphUrl}") | |||||
| private String url; | |||||
| @GetMapping(value = "/getURL") | |||||
| @ApiOperation("得到访问地址") | |||||
| public GenericsAjaxResult<String> getURL() { | |||||
| return genericsSuccess(url); | |||||
| } | |||||
| } | |||||
| @@ -1,9 +1,7 @@ | |||||
| package com.ruoyi.platform.controller.labelStudio; | package com.ruoyi.platform.controller.labelStudio; | ||||
| import com.ruoyi.common.core.web.controller.BaseController; | import com.ruoyi.common.core.web.controller.BaseController; | ||||
| import com.ruoyi.common.core.web.domain.AjaxResult; | |||||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | ||||
| import com.ruoyi.platform.service.JupyterService; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
| @@ -11,12 +9,6 @@ import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
| import javax.annotation.Resource; | |||||
| import java.io.File; | |||||
| import java.io.FileInputStream; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("/labelStudio") | @RequestMapping("/labelStudio") | ||||
| @Api("labelStudio service") | @Api("labelStudio service") | ||||
| @@ -25,7 +17,7 @@ public class labelStudioController extends BaseController { | |||||
| private String url; | private String url; | ||||
| @GetMapping(value = "/getURL") | @GetMapping(value = "/getURL") | ||||
| @ApiOperation("得到访问地址") | @ApiOperation("得到访问地址") | ||||
| public GenericsAjaxResult<String> getURL() throws IOException { | |||||
| public GenericsAjaxResult<String> getURL() { | |||||
| return genericsSuccess(url); | return genericsSuccess(url); | ||||
| } | } | ||||
| } | } | ||||
| @@ -34,6 +34,12 @@ public class MachineLearnInsController extends BaseController { | |||||
| return genericsSuccess(this.machineLearnInsService.insert(machineLearnIns)); | return genericsSuccess(this.machineLearnInsService.insert(machineLearnIns)); | ||||
| } | } | ||||
| @PutMapping | |||||
| @ApiOperation("编辑实验实例") | |||||
| public GenericsAjaxResult<MachineLearnIns> edit(@RequestBody MachineLearnIns machineLearnIns){ | |||||
| return genericsSuccess(this.machineLearnInsService.update(machineLearnIns)); | |||||
| } | |||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除实验实例") | @ApiOperation("删除实验实例") | ||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | ||||
| @@ -101,7 +101,7 @@ public class ModelDependencyController extends BaseController { | |||||
| */ | */ | ||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除模型依赖") | @ApiOperation("删除模型依赖") | ||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) { | |||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) throws Exception { | |||||
| return genericsSuccess(this.modelDependencyService.removeById(id)); | return genericsSuccess(this.modelDependencyService.removeById(id)); | ||||
| } | } | ||||
| @@ -130,7 +130,7 @@ public class ModelsVersionController extends BaseController { | |||||
| @DeleteMapping("/deleteVersion") | @DeleteMapping("/deleteVersion") | ||||
| @ApiOperation(value = "逻辑删除模型版本", notes = "根据模型ID和版本逻辑删除模型版本记录。") | @ApiOperation(value = "逻辑删除模型版本", notes = "根据模型ID和版本逻辑删除模型版本记录。") | ||||
| public GenericsAjaxResult<Map<Integer, String>> deleteModelsVersion(@RequestParam("models_id") Integer modelsId, | public GenericsAjaxResult<Map<Integer, String>> deleteModelsVersion(@RequestParam("models_id") Integer modelsId, | ||||
| @RequestParam("version") String version) throws IOException { | |||||
| @RequestParam("version") String version) throws Exception { | |||||
| return genericsSuccess(this.modelsVersionService.deleteModelsVersion(modelsId, version)); | return genericsSuccess(this.modelsVersionService.deleteModelsVersion(modelsId, version)); | ||||
| } | } | ||||
| @@ -1,6 +1,8 @@ | |||||
| package com.ruoyi.platform.controller.model; | package com.ruoyi.platform.controller.model; | ||||
| import com.ruoyi.common.core.web.controller.BaseController; | |||||
| import com.ruoyi.common.core.web.domain.AjaxResult; | import com.ruoyi.common.core.web.domain.AjaxResult; | ||||
| import com.ruoyi.common.core.web.domain.GenericsAjaxResult; | |||||
| import com.ruoyi.platform.service.ModelsService; | import com.ruoyi.platform.service.ModelsService; | ||||
| import com.ruoyi.platform.vo.ModelsVo; | import com.ruoyi.platform.vo.ModelsVo; | ||||
| import com.ruoyi.platform.vo.QueryModelMetricsVo; | import com.ruoyi.platform.vo.QueryModelMetricsVo; | ||||
| @@ -19,15 +21,15 @@ import java.util.Map; | |||||
| @RestController | @RestController | ||||
| @RequestMapping("newmodel") | @RequestMapping("newmodel") | ||||
| @Api(value = "新模型管理") | @Api(value = "新模型管理") | ||||
| public class NewModelFromGitController { | |||||
| public class NewModelFromGitController extends BaseController { | |||||
| @Resource | @Resource | ||||
| private ModelsService modelsService; | private ModelsService modelsService; | ||||
| @PostMapping("/addModel") | @PostMapping("/addModel") | ||||
| @ApiOperation("添加模型") | @ApiOperation("添加模型") | ||||
| public AjaxResult addModelAndVersion(@RequestBody ModelsVo modelsVo) throws Exception { | |||||
| return AjaxResult.success(this.modelsService.newCreateModel(modelsVo)); | |||||
| public GenericsAjaxResult<String> addModelAndVersion(@RequestBody ModelsVo modelsVo) { | |||||
| return genericsSuccess(this.modelsService.newCreateModel(modelsVo)); | |||||
| } | } | ||||
| @PostMapping("/addVersion") | @PostMapping("/addVersion") | ||||
| @@ -50,7 +50,7 @@ public class RayController extends BaseController { | |||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除自动超参数寻优") | @ApiOperation("删除自动超参数寻优") | ||||
| public GenericsAjaxResult<String> deleteRay(@PathVariable("id") Long id) { | |||||
| public GenericsAjaxResult<String> deleteRay(@PathVariable("id") Long id) throws Exception { | |||||
| return genericsSuccess(this.rayService.delete(id)); | return genericsSuccess(this.rayService.delete(id)); | ||||
| } | } | ||||
| @@ -35,6 +35,12 @@ public class RayInsController extends BaseController { | |||||
| return genericsSuccess(this.rayInsService.insert(rayIns)); | return genericsSuccess(this.rayInsService.insert(rayIns)); | ||||
| } | } | ||||
| @PutMapping | |||||
| @ApiOperation("编辑实验实例") | |||||
| public GenericsAjaxResult update(@RequestBody RayIns rayIns) { | |||||
| return genericsSuccess(this.rayInsService.update(rayIns)); | |||||
| } | |||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除实验实例") | @ApiOperation("删除实验实例") | ||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | public GenericsAjaxResult<String> deleteById(@PathVariable("id") Long id) { | ||||
| @@ -94,7 +94,7 @@ public class ComputingResourceController extends BaseController { | |||||
| */ | */ | ||||
| @DeleteMapping("{id}") | @DeleteMapping("{id}") | ||||
| @ApiOperation("删除计算资源") | @ApiOperation("删除计算资源") | ||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) { | |||||
| public GenericsAjaxResult<String> deleteById(@PathVariable("id") Integer id) throws Exception { | |||||
| return genericsSuccess(this.computingResourceService.removeById(id)); | return genericsSuccess(this.computingResourceService.removeById(id)); | ||||
| } | } | ||||
| @@ -84,7 +84,7 @@ public class WorkflowParamController extends BaseController { | |||||
| */ | */ | ||||
| @DeleteMapping | @DeleteMapping | ||||
| @ApiOperation("删除流水线参数") | @ApiOperation("删除流水线参数") | ||||
| public GenericsAjaxResult<String> deleteById(Integer id) { | |||||
| public GenericsAjaxResult<String> deleteById(Integer id) throws Exception { | |||||
| return genericsSuccess(this.workflowParamService.removeById(id)); | return genericsSuccess(this.workflowParamService.removeById(id)); | ||||
| } | } | ||||
| @@ -1,184 +0,0 @@ | |||||
| package com.ruoyi.platform.domain; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||||
| import com.ruoyi.platform.vo.VersionVo; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| import java.util.Map; | |||||
| @Data | |||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||||
| @ApiModel(description = "自动机器学习") | |||||
| public class AutoMl { | |||||
| private Long id; | |||||
| @ApiModelProperty(value = "实验名称") | |||||
| private String mlName; | |||||
| @ApiModelProperty(value = "实验描述") | |||||
| private String mlDescription; | |||||
| @ApiModelProperty(value = "任务类型:classification或regression") | |||||
| private String taskType; | |||||
| @ApiModelProperty(value = "搜索合适模型的时间限制(以秒为单位)。通过增加这个值,auto-sklearn有更高的机会找到更好的模型。默认3600,非必传。") | |||||
| private Integer timeLeftForThisTask; | |||||
| @ApiModelProperty(value = "单次调用机器学习模型的时间限制(以秒为单位)。如果机器学习算法运行超过时间限制,将终止模型拟合。将这个值设置得足够高,这样典型的机器学习算法就可以适用于训练数据。默认600,非必传。") | |||||
| private Integer perRunTimeLimit; | |||||
| @ApiModelProperty(value = "集成模型数量,如果设置为0,则没有集成。默认50,非必传。") | |||||
| private Integer ensembleSize; | |||||
| @ApiModelProperty(value = "设置为None将禁用集成构建,设置为SingleBest仅使用单个最佳模型而不是集成,设置为default,它将对单目标问题使用EnsembleSelection,对多目标问题使用MultiObjectiveDummyEnsemble。默认default,非必传。") | |||||
| private String ensembleClass; | |||||
| @ApiModelProperty(value = "在构建集成时只考虑ensemble_nbest模型。这是受到了“最大限度地利用集成选择”中引入的库修剪概念的启发。这是独立于ensemble_class参数的,并且这个修剪步骤是在构造集成之前完成的。默认50,非必传。") | |||||
| private Integer ensembleNbest; | |||||
| @ApiModelProperty(value = "定义在磁盘中保存的模型的最大数量。额外的模型数量将被永久删除。由于这个变量的性质,它设置了一个集成可以使用多少个模型的上限。必须是大于等于1的整数。如果设置为None,则所有模型都保留在磁盘上。默认50,非必传。") | |||||
| private Integer maxModelsOnDisc; | |||||
| @ApiModelProperty(value = "随机种子,将决定输出文件名。默认1,非必传。") | |||||
| private Integer seed; | |||||
| @ApiModelProperty(value = "机器学习算法的内存限制(MB)。如果auto-sklearn试图分配超过memory_limit MB,它将停止拟合机器学习算法。默认3072,非必传。") | |||||
| private Integer memoryLimit; | |||||
| @ApiModelProperty(value = "如果为None,则使用所有可能的分类算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components/<step>/*。与参数exclude不兼容。多选,逗号分隔。包含:adaboost\n" + | |||||
| "bernoulli_nb\n" + | |||||
| "decision_tree\n" + | |||||
| "extra_trees\n" + | |||||
| "gaussian_nb\n" + | |||||
| "gradient_boosting\n" + | |||||
| "k_nearest_neighbors\n" + | |||||
| "lda\n" + | |||||
| "liblinear_svc\n" + | |||||
| "libsvm_svc\n" + | |||||
| "mlp\n" + | |||||
| "multinomial_nb\n" + | |||||
| "passive_aggressive\n" + | |||||
| "qda\n" + | |||||
| "random_forest\n" + | |||||
| "sgd") | |||||
| private String includeClassifier; | |||||
| @ApiModelProperty(value = "如果为None,则使用所有可能的特征预处理算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components/<step>/*。与参数exclude不兼容。多选,逗号分隔。包含:densifier\n" + | |||||
| "extra_trees_preproc_for_classification\n" + | |||||
| "extra_trees_preproc_for_regression\n" + | |||||
| "fast_ica\n" + | |||||
| "feature_agglomeration\n" + | |||||
| "kernel_pca\n" + | |||||
| "kitchen_sinks\n" + | |||||
| "liblinear_svc_preprocessor\n" + | |||||
| "no_preprocessing\n" + | |||||
| "nystroem_sampler\n" + | |||||
| "pca\n" + | |||||
| "polynomial\n" + | |||||
| "random_trees_embedding\n" + | |||||
| "select_percentile_classification\n" + | |||||
| "select_percentile_regression\n" + | |||||
| "select_rates_classification\n" + | |||||
| "select_rates_regression\n" + | |||||
| "truncatedSVD") | |||||
| private String includeFeaturePreprocessor; | |||||
| @ApiModelProperty(value = "如果为None,则使用所有可能的回归算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components/<step>/*。与参数exclude不兼容。多选,逗号分隔。包含:adaboost,\n" + | |||||
| "ard_regression,\n" + | |||||
| "decision_tree,\n" + | |||||
| "extra_trees,\n" + | |||||
| "gaussian_process,\n" + | |||||
| "gradient_boosting,\n" + | |||||
| "k_nearest_neighbors,\n" + | |||||
| "liblinear_svr,\n" + | |||||
| "libsvm_svr,\n" + | |||||
| "mlp,\n" + | |||||
| "random_forest,\n" + | |||||
| "sgd") | |||||
| private String includeRegressor; | |||||
| private String excludeClassifier; | |||||
| private String excludeRegressor; | |||||
| private String excludeFeaturePreprocessor; | |||||
| @ApiModelProperty(value = "测试集的比率,0到1之间") | |||||
| private Float testSize; | |||||
| @ApiModelProperty(value = "如何处理过拟合,如果使用基于“cv”的方法或Splitter对象,可能需要使用resampling_strategy_arguments。holdout或crossValid") | |||||
| private String resamplingStrategy; | |||||
| @ApiModelProperty(value = "重采样划分训练集和验证集,训练集的比率,0到1之间") | |||||
| private Float trainSize; | |||||
| @ApiModelProperty(value = "拆分数据前是否进行shuffle") | |||||
| private Boolean shuffle; | |||||
| @ApiModelProperty(value = "交叉验证的折数,当resamplingStrategy为crossValid时,此项必填,为整数") | |||||
| private Integer folds; | |||||
| @ApiModelProperty(value = "文件夹存放配置输出和日志文件,默认/tmp/automl") | |||||
| private String tmpFolder; | |||||
| @ApiModelProperty(value = "数据集csv文件中哪几列是预测目标列,逗号分隔") | |||||
| private String targetColumns; | |||||
| @ApiModelProperty(value = "自定义指标名称") | |||||
| private String metricName; | |||||
| @ApiModelProperty(value = "模型优化目标指标及权重,json格式。分类的指标包含:accuracy\n" + | |||||
| "balanced_accuracy\n" + | |||||
| "roc_auc\n" + | |||||
| "average_precision\n" + | |||||
| "log_loss\n" + | |||||
| "precision_macro\n" + | |||||
| "precision_micro\n" + | |||||
| "precision_samples\n" + | |||||
| "precision_weighted\n" + | |||||
| "recall_macro\n" + | |||||
| "recall_micro\n" + | |||||
| "recall_samples\n" + | |||||
| "recall_weighted\n" + | |||||
| "f1_macro\n" + | |||||
| "f1_micro\n" + | |||||
| "f1_samples\n" + | |||||
| "f1_weighted\n" + | |||||
| "回归的指标包含:mean_absolute_error\n" + | |||||
| "mean_squared_error\n" + | |||||
| "root_mean_squared_error\n" + | |||||
| "mean_squared_log_error\n" + | |||||
| "median_absolute_error\n" + | |||||
| "r2") | |||||
| private String metrics; | |||||
| @ApiModelProperty(value = "指标优化方向,是越大越好还是越小越好") | |||||
| private Boolean greaterIsBetter; | |||||
| @ApiModelProperty(value = "模型计算并打印指标") | |||||
| private String scoringFunctions; | |||||
| private Integer state; | |||||
| private String runState; | |||||
| private Double progress; | |||||
| private String createBy; | |||||
| private Date createTime; | |||||
| private String updateBy; | |||||
| private Date updateTime; | |||||
| private String dataset; | |||||
| @ApiModelProperty(value = "状态列表") | |||||
| private String statusList; | |||||
| } | |||||
| @@ -1,50 +0,0 @@ | |||||
| package com.ruoyi.platform.domain; | |||||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| @Data | |||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||||
| @ApiModel(description = "自动机器学习实验实例") | |||||
| public class AutoMlIns { | |||||
| private Long id; | |||||
| private Long autoMlId; | |||||
| private String resultPath; | |||||
| private String modelPath; | |||||
| private String imgPath; | |||||
| private String runHistoryPath; | |||||
| private Integer state; | |||||
| private String status; | |||||
| private String nodeStatus; | |||||
| private String nodeResult; | |||||
| private String param; | |||||
| private String source; | |||||
| @ApiModelProperty(value = "Argo实例名称") | |||||
| private String argoInsName; | |||||
| @ApiModelProperty(value = "Argo命名空间") | |||||
| private String argoInsNs; | |||||
| private Date createTime; | |||||
| private Date updateTime; | |||||
| private Date finishTime; | |||||
| } | |||||
| @@ -21,6 +21,9 @@ public class CodeConfig implements Serializable { | |||||
| @ApiModelProperty(name = "code_repo_vis", value = "代码仓库可见性(1-公开,0-私有)") | @ApiModelProperty(name = "code_repo_vis", value = "代码仓库可见性(1-公开,0-私有)") | ||||
| private Integer codeRepoVis; | private Integer codeRepoVis; | ||||
| @ApiModelProperty(name = "is_public", value = "1-公开,0-私有)") | |||||
| private Boolean isPublic; | |||||
| @ApiModelProperty(name = "git_url", value = "Git地址") | @ApiModelProperty(name = "git_url", value = "Git地址") | ||||
| private String gitUrl; | private String gitUrl; | ||||
| @@ -7,6 +7,8 @@ import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @Data | @Data | ||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | ||||
| @@ -48,4 +50,6 @@ public class MachineLearnIns { | |||||
| private Date updateTime; | private Date updateTime; | ||||
| private Date finishTime; | private Date finishTime; | ||||
| private Map fileMap; | |||||
| } | } | ||||
| @@ -1,23 +0,0 @@ | |||||
| package com.ruoyi.platform.mapper; | |||||
| import com.ruoyi.platform.domain.AutoMl; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import org.springframework.data.domain.Pageable; | |||||
| import java.util.List; | |||||
| public interface AutoMlDao { | |||||
| long count(@Param("mlName") String mlName); | |||||
| List<AutoMl> queryByPage(@Param("mlName") String mlName, @Param("pageable") Pageable pageable); | |||||
| AutoMl getAutoMlById(@Param("id") Long id); | |||||
| AutoMl getAutoMlByName(@Param("mlName") String mlName); | |||||
| int save(@Param("autoMl") AutoMl autoMl); | |||||
| int edit(@Param("autoMl") AutoMl autoMl); | |||||
| List<AutoMl> queryByDatasetId(@Param("datasetId") String datasetId); | |||||
| } | |||||
| @@ -1,23 +0,0 @@ | |||||
| package com.ruoyi.platform.mapper; | |||||
| import com.ruoyi.platform.domain.AutoMlIns; | |||||
| import org.apache.ibatis.annotations.Param; | |||||
| import org.springframework.data.domain.Pageable; | |||||
| import java.util.List; | |||||
| public interface AutoMlInsDao { | |||||
| long count(@Param("autoMlIns") AutoMlIns autoMlIns); | |||||
| List<AutoMlIns> queryAllByLimit(@Param("autoMlIns") AutoMlIns autoMlIns, @Param("pageable") Pageable pageable); | |||||
| List<AutoMlIns> getByAutoMlId(@Param("autoMlId") Long AutoMlId); | |||||
| int insert(@Param("autoMlIns") AutoMlIns autoMlIns); | |||||
| int update(@Param("autoMlIns") AutoMlIns autoMlIns); | |||||
| AutoMlIns queryById(@Param("id") Long id); | |||||
| List<AutoMlIns> queryByAutoMlInsIsNotTerminated(); | |||||
| } | |||||
| @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.HashSet; | |||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -31,9 +32,9 @@ public class ActiveLearnInsStatusTask { | |||||
| @Resource | @Resource | ||||
| private ResourceOccupyService resourceOccupyService; | private ResourceOccupyService resourceOccupyService; | ||||
| private List<Long> activeLearnIds = new ArrayList<>(); | |||||
| private HashSet<Long> activeLearnIds = new HashSet<>(); | |||||
| @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 | |||||
| @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 | |||||
| public void executeActiveLearnInsStatus() { | public void executeActiveLearnInsStatus() { | ||||
| List<ActiveLearnIns> activeLearnInsList = activeLearnInsService.queryActiveLearnInsIsNotTerminated(); | List<ActiveLearnIns> activeLearnInsList = activeLearnInsService.queryActiveLearnInsIsNotTerminated(); | ||||
| @@ -52,7 +53,8 @@ public class ActiveLearnInsStatusTask { | |||||
| // 扣除积分 | // 扣除积分 | ||||
| if (Constant.Running.equals(activeLearnIns.getStatus())) { | if (Constant.Running.equals(activeLearnIns.getStatus())) { | ||||
| resourceOccupyService.deducing(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); | resourceOccupyService.deducing(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); | ||||
| } else if (Constant.Failed.equals(activeLearnIns.getStatus()) || Constant.Terminated.equals(activeLearnIns.getStatus()) | |||||
| } | |||||
| else if (Constant.Failed.equals(activeLearnIns.getStatus()) || Constant.Terminated.equals(activeLearnIns.getStatus()) | |||||
| || Constant.Succeeded.equals(activeLearnIns.getStatus())) { | || Constant.Succeeded.equals(activeLearnIns.getStatus())) { | ||||
| resourceOccupyService.endDeduce(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); | resourceOccupyService.endDeduce(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); | ||||
| } | } | ||||
| @@ -76,14 +78,16 @@ public class ActiveLearnInsStatusTask { | |||||
| } | } | ||||
| } | } | ||||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||||
| @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 | |||||
| public void executeActiveLearnStatus() { | public void executeActiveLearnStatus() { | ||||
| if (activeLearnIds.size() == 0) { | |||||
| if (activeLearnIds.isEmpty()) { | |||||
| return; | return; | ||||
| } | } | ||||
| // 存储需要更新的实验对象列表 | // 存储需要更新的实验对象列表 | ||||
| List<ActiveLearn> updateActiveLearns = new ArrayList<>(); | List<ActiveLearn> updateActiveLearns = new ArrayList<>(); | ||||
| for (Long activeLearnId : activeLearnIds) { | |||||
| Iterator<Long> iterator1 = activeLearnIds.iterator(); | |||||
| while (iterator1.hasNext()) { | |||||
| Long activeLearnId = iterator1.next(); | |||||
| // 获取当前实验的所有实例列表 | // 获取当前实验的所有实例列表 | ||||
| List<ActiveLearnIns> insList = activeLearnInsDao.getByActiveLearnId(activeLearnId); | List<ActiveLearnIns> insList = activeLearnInsDao.getByActiveLearnId(activeLearnId); | ||||
| List<String> statusList = new ArrayList<>(); | List<String> statusList = new ArrayList<>(); | ||||
| @@ -93,10 +97,14 @@ public class ActiveLearnInsStatusTask { | |||||
| } | } | ||||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | ||||
| ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(activeLearnId); | ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(activeLearnId); | ||||
| if (!StringUtils.equals(activeLearn.getStatusList(), subStatus)) { | |||||
| activeLearn.setStatusList(subStatus); | |||||
| updateActiveLearns.add(activeLearn); | |||||
| activeLearnDao.edit(activeLearn); | |||||
| if (activeLearn == null) { | |||||
| iterator1.remove(); | |||||
| } else { | |||||
| if (!StringUtils.equals(activeLearn.getStatusList(), subStatus)) { | |||||
| activeLearn.setStatusList(subStatus); | |||||
| updateActiveLearns.add(activeLearn); | |||||
| activeLearnDao.edit(activeLearn); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -1,98 +0,0 @@ | |||||
| package com.ruoyi.platform.scheduling; | |||||
| import com.ruoyi.system.api.constant.Constant; | |||||
| import com.ruoyi.platform.domain.AutoMl; | |||||
| import com.ruoyi.platform.domain.AutoMlIns; | |||||
| import com.ruoyi.platform.mapper.AutoMlDao; | |||||
| import com.ruoyi.platform.mapper.AutoMlInsDao; | |||||
| import com.ruoyi.platform.service.AutoMlInsService; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.scheduling.annotation.Scheduled; | |||||
| import org.springframework.stereotype.Component; | |||||
| import javax.annotation.Resource; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Iterator; | |||||
| import java.util.List; | |||||
| @Component() | |||||
| public class AutoMlInsStatusTask { | |||||
| @Resource | |||||
| private AutoMlInsService autoMlInsService; | |||||
| @Resource | |||||
| private AutoMlInsDao autoMlInsDao; | |||||
| @Resource | |||||
| private AutoMlDao autoMlDao; | |||||
| private List<Long> autoMlIds = new ArrayList<>(); | |||||
| @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 | |||||
| public void executeAutoMlInsStatus() { | |||||
| // 首先查到所有非终止态的实验实例 | |||||
| List<AutoMlIns> autoMlInsList = autoMlInsService.queryByAutoMlInsIsNotTerminated(); | |||||
| // 去argo查询状态 | |||||
| List<AutoMlIns> updateList = new ArrayList<>(); | |||||
| if (autoMlInsList != null && autoMlInsList.size() > 0) { | |||||
| for (AutoMlIns autoMlIns : autoMlInsList) { | |||||
| //当原本状态为null或非终止态时才调用argo接口 | |||||
| try { | |||||
| autoMlIns = autoMlInsService.queryStatusFromArgo(autoMlIns); | |||||
| } catch (Exception e) { | |||||
| autoMlIns.setStatus(Constant.Failed); | |||||
| } | |||||
| // 线程安全的添加操作 | |||||
| synchronized (autoMlIds) { | |||||
| autoMlIds.add(autoMlIns.getAutoMlId()); | |||||
| } | |||||
| updateList.add(autoMlIns); | |||||
| } | |||||
| if (updateList.size() > 0) { | |||||
| for (AutoMlIns autoMlIns : updateList) { | |||||
| autoMlInsDao.update(autoMlIns); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||||
| public void executeAutoMlStatus() { | |||||
| if (autoMlIds.size() == 0) { | |||||
| return; | |||||
| } | |||||
| // 存储需要更新的实验对象列表 | |||||
| List<AutoMl> updateAutoMls = new ArrayList<>(); | |||||
| for (Long autoMlId : autoMlIds) { | |||||
| // 获取当前实验的所有实例列表 | |||||
| List<AutoMlIns> insList = autoMlInsDao.getByAutoMlId(autoMlId); | |||||
| List<String> statusList = new ArrayList<>(); | |||||
| // 更新实验状态列表 | |||||
| for (int i = 0; i < insList.size(); i++) { | |||||
| statusList.add(insList.get(i).getStatus()); | |||||
| } | |||||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | |||||
| AutoMl autoMl = autoMlDao.getAutoMlById(autoMlId); | |||||
| if (!StringUtils.equals(autoMl.getStatusList(), subStatus)) { | |||||
| autoMl.setStatusList(subStatus); | |||||
| updateAutoMls.add(autoMl); | |||||
| autoMlDao.edit(autoMl); | |||||
| } | |||||
| } | |||||
| if (!updateAutoMls.isEmpty()) { | |||||
| // 使用Iterator进行安全的删除操作 | |||||
| Iterator<Long> iterator = autoMlIds.iterator(); | |||||
| while (iterator.hasNext()) { | |||||
| Long autoMlId = iterator.next(); | |||||
| for (AutoMl autoMl : updateAutoMls) { | |||||
| if (autoMl.getId().equals(autoMlId)) { | |||||
| iterator.remove(); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -34,9 +34,9 @@ public class ExperimentInstanceStatusTask { | |||||
| @Resource | @Resource | ||||
| private ResourceOccupyService resourceOccupyService; | private ResourceOccupyService resourceOccupyService; | ||||
| private List<Integer> experimentIds = new ArrayList<>(); | |||||
| private HashSet<Integer> experimentIds = new HashSet<>(); | |||||
| @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 | |||||
| @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 | |||||
| public void executeExperimentInsStatus() throws Exception { | public void executeExperimentInsStatus() throws Exception { | ||||
| // 首先查到所有非终止态的实验实例 | // 首先查到所有非终止态的实验实例 | ||||
| List<ExperimentIns> experimentInsList = experimentInsService.queryByExperimentIsNotTerminated(); | List<ExperimentIns> experimentInsList = experimentInsService.queryByExperimentIsNotTerminated(); | ||||
| @@ -141,14 +141,17 @@ public class ExperimentInstanceStatusTask { | |||||
| } | } | ||||
| } | } | ||||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||||
| @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 | |||||
| public void executeExperimentStatus() throws IOException { | public void executeExperimentStatus() throws IOException { | ||||
| if (experimentIds.size() == 0) { | |||||
| if (experimentIds.isEmpty()) { | |||||
| return; | return; | ||||
| } | } | ||||
| // 存储需要更新的实验对象列表 | // 存储需要更新的实验对象列表 | ||||
| List<Experiment> updateExperiments = new ArrayList<>(); | List<Experiment> updateExperiments = new ArrayList<>(); | ||||
| for (Integer experimentId : experimentIds) { | |||||
| Iterator<Integer> iterator1 = experimentIds.iterator(); | |||||
| while (iterator1.hasNext()) { | |||||
| Integer experimentId = iterator1.next(); | |||||
| // 获取当前实验的所有实例列表 | // 获取当前实验的所有实例列表 | ||||
| List<ExperimentIns> insList = experimentInsService.getByExperimentId(experimentId); | List<ExperimentIns> insList = experimentInsService.getByExperimentId(experimentId); | ||||
| List<String> statusList = new ArrayList<>(); | List<String> statusList = new ArrayList<>(); | ||||
| @@ -158,10 +161,14 @@ public class ExperimentInstanceStatusTask { | |||||
| } | } | ||||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | ||||
| Experiment experiment = experimentDao.queryById(experimentId); | Experiment experiment = experimentDao.queryById(experimentId); | ||||
| // 如果实验状态列表发生变化,则更新实验对象,并加入到需要更新的列表中 | |||||
| if (!StringUtils.equals(subStatus, experiment.getStatusList())) { | |||||
| experiment.setStatusList(subStatus); | |||||
| updateExperiments.add(experiment); | |||||
| if (experiment == null) { | |||||
| iterator1.remove(); | |||||
| } else { | |||||
| // 如果实验状态列表发生变化,则更新实验对象,并加入到需要更新的列表中 | |||||
| if (!StringUtils.equals(subStatus, experiment.getStatusList())) { | |||||
| experiment.setStatusList(subStatus); | |||||
| updateExperiments.add(experiment); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -13,6 +13,7 @@ import org.springframework.stereotype.Component; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.HashSet; | |||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -29,9 +30,9 @@ public class MLStatusTask { | |||||
| @Resource | @Resource | ||||
| private ResourceOccupyService resourceOccupyService; | private ResourceOccupyService resourceOccupyService; | ||||
| private List<Long> machineLearnIds = new ArrayList<>(); | |||||
| private HashSet<Long> machineLearnIds = new HashSet<>(); | |||||
| @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 | |||||
| @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 | |||||
| public void executeMachineLearnInsStatus() { | public void executeMachineLearnInsStatus() { | ||||
| // 首先查到所有非终止态的实验实例 | // 首先查到所有非终止态的实验实例 | ||||
| List<MachineLearnIns> insList = machineLearnInsService.queryNotTerminated(); | List<MachineLearnIns> insList = machineLearnInsService.queryNotTerminated(); | ||||
| @@ -53,7 +54,8 @@ public class MLStatusTask { | |||||
| // 扣除积分 | // 扣除积分 | ||||
| if (Constant.Running.equals(ins.getStatus())) { | if (Constant.Running.equals(ins.getStatus())) { | ||||
| resourceOccupyService.deducing(Constant.TaskType_ML, null, ins.getId(), null, null); | resourceOccupyService.deducing(Constant.TaskType_ML, null, ins.getId(), null, null); | ||||
| } else if (Constant.Failed.equals(ins.getStatus()) || Constant.Terminated.equals(ins.getStatus()) | |||||
| } | |||||
| else if (Constant.Failed.equals(ins.getStatus()) || Constant.Terminated.equals(ins.getStatus()) | |||||
| || Constant.Succeeded.equals(ins.getStatus())) { | || Constant.Succeeded.equals(ins.getStatus())) { | ||||
| resourceOccupyService.endDeduce(Constant.TaskType_ML, null, ins.getId(), null, null); | resourceOccupyService.endDeduce(Constant.TaskType_ML, null, ins.getId(), null, null); | ||||
| } | } | ||||
| @@ -80,14 +82,17 @@ public class MLStatusTask { | |||||
| } | } | ||||
| } | } | ||||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||||
| @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 | |||||
| public void executeMachineLearn() { | public void executeMachineLearn() { | ||||
| if (machineLearnIds.size() == 0) { | |||||
| if (machineLearnIds.isEmpty()) { | |||||
| return; | return; | ||||
| } | } | ||||
| // 存储需要更新的实验对象列表 | // 存储需要更新的实验对象列表 | ||||
| List<MachineLearn> updateMLs = new ArrayList<>(); | List<MachineLearn> updateMLs = new ArrayList<>(); | ||||
| for (Long machineLearnId : machineLearnIds) { | |||||
| Iterator<Long> iterator1 = machineLearnIds.iterator(); | |||||
| while (iterator1.hasNext()) { | |||||
| Long machineLearnId = iterator1.next(); | |||||
| // 获取当前实验的所有实例列表 | // 获取当前实验的所有实例列表 | ||||
| List<MachineLearnIns> insList = machineLearnInsDao.getByMachineLearnId(machineLearnId); | List<MachineLearnIns> insList = machineLearnInsDao.getByMachineLearnId(machineLearnId); | ||||
| List<String> statusList = new ArrayList<>(); | List<String> statusList = new ArrayList<>(); | ||||
| @@ -97,10 +102,14 @@ public class MLStatusTask { | |||||
| } | } | ||||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | ||||
| MachineLearn machineLearn = machineLearnDao.getMachineLearnById(machineLearnId); | MachineLearn machineLearn = machineLearnDao.getMachineLearnById(machineLearnId); | ||||
| if (!StringUtils.equals(machineLearn.getStatusList(), subStatus)) { | |||||
| machineLearn.setStatusList(subStatus); | |||||
| updateMLs.add(machineLearn); | |||||
| machineLearnDao.edit(machineLearn); | |||||
| if (machineLearn == null) { | |||||
| iterator1.remove(); | |||||
| } else { | |||||
| if (!StringUtils.equals(machineLearn.getStatusList(), subStatus)) { | |||||
| machineLearn.setStatusList(subStatus); | |||||
| updateMLs.add(machineLearn); | |||||
| machineLearnDao.edit(machineLearn); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -14,6 +14,7 @@ import org.springframework.stereotype.Component; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.HashSet; | |||||
| import java.util.Iterator; | import java.util.Iterator; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -31,9 +32,9 @@ public class RayInsStatusTask { | |||||
| @Resource | @Resource | ||||
| private ResourceOccupyService resourceOccupyService; | private ResourceOccupyService resourceOccupyService; | ||||
| private List<Long> rayIds = new ArrayList<>(); | |||||
| private HashSet<Long> rayIds = new HashSet<>(); | |||||
| @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 | |||||
| @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 | |||||
| public void executeRayInsStatus() { | public void executeRayInsStatus() { | ||||
| List<RayIns> rayInsList = rayInsService.queryByRayInsIsNotTerminated(); | List<RayIns> rayInsList = rayInsService.queryByRayInsIsNotTerminated(); | ||||
| @@ -52,12 +53,14 @@ public class RayInsStatusTask { | |||||
| // 扣除积分 | // 扣除积分 | ||||
| if (Constant.Running.equals(rayIns.getStatus())) { | if (Constant.Running.equals(rayIns.getStatus())) { | ||||
| resourceOccupyService.deducing(Constant.TaskType_Ray, null, rayIns.getId(), null, null); | resourceOccupyService.deducing(Constant.TaskType_Ray, null, rayIns.getId(), null, null); | ||||
| } else if (Constant.Failed.equals(rayIns.getStatus()) || Constant.Terminated.equals(rayIns.getStatus()) | |||||
| } | |||||
| else if (Constant.Failed.equals(rayIns.getStatus()) || Constant.Terminated.equals(rayIns.getStatus()) | |||||
| || Constant.Succeeded.equals(rayIns.getStatus())) { | || Constant.Succeeded.equals(rayIns.getStatus())) { | ||||
| resourceOccupyService.endDeduce(Constant.TaskType_Ray, null, rayIns.getId(), null, null); | resourceOccupyService.endDeduce(Constant.TaskType_Ray, null, rayIns.getId(), null, null); | ||||
| } | } | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| System.out.println(e.getMessage()); | |||||
| rayIns.setStatus(Constant.Failed); | rayIns.setStatus(Constant.Failed); | ||||
| // 结束扣除积分 | // 结束扣除积分 | ||||
| resourceOccupyService.endDeduce(Constant.TaskType_Ray, null, rayIns.getId(), null, null); | resourceOccupyService.endDeduce(Constant.TaskType_Ray, null, rayIns.getId(), null, null); | ||||
| @@ -76,14 +79,17 @@ public class RayInsStatusTask { | |||||
| } | } | ||||
| } | } | ||||
| @Scheduled(cron = "0/30 * * * * ?") // / 每30S执行一次 | |||||
| @Scheduled(cron = "0/10 * * * * ?") // / 每30S执行一次 | |||||
| public void executeRayStatus() { | public void executeRayStatus() { | ||||
| if (rayIds.size() == 0) { | |||||
| if (rayIds.isEmpty()) { | |||||
| return; | return; | ||||
| } | } | ||||
| // 存储需要更新的实验对象列表 | // 存储需要更新的实验对象列表 | ||||
| List<Ray> updateRays = new ArrayList<>(); | List<Ray> updateRays = new ArrayList<>(); | ||||
| for (Long rayId : rayIds) { | |||||
| Iterator<Long> iterator1 = rayIds.iterator(); | |||||
| while (iterator1.hasNext()) { | |||||
| Long rayId = iterator1.next(); | |||||
| // 获取当前实验的所有实例列表 | // 获取当前实验的所有实例列表 | ||||
| List<RayIns> insList = rayInsDao.getByRayId(rayId); | List<RayIns> insList = rayInsDao.getByRayId(rayId); | ||||
| List<String> statusList = new ArrayList<>(); | List<String> statusList = new ArrayList<>(); | ||||
| @@ -93,10 +99,14 @@ public class RayInsStatusTask { | |||||
| } | } | ||||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | ||||
| Ray ray = rayDao.getRayById(rayId); | Ray ray = rayDao.getRayById(rayId); | ||||
| if (!StringUtils.equals(ray.getStatusList(), subStatus)) { | |||||
| ray.setStatusList(subStatus); | |||||
| updateRays.add(ray); | |||||
| rayDao.edit(ray); | |||||
| if (ray == null) { | |||||
| iterator1.remove(); | |||||
| } else { | |||||
| if (!StringUtils.equals(ray.getStatusList(), subStatus)) { | |||||
| ray.setStatusList(subStatus); | |||||
| updateRays.add(ray); | |||||
| rayDao.edit(ray); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -13,6 +13,8 @@ public interface ActiveLearnInsService { | |||||
| ActiveLearnIns insert(ActiveLearnIns activeLearnIns); | ActiveLearnIns insert(ActiveLearnIns activeLearnIns); | ||||
| ActiveLearnIns update(ActiveLearnIns activeLearnIns); | |||||
| String deleteById(Long id); | String deleteById(Long id); | ||||
| String batchDelete(List<Long> ids); | String batchDelete(List<Long> ids); | ||||
| @@ -16,7 +16,7 @@ public interface ActiveLearnService { | |||||
| ActiveLearnVo getActiveLearnDetail(Long id) throws IOException; | ActiveLearnVo getActiveLearnDetail(Long id) throws IOException; | ||||
| String delete(Long id); | |||||
| String delete(Long id) throws Exception; | |||||
| String runActiveLearnIns (Long id) throws Exception; | String runActiveLearnIns (Long id) throws Exception; | ||||
| } | } | ||||
| @@ -64,7 +64,7 @@ public interface AssetIconService { | |||||
| */ | */ | ||||
| boolean deleteById(Integer id); | boolean deleteById(Integer id); | ||||
| String removeById(Integer id); | |||||
| String removeById(Integer id) throws Exception; | |||||
| List<AssetIcon> queryByName(String name); | List<AssetIcon> queryByName(String name); | ||||
| @@ -1,29 +0,0 @@ | |||||
| package com.ruoyi.platform.service; | |||||
| import com.ruoyi.platform.domain.AutoMlIns; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import java.io.IOException; | |||||
| import java.util.List; | |||||
| public interface AutoMlInsService { | |||||
| Page<AutoMlIns> queryByPage(AutoMlIns autoMlIns, PageRequest pageRequest) throws IOException; | |||||
| AutoMlIns insert(AutoMlIns autoMlIns); | |||||
| String removeById(Long id); | |||||
| String batchDelete(List<Long> ids); | |||||
| List<AutoMlIns> queryByAutoMlInsIsNotTerminated(); | |||||
| AutoMlIns queryStatusFromArgo(AutoMlIns autoMlIns); | |||||
| boolean terminateAutoMlIns(Long id) throws Exception; | |||||
| AutoMlIns getDetailById(Long id); | |||||
| void updateAutoMlStatus(Long autoMlId); | |||||
| } | |||||
| @@ -1,26 +0,0 @@ | |||||
| package com.ruoyi.platform.service; | |||||
| import com.ruoyi.platform.domain.AutoMl; | |||||
| import com.ruoyi.platform.vo.AutoMlVo; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import java.io.IOException; | |||||
| import java.util.Map; | |||||
| public interface AutoMlService { | |||||
| Page<AutoMl> queryByPage(String mlName, PageRequest pageRequest); | |||||
| AutoMl save(AutoMlVo autoMlVo) throws Exception; | |||||
| String edit(AutoMlVo autoMlVo) throws Exception; | |||||
| String delete(Long id); | |||||
| AutoMlVo getAutoMlDetail(Long id) throws IOException; | |||||
| Map<String, String> upload(MultipartFile file, String uuid) throws Exception; | |||||
| String runAutoMlIns(Long id) throws Exception; | |||||
| } | |||||
| @@ -8,7 +8,7 @@ public interface CodeConfigService { | |||||
| Page<CodeConfig> queryByPage(CodeConfig codeConfig, PageRequest pageRequest); | Page<CodeConfig> queryByPage(CodeConfig codeConfig, PageRequest pageRequest); | ||||
| CodeConfig queryById(Long id); | |||||
| CodeConfig queryById(Long id) throws Exception; | |||||
| CodeConfig insert(CodeConfig codeConfig); | CodeConfig insert(CodeConfig codeConfig); | ||||
| @@ -57,7 +57,7 @@ public interface ComponentService { | |||||
| */ | */ | ||||
| boolean deleteById(Integer id); | boolean deleteById(Integer id); | ||||
| String removeById(Integer id); | |||||
| String removeById(Integer id) throws Exception; | |||||
| List<Map> queryAllGroupedByCategory() throws Exception; | List<Map> queryAllGroupedByCategory() throws Exception; | ||||
| @@ -54,6 +54,6 @@ public interface ComputingResourceService { | |||||
| */ | */ | ||||
| boolean deleteById(Integer id); | boolean deleteById(Integer id); | ||||
| String removeById(Integer id); | |||||
| String removeById(Integer id) throws Exception; | |||||
| } | } | ||||
| @@ -58,7 +58,7 @@ public interface DatasetVersionService { | |||||
| */ | */ | ||||
| boolean deleteById(Integer id); | boolean deleteById(Integer id); | ||||
| String removeById(Integer id); | |||||
| String removeById(Integer id) throws Exception; | |||||
| List<DatasetVersion> queryByDatasetId(Integer datasetId); | List<DatasetVersion> queryByDatasetId(Integer datasetId); | ||||
| @@ -66,7 +66,7 @@ public interface DatasetVersionService { | |||||
| Map<String,Object> queryByDatasetIdAndVersion(Integer datasetId, String version); | Map<String,Object> queryByDatasetIdAndVersion(Integer datasetId, String version); | ||||
| Map<Integer,String> deleteDatasetVersion(Integer datasetId, String version); | |||||
| Map<Integer,String> deleteDatasetVersion(Integer datasetId, String version) throws Exception; | |||||
| void checkDeclaredVersion(DatasetVersion insert) throws Exception; | void checkDeclaredVersion(DatasetVersion insert) throws Exception; | ||||
| @@ -38,4 +38,8 @@ public interface GitService { | |||||
| void resetPhoneNum(SysUser sysUser) throws Exception; | void resetPhoneNum(SysUser sysUser) throws Exception; | ||||
| void deleteUser(SysUser sysUser) throws Exception; | void deleteUser(SysUser sysUser) throws Exception; | ||||
| List<Map<String, Object>> PersonalQueryGitByPage(String token, String login, String name, Integer page) throws Exception; | |||||
| List<Map<String, Object>> PubilcQueryGitByPage(String token, String name, Integer page, Integer projectCategoryId) throws Exception; | |||||
| } | } | ||||
| @@ -12,6 +12,8 @@ public interface MachineLearnInsService { | |||||
| MachineLearnIns insert(MachineLearnIns machineLearnIns); | MachineLearnIns insert(MachineLearnIns machineLearnIns); | ||||
| MachineLearnIns update(MachineLearnIns machineLearnIns); | |||||
| String removeById(Long id); | String removeById(Long id); | ||||
| String batchDelete(List<Long> ids); | String batchDelete(List<Long> ids); | ||||
| @@ -57,7 +57,7 @@ public interface ModelDependencyService { | |||||
| */ | */ | ||||
| boolean deleteById(Integer id); | boolean deleteById(Integer id); | ||||
| String removeById(Integer id); | |||||
| String removeById(Integer id) throws Exception; | |||||
| List<ModelDependency> queryByModelDependency(ModelDependency modelDependency) throws IOException; | List<ModelDependency> queryByModelDependency(ModelDependency modelDependency) throws IOException; | ||||
| @@ -89,7 +89,7 @@ public interface ModelsService { | |||||
| List<Map<String, String>> exportModels(String path, String uuid) throws Exception; | List<Map<String, String>> exportModels(String path, String uuid) throws Exception; | ||||
| String newCreateModel(ModelsVo modelsVo) throws Exception; | |||||
| String newCreateModel(ModelsVo modelsVo); | |||||
| String newCreateVersion(ModelsVo modelsVo) throws Exception; | String newCreateVersion(ModelsVo modelsVo) throws Exception; | ||||
| @@ -69,7 +69,7 @@ public interface ModelsVersionService { | |||||
| Map<String,Object> queryByModelsIdAndVersion(Integer modelsId, String version); | Map<String,Object> queryByModelsIdAndVersion(Integer modelsId, String version); | ||||
| Map<Integer, String> deleteModelsVersion(Integer modelsId, String version) throws IOException; | |||||
| Map<Integer, String> deleteModelsVersion(Integer modelsId, String version) throws Exception; | |||||
| String addModelVersions(List<ModelsVersion> modelsVersions) throws Exception; | String addModelVersions(List<ModelsVersion> modelsVersions) throws Exception; | ||||
| @@ -10,6 +10,8 @@ public interface RayInsService { | |||||
| RayIns insert(RayIns rayIns); | RayIns insert(RayIns rayIns); | ||||
| RayIns update(RayIns rayIns); | |||||
| String deleteById(Long id); | String deleteById(Long id); | ||||
| String batchDelete(List<Long> ids); | String batchDelete(List<Long> ids); | ||||
| @@ -16,7 +16,7 @@ public interface RayService { | |||||
| RayVo getRayDetail(Long id) throws IOException; | RayVo getRayDetail(Long id) throws IOException; | ||||
| String delete(Long id); | |||||
| String delete(Long id) throws Exception; | |||||
| String runRayIns(Long id) throws Exception; | String runRayIns(Long id) throws Exception; | ||||
| } | } | ||||
| @@ -21,7 +21,7 @@ public interface ResourceOccupyService { | |||||
| Map<String, Double> queryCredit(); | Map<String, Double> queryCredit(); | ||||
| void update(String taskType, Long taskId, Long taskInsId, Integer computingResourceId, Integer replicas); | |||||
| void update(String taskType, Long taskId, Long taskInsId, Integer computingResourceId, Integer replicas, String taskName); | |||||
| void deleteTaskState(String taskType, Long taskId, Long taskInsId); | void deleteTaskState(String taskType, Long taskId, Long taskInsId); | ||||
| } | } | ||||
| @@ -45,7 +45,7 @@ public interface WorkflowParamService { | |||||
| */ | */ | ||||
| WorkflowParam update(WorkflowParam workflowParam); | WorkflowParam update(WorkflowParam workflowParam); | ||||
| String removeById(Integer id); | |||||
| String removeById(Integer id) throws Exception; | |||||
| /** | /** | ||||
| * 通过主键删除数据 | * 通过主键删除数据 | ||||
| @@ -62,6 +62,18 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { | |||||
| return activeLearnIns; | return activeLearnIns; | ||||
| } | } | ||||
| @Override | |||||
| public ActiveLearnIns update(ActiveLearnIns activeLearnIns) { | |||||
| activeLearnIns.setUpdateTime(new Date()); | |||||
| activeLearnIns = queryStatusFromArgo(activeLearnIns); | |||||
| activeLearnInsDao.update(activeLearnIns); | |||||
| updateActiveLearnStatus(activeLearnIns.getActiveLearnId()); | |||||
| if (Constant.Failed.equals(activeLearnIns.getStatus()) || Constant.Succeeded.equals(activeLearnIns.getStatus())) { | |||||
| resourceOccupyService.endDeduce(Constant.TaskType_ActiveLearn, null, activeLearnIns.getId(), null, null); | |||||
| } | |||||
| return activeLearnIns; | |||||
| } | |||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| public String deleteById(Long id) { | public String deleteById(Long id) { | ||||
| @@ -154,6 +166,7 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { | |||||
| // 如果值不等于 Succeeded,则赋值为 Failed | // 如果值不等于 Succeeded,则赋值为 Failed | ||||
| if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { | if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { | ||||
| innerMap.put("phase", Constant.Failed); | innerMap.put("phase", Constant.Failed); | ||||
| innerMap.put("finishedAt", new Date()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -290,9 +303,24 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { | |||||
| return aimUrl + "/metrics?select=" + decode; | return aimUrl + "/metrics?select=" + decode; | ||||
| } | } | ||||
| public void getTrialList(ActiveLearnIns ins) { | |||||
| public void getTrialList(ActiveLearnIns ins) throws IOException { | |||||
| String directoryPath = ins.getResultPath(); | String directoryPath = ins.getResultPath(); | ||||
| ins.setResultPath(endpoint + "/" + directoryPath + "/final_checkpoint/final_model_weights.pth"); | |||||
| Map<String, Object> paramMap = JsonUtils.jsonToMap(ins.getParam()); | |||||
| Map<String, Object> dataMap = (Map<String, Object>) paramMap.get("data"); | |||||
| switch ((String) dataMap.get("framework_type")) { | |||||
| case Constant.AL_PYTORCH: { | |||||
| ins.setResultPath(endpoint + "/" + directoryPath + "/best_checkpoint/best_model_weights.pth"); | |||||
| break; | |||||
| } | |||||
| case Constant.AL_SKLEARN: { | |||||
| ins.setResultPath(endpoint + "/" + directoryPath + "/best_checkpoint/best_model.joblib"); | |||||
| break; | |||||
| } | |||||
| case Constant.AL_KERAS: { | |||||
| ins.setResultPath(endpoint + "/" + directoryPath + "/best_checkpoint/best_model.h5"); | |||||
| break; | |||||
| } | |||||
| } | |||||
| try { | try { | ||||
| String bucketName = directoryPath.substring(0, directoryPath.indexOf("/")); | String bucketName = directoryPath.substring(0, directoryPath.indexOf("/")); | ||||
| @@ -57,7 +57,7 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { | |||||
| @Override | @Override | ||||
| public ActiveLearn save(ActiveLearnVo activeLearnVo) throws Exception { | public ActiveLearn save(ActiveLearnVo activeLearnVo) throws Exception { | ||||
| if (activeLearnVo.getName().length() >= 64) { | |||||
| if (activeLearnVo.getName().length() > 64) { | |||||
| throw new RuntimeException("实验名称大于最大长度"); | throw new RuntimeException("实验名称大于最大长度"); | ||||
| } | } | ||||
| ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName()); | ActiveLearn activeLearnByName = activeLearnDao.getActiveLearnByName(activeLearnVo.getName()); | ||||
| @@ -117,15 +117,20 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { | |||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| public String delete(Long id) { | |||||
| public String delete(Long id) throws Exception { | |||||
| ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); | ActiveLearn activeLearn = activeLearnDao.getActiveLearnById(id); | ||||
| if (activeLearn == null) { | if (activeLearn == null) { | ||||
| throw new RuntimeException("实验不存在"); | |||||
| throw new Exception("实验不存在"); | |||||
| } | } | ||||
| String username = SecurityUtils.getLoginUser().getUsername(); | String username = SecurityUtils.getLoginUser().getUsername(); | ||||
| String createBy = activeLearn.getCreateBy(); | String createBy = activeLearn.getCreateBy(); | ||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | ||||
| throw new RuntimeException("无权限删除该实验"); | |||||
| throw new Exception("无权限删除该实验"); | |||||
| } | |||||
| List<ActiveLearnIns> insList = activeLearnInsDao.getByActiveLearnId(id); | |||||
| if (!insList.isEmpty()) { | |||||
| throw new Exception("该实验存在实例,无法删除"); | |||||
| } | } | ||||
| activeLearn.setState(Constant.State_invalid); | activeLearn.setState(Constant.State_invalid); | ||||
| resourceOccupyService.deleteTaskState(Constant.TaskType_ActiveLearn, id, null); | resourceOccupyService.deleteTaskState(Constant.TaskType_ActiveLearn, id, null); | ||||
| @@ -157,6 +162,10 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { | |||||
| throw new RuntimeException("转换流水线失败"); | throw new RuntimeException("转换流水线失败"); | ||||
| } | } | ||||
| Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | ||||
| if (converMap.get("data") == null) { | |||||
| throw new RuntimeException("转换流水线失败"); | |||||
| } | |||||
| // 组装运行接口json | // 组装运行接口json | ||||
| Map<String, Object> output = (Map<String, Object>) converMap.get("output"); | Map<String, Object> output = (Map<String, Object>) converMap.get("output"); | ||||
| Map<String, Object> runReqMap = new HashMap<>(); | Map<String, Object> runReqMap = new HashMap<>(); | ||||
| @@ -195,7 +204,7 @@ public class ActiveLearnServiceImpl implements ActiveLearnService { | |||||
| // 记录开始扣除积分 | // 记录开始扣除积分 | ||||
| resourceOccupyService.startDeduce(activeLearn.getComputingResourceId(), 1, Constant.TaskType_ActiveLearn, id, activeLearnIns.getId(), null, activeLearn.getName(), null, null); | resourceOccupyService.startDeduce(activeLearn.getComputingResourceId(), 1, Constant.TaskType_ActiveLearn, id, activeLearnIns.getId(), null, activeLearn.getName(), null, null); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException(e); | |||||
| throw new RuntimeException(e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| return "执行成功"; | return "执行成功"; | ||||
| @@ -101,10 +101,10 @@ public class AssetIconServiceImpl implements AssetIconService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public String removeById(Integer id) { | |||||
| public String removeById(Integer id) throws Exception { | |||||
| AssetIcon assetIcon = this.assetIconDao.queryById(id); | AssetIcon assetIcon = this.assetIconDao.queryById(id); | ||||
| if (assetIcon == null){ | if (assetIcon == null){ | ||||
| return "图标不存在"; | |||||
| throw new Exception("图标不存在"); | |||||
| } | } | ||||
| //判断权限,只有admin和创建者本身可以删除 | //判断权限,只有admin和创建者本身可以删除 | ||||
| @@ -114,7 +114,7 @@ public class AssetIconServiceImpl implements AssetIconService { | |||||
| String createdBy = assetIcon.getCreateBy(); | String createdBy = assetIcon.getCreateBy(); | ||||
| if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | ||||
| return "无权限删除该图标"; | |||||
| throw new Exception("无权限删除该图标"); | |||||
| } | } | ||||
| assetIcon.setState(0); | assetIcon.setState(0); | ||||
| @@ -1,257 +0,0 @@ | |||||
| package com.ruoyi.platform.service.impl; | |||||
| import com.ruoyi.system.api.constant.Constant; | |||||
| import com.ruoyi.platform.domain.AutoMl; | |||||
| import com.ruoyi.platform.domain.AutoMlIns; | |||||
| import com.ruoyi.platform.mapper.AutoMlDao; | |||||
| import com.ruoyi.platform.mapper.AutoMlInsDao; | |||||
| import com.ruoyi.platform.service.AutoMlInsService; | |||||
| import com.ruoyi.platform.utils.DateUtils; | |||||
| import com.ruoyi.platform.utils.HttpUtils; | |||||
| import com.ruoyi.platform.utils.JsonUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageImpl; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.stereotype.Service; | |||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| import javax.annotation.Resource; | |||||
| import java.io.IOException; | |||||
| import java.util.*; | |||||
| @Service | |||||
| public class AutoMlInsServiceImpl implements AutoMlInsService { | |||||
| @Value("${argo.url}") | |||||
| private String argoUrl; | |||||
| @Value("${argo.workflowStatus}") | |||||
| private String argoWorkflowStatus; | |||||
| @Value("${argo.workflowTermination}") | |||||
| private String argoWorkflowTermination; | |||||
| @Resource | |||||
| private AutoMlInsDao autoMlInsDao; | |||||
| @Resource | |||||
| private AutoMlDao autoMlDao; | |||||
| @Override | |||||
| public Page<AutoMlIns> queryByPage(AutoMlIns autoMlIns, PageRequest pageRequest) throws IOException { | |||||
| long total = this.autoMlInsDao.count(autoMlIns); | |||||
| List<AutoMlIns> autoMlInsList = this.autoMlInsDao.queryAllByLimit(autoMlIns, pageRequest); | |||||
| return new PageImpl<>(autoMlInsList, pageRequest, total); | |||||
| } | |||||
| @Override | |||||
| public AutoMlIns insert(AutoMlIns autoMlIns) { | |||||
| this.autoMlInsDao.insert(autoMlIns); | |||||
| return autoMlIns; | |||||
| } | |||||
| @Override | |||||
| public String removeById(Long id) { | |||||
| AutoMlIns autoMlIns = autoMlInsDao.queryById(id); | |||||
| if (autoMlIns == null) { | |||||
| return "实验实例不存在"; | |||||
| } | |||||
| if (StringUtils.isEmpty(autoMlIns.getStatus())) { | |||||
| autoMlIns = queryStatusFromArgo(autoMlIns); | |||||
| } | |||||
| if (StringUtils.equals(autoMlIns.getStatus(), Constant.Running)) { | |||||
| return "实验实例正在运行,不可删除"; | |||||
| } | |||||
| autoMlIns.setState(Constant.State_invalid); | |||||
| int update = autoMlInsDao.update(autoMlIns); | |||||
| if (update > 0) { | |||||
| updateAutoMlStatus(autoMlIns.getAutoMlId()); | |||||
| return "删除成功"; | |||||
| } else { | |||||
| return "删除失败"; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| @Transactional | |||||
| public String batchDelete(List<Long> ids) { | |||||
| for (Long id : ids) { | |||||
| String result = removeById(id); | |||||
| if (!"删除成功".equals(result)) { | |||||
| return result; | |||||
| } | |||||
| } | |||||
| return "删除成功"; | |||||
| } | |||||
| @Override | |||||
| public List<AutoMlIns> queryByAutoMlInsIsNotTerminated() { | |||||
| return autoMlInsDao.queryByAutoMlInsIsNotTerminated(); | |||||
| } | |||||
| @Override | |||||
| public AutoMlIns queryStatusFromArgo(AutoMlIns ins) { | |||||
| String namespace = ins.getArgoInsNs(); | |||||
| String name = ins.getArgoInsName(); | |||||
| // 创建请求数据map | |||||
| Map<String, Object> requestData = new HashMap<>(); | |||||
| requestData.put("namespace", namespace); | |||||
| requestData.put("name", name); | |||||
| // 创建发送数据map,将请求数据作为"data"键的值 | |||||
| Map<String, Object> res = new HashMap<>(); | |||||
| res.put("data", requestData); | |||||
| try { | |||||
| // 发送POST请求到Argo工作流状态查询接口,并将请求数据转换为JSON | |||||
| String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, null, JsonUtils.mapToJson(res)); | |||||
| // 检查响应是否为空或无内容 | |||||
| if (req == null || StringUtils.isEmpty(req)) { | |||||
| throw new RuntimeException("工作流状态响应为空"); | |||||
| } | |||||
| // 将响应的JSON字符串转换为Map对象 | |||||
| Map<String, Object> runResMap = JsonUtils.jsonToMap(req); | |||||
| // 从响应Map中获取"data"部分 | |||||
| Map<String, Object> data = (Map<String, Object>) runResMap.get("data"); | |||||
| if (data == null || data.isEmpty()) { | |||||
| throw new RuntimeException("工作流数据为空"); | |||||
| } | |||||
| // 从"data"中获取"status"部分,并返回"phase"的值 | |||||
| Map<String, Object> status = (Map<String, Object>) data.get("status"); | |||||
| if (status == null || status.isEmpty()) { | |||||
| throw new RuntimeException("工作流状态为空"); | |||||
| } | |||||
| //解析流水线结束时间 | |||||
| String finishedAtString = (String) status.get("finishedAt"); | |||||
| if (finishedAtString != null && !finishedAtString.isEmpty()) { | |||||
| Date finishTime = DateUtils.convertUTCtoShanghaiDate(finishedAtString); | |||||
| ins.setFinishTime(finishTime); | |||||
| } | |||||
| // 解析nodes字段,提取节点状态并转换为JSON字符串 | |||||
| Map<String, Object> nodes = (Map<String, Object>) status.get("nodes"); | |||||
| Map<String, Object> modifiedNodes = new LinkedHashMap<>(); | |||||
| if (nodes != null) { | |||||
| for (Map.Entry<String, Object> nodeEntry : nodes.entrySet()) { | |||||
| Map<String, Object> nodeDetails = (Map<String, Object>) nodeEntry.getValue(); | |||||
| String templateName = (String) nodeDetails.get("displayName"); | |||||
| modifiedNodes.put(templateName, nodeDetails); | |||||
| } | |||||
| } | |||||
| String nodeStatusJson = JsonUtils.mapToJson(modifiedNodes); | |||||
| ins.setNodeStatus(nodeStatusJson); | |||||
| //终止态为终止不改 | |||||
| if (!StringUtils.equals(ins.getStatus(), Constant.Terminated)) { | |||||
| ins.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : Constant.Pending); | |||||
| } | |||||
| if (StringUtils.equals(ins.getStatus(), Constant.Error)) { | |||||
| ins.setStatus(Constant.Failed); | |||||
| } | |||||
| return ins; | |||||
| } catch (Exception e) { | |||||
| throw new RuntimeException("查询状态失败: " + e.getMessage(), e); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean terminateAutoMlIns(Long id) throws Exception { | |||||
| AutoMlIns autoMlIns = autoMlInsDao.queryById(id); | |||||
| if (autoMlIns == null) { | |||||
| throw new IllegalStateException("实验实例未查询到,id: " + id); | |||||
| } | |||||
| String currentStatus = autoMlIns.getStatus(); | |||||
| String name = autoMlIns.getArgoInsName(); | |||||
| String namespace = autoMlIns.getArgoInsNs(); | |||||
| // 获取当前状态,如果为空,则从Argo查询 | |||||
| if (StringUtils.isEmpty(currentStatus)) { | |||||
| currentStatus = queryStatusFromArgo(autoMlIns).getStatus(); | |||||
| } | |||||
| // 只有状态是"Running"时才能终止实例 | |||||
| if (!currentStatus.equalsIgnoreCase(Constant.Running)) { | |||||
| throw new Exception("终止错误,只有运行状态的实例才能终止"); // 如果不是"Running"状态,则不执行终止操作 | |||||
| } | |||||
| // 创建请求数据map | |||||
| Map<String, Object> requestData = new HashMap<>(); | |||||
| requestData.put("namespace", namespace); | |||||
| requestData.put("name", name); | |||||
| // 创建发送数据map,将请求数据作为"data"键的值 | |||||
| Map<String, Object> res = new HashMap<>(); | |||||
| res.put("data", requestData); | |||||
| try { | |||||
| // 发送POST请求到Argo工作流状态查询接口,并将请求数据转换为JSON | |||||
| String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, null, JsonUtils.mapToJson(res)); | |||||
| // 检查响应是否为空或无内容 | |||||
| if (StringUtils.isEmpty(req)) { | |||||
| throw new RuntimeException("终止响应内容为空"); | |||||
| } | |||||
| // 将响应的JSON字符串转换为Map对象 | |||||
| Map<String, Object> runResMap = JsonUtils.jsonToMap(req); | |||||
| // 从响应Map中直接获取"errCode"的值 | |||||
| Integer errCode = (Integer) runResMap.get("errCode"); | |||||
| if (errCode != null && errCode == 0) { | |||||
| //更新autoMlIns,确保状态更新被保存到数据库 | |||||
| AutoMlIns ins = queryStatusFromArgo(autoMlIns); | |||||
| String nodeStatus = ins.getNodeStatus(); | |||||
| Map<String, Object> nodeMap = JsonUtils.jsonToMap(nodeStatus); | |||||
| // 遍历 map | |||||
| for (Map.Entry<String, Object> entry : nodeMap.entrySet()) { | |||||
| // 获取每个 Map 中的值并强制转换为 Map | |||||
| Map<String, Object> innerMap = (Map<String, Object>) entry.getValue(); | |||||
| // 检查 phase 的值 | |||||
| if (innerMap.containsKey("phase")) { | |||||
| String phaseValue = (String) innerMap.get("phase"); | |||||
| // 如果值不等于 Succeeded,则赋值为 Failed | |||||
| if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { | |||||
| innerMap.put("phase", Constant.Failed); | |||||
| } | |||||
| } | |||||
| } | |||||
| ins.setNodeStatus(JsonUtils.mapToJson(nodeMap)); | |||||
| ins.setStatus(Constant.Terminated); | |||||
| ins.setUpdateTime(new Date()); | |||||
| ins.setFinishTime(new Date()); | |||||
| this.autoMlInsDao.update(ins); | |||||
| updateAutoMlStatus(autoMlIns.getAutoMlId()); | |||||
| return true; | |||||
| } else { | |||||
| return false; | |||||
| } | |||||
| } catch (Exception e) { | |||||
| throw new RuntimeException("终止实例错误: " + e.getMessage(), e); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public AutoMlIns getDetailById(Long id) { | |||||
| AutoMlIns autoMlIns = this.autoMlInsDao.queryById(id); | |||||
| if(Constant.Running.equals(autoMlIns.getStatus()) || Constant.Pending.equals(autoMlIns.getStatus())){ | |||||
| autoMlIns = queryStatusFromArgo(autoMlIns); | |||||
| } | |||||
| return autoMlIns; | |||||
| } | |||||
| public void updateAutoMlStatus(Long autoMlId) { | |||||
| List<AutoMlIns> insList = autoMlInsDao.getByAutoMlId(autoMlId); | |||||
| List<String> statusList = new ArrayList<>(); | |||||
| // 更新实验状态列表 | |||||
| for (int i = 0; i < insList.size(); i++) { | |||||
| statusList.add(insList.get(i).getStatus()); | |||||
| } | |||||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | |||||
| AutoMl autoMl = autoMlDao.getAutoMlById(autoMlId); | |||||
| if (!StringUtils.equals(autoMl.getStatusList(), subStatus)) { | |||||
| autoMl.setStatusList(subStatus); | |||||
| autoMlDao.edit(autoMl); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1,219 +0,0 @@ | |||||
| package com.ruoyi.platform.service.impl; | |||||
| import com.ruoyi.common.security.utils.SecurityUtils; | |||||
| import com.ruoyi.system.api.constant.Constant; | |||||
| import com.ruoyi.platform.domain.AutoMl; | |||||
| import com.ruoyi.platform.domain.AutoMlIns; | |||||
| import com.ruoyi.platform.mapper.AutoMlDao; | |||||
| import com.ruoyi.platform.mapper.AutoMlInsDao; | |||||
| import com.ruoyi.platform.service.AutoMlInsService; | |||||
| import com.ruoyi.platform.service.AutoMlService; | |||||
| import com.ruoyi.platform.utils.FileUtil; | |||||
| import com.ruoyi.platform.utils.HttpUtils; | |||||
| import com.ruoyi.platform.utils.JacksonUtil; | |||||
| import com.ruoyi.platform.utils.JsonUtils; | |||||
| import com.ruoyi.platform.vo.AutoMlParamVo; | |||||
| import com.ruoyi.platform.vo.AutoMlVo; | |||||
| import org.apache.commons.collections4.MapUtils; | |||||
| import org.apache.commons.io.FileUtils; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.springframework.beans.BeanUtils; | |||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageImpl; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.stereotype.Service; | |||||
| import org.springframework.web.multipart.MultipartFile; | |||||
| import javax.annotation.Resource; | |||||
| import java.io.File; | |||||
| import java.io.IOException; | |||||
| import java.util.ArrayList; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| @Service("autoMLService") | |||||
| public class AutoMlServiceImpl implements AutoMlService { | |||||
| @Value("${git.localPath}") | |||||
| String localPath; | |||||
| @Value("${argo.url}") | |||||
| private String argoUrl; | |||||
| @Value("${argo.convertAutoML}") | |||||
| String convertAutoML; | |||||
| @Value("${argo.workflowRun}") | |||||
| private String argoWorkflowRun; | |||||
| @Value("${minio.endpointIp}") | |||||
| private String minioEndpoint; | |||||
| @Resource | |||||
| private AutoMlDao autoMlDao; | |||||
| @Resource | |||||
| private AutoMlInsDao autoMlInsDao; | |||||
| @Resource | |||||
| private AutoMlInsService autoMlInsService; | |||||
| @Override | |||||
| public Page<AutoMl> queryByPage(String mlName, PageRequest pageRequest) { | |||||
| long total = autoMlDao.count(mlName); | |||||
| List<AutoMl> autoMls = autoMlDao.queryByPage(mlName, pageRequest); | |||||
| return new PageImpl<>(autoMls, pageRequest, total); | |||||
| } | |||||
| @Override | |||||
| public AutoMl save(AutoMlVo autoMlVo) throws Exception { | |||||
| if (autoMlVo.getMlName().length() >= 64) { | |||||
| throw new RuntimeException("实验名称大于最大长度"); | |||||
| } | |||||
| AutoMl autoMlByName = autoMlDao.getAutoMlByName(autoMlVo.getMlName()); | |||||
| if (autoMlByName != null) { | |||||
| throw new RuntimeException("实验名称已存在"); | |||||
| } | |||||
| AutoMl autoMl = new AutoMl(); | |||||
| BeanUtils.copyProperties(autoMlVo, autoMl); | |||||
| String username = SecurityUtils.getLoginUser().getUsername(); | |||||
| autoMl.setCreateBy(username); | |||||
| autoMl.setUpdateBy(username); | |||||
| String datasetJson = JacksonUtil.toJSONString(autoMlVo.getDataset()); | |||||
| autoMl.setDataset(datasetJson); | |||||
| autoMlDao.save(autoMl); | |||||
| return autoMl; | |||||
| } | |||||
| @Override | |||||
| public String edit(AutoMlVo autoMlVo) throws Exception { | |||||
| AutoMl oldAutoMl = autoMlDao.getAutoMlByName(autoMlVo.getMlName()); | |||||
| if (oldAutoMl != null && !oldAutoMl.getId().equals(autoMlVo.getId())) { | |||||
| throw new RuntimeException("实验名称已存在"); | |||||
| } | |||||
| AutoMl autoMl = new AutoMl(); | |||||
| BeanUtils.copyProperties(autoMlVo, autoMl); | |||||
| String username = SecurityUtils.getLoginUser().getUsername(); | |||||
| autoMl.setUpdateBy(username); | |||||
| String datasetJson = JacksonUtil.toJSONString(autoMlVo.getDataset()); | |||||
| autoMl.setDataset(datasetJson); | |||||
| autoMlDao.edit(autoMl); | |||||
| return "修改成功"; | |||||
| } | |||||
| @Override | |||||
| public String delete(Long id) { | |||||
| AutoMl autoMl = autoMlDao.getAutoMlById(id); | |||||
| if (autoMl == null) { | |||||
| throw new RuntimeException("实验不存在"); | |||||
| } | |||||
| String username = SecurityUtils.getLoginUser().getUsername(); | |||||
| String createBy = autoMl.getCreateBy(); | |||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | |||||
| throw new RuntimeException("无权限删除该实验"); | |||||
| } | |||||
| autoMl.setState(Constant.State_invalid); | |||||
| return autoMlDao.edit(autoMl) > 0 ? "删除成功" : "删除失败"; | |||||
| } | |||||
| @Override | |||||
| public AutoMlVo getAutoMlDetail(Long id) throws IOException { | |||||
| AutoMl autoMl = autoMlDao.getAutoMlById(id); | |||||
| AutoMlVo autoMlVo = new AutoMlVo(); | |||||
| BeanUtils.copyProperties(autoMl, autoMlVo); | |||||
| if (StringUtils.isNotEmpty(autoMl.getDataset())) { | |||||
| autoMlVo.setDataset(JsonUtils.jsonToMap(autoMl.getDataset())); | |||||
| } | |||||
| return autoMlVo; | |||||
| } | |||||
| @Override | |||||
| public Map<String, String> upload(MultipartFile file, String uuid) throws Exception { | |||||
| Map<String, String> result = new HashMap<>(); | |||||
| String username = SecurityUtils.getLoginUser().getUsername(); | |||||
| String fileName = file.getOriginalFilename(); | |||||
| String path = localPath + "temp/" + username + "/automl_data/" + uuid; | |||||
| long sizeInBytes = file.getSize(); | |||||
| String formattedSize = FileUtil.formatFileSize(sizeInBytes); | |||||
| File targetFile = new File(path, file.getOriginalFilename()); | |||||
| // 确保目录存在 | |||||
| targetFile.getParentFile().mkdirs(); | |||||
| // 保存文件到目标路径 | |||||
| FileUtils.copyInputStreamToFile(file.getInputStream(), targetFile); | |||||
| // 返回上传文件的路径 | |||||
| result.put("fileName", fileName); | |||||
| result.put("url", path); // objectName根据实际情况定义 | |||||
| result.put("fileSize", formattedSize); | |||||
| return result; | |||||
| } | |||||
| @Override | |||||
| public String runAutoMlIns(Long id) throws Exception { | |||||
| AutoMl autoMl = autoMlDao.getAutoMlById(id); | |||||
| if (autoMl == null) { | |||||
| throw new Exception("自动机器学习配置不存在"); | |||||
| } | |||||
| AutoMlParamVo autoMlParam = new AutoMlParamVo(); | |||||
| BeanUtils.copyProperties(autoMl, autoMlParam); | |||||
| autoMlParam.setDataset(JsonUtils.jsonToMap(autoMl.getDataset())); | |||||
| String param = JsonUtils.objectToJson(autoMlParam); | |||||
| // 调argo转换接口 | |||||
| try { | |||||
| String convertRes = HttpUtils.sendPost(argoUrl + convertAutoML, param); | |||||
| if (convertRes == null || StringUtils.isEmpty(convertRes)) { | |||||
| throw new RuntimeException("转换流水线失败"); | |||||
| } | |||||
| Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | |||||
| // 组装运行接口json | |||||
| Map<String, Object> output = (Map<String, Object>) converMap.get("output"); | |||||
| Map<String, Object> runReqMap = new HashMap<>(); | |||||
| runReqMap.put("data", converMap.get("data")); | |||||
| // 调argo运行接口 | |||||
| String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap)); | |||||
| if (runRes == null || StringUtils.isEmpty(runRes)) { | |||||
| throw new RuntimeException("运行流水线失败"); | |||||
| } | |||||
| Map<String, Object> runResMap = JsonUtils.jsonToMap(runRes); | |||||
| Map<String, Object> data = (Map<String, Object>) runResMap.get("data"); | |||||
| //判断data为空 | |||||
| if (data == null || MapUtils.isEmpty(data)) { | |||||
| throw new RuntimeException("运行流水线失败"); | |||||
| } | |||||
| Map<String, Object> metadata = (Map<String, Object>) data.get("metadata"); | |||||
| // 插入记录到实验实例表 | |||||
| AutoMlIns autoMlIns = new AutoMlIns(); | |||||
| autoMlIns.setAutoMlId(autoMl.getId()); | |||||
| autoMlIns.setArgoInsNs((String) metadata.get("namespace")); | |||||
| autoMlIns.setArgoInsName((String) metadata.get("name")); | |||||
| autoMlIns.setParam(param); | |||||
| autoMlIns.setStatus(Constant.Pending); | |||||
| //替换argoInsName | |||||
| String outputString = JsonUtils.mapToJson(output); | |||||
| autoMlIns.setNodeResult(outputString.replace("{{workflow.name}}", (String) metadata.get("name"))); | |||||
| Map<String, Object> param_output = (Map<String, Object>) output.get("param_output"); | |||||
| List output1 = (ArrayList) param_output.values().toArray()[0]; | |||||
| Map<String, String> output2 = (Map<String, String>) output1.get(0); | |||||
| String outputPath = minioEndpoint + "/" + output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")) + "/"; | |||||
| autoMlIns.setModelPath(outputPath + "save_model.joblib"); | |||||
| if (Constant.AutoMl_Classification.equals(autoMl.getTaskType())) { | |||||
| autoMlIns.setImgPath(outputPath + "Auto-sklearn_metric_over_time.png" + "," + outputPath + "Train_Confusion_Matrix.png" + "," + outputPath + "Test_Confusion_Matrix.png"); | |||||
| } else { | |||||
| autoMlIns.setImgPath(outputPath + "Auto-sklearn_metric_over_time.png" + "," + outputPath + "regression.png"); | |||||
| } | |||||
| autoMlIns.setResultPath(outputPath + "result.txt"); | |||||
| String seed = autoMl.getSeed() != null ? String.valueOf(autoMl.getSeed()) : "1"; | |||||
| autoMlIns.setRunHistoryPath(outputPath + "smac3-output/run_" + seed + "/runhistory.json"); | |||||
| autoMlInsDao.insert(autoMlIns); | |||||
| autoMlInsService.updateAutoMlStatus(id); | |||||
| } catch (Exception e) { | |||||
| throw new RuntimeException(e); | |||||
| } | |||||
| return "执行成功"; | |||||
| } | |||||
| } | |||||
| @@ -10,6 +10,7 @@ import com.ruoyi.platform.domain.CodeConfig; | |||||
| import com.ruoyi.platform.service.CodeConfigService; | import com.ruoyi.platform.service.CodeConfigService; | ||||
| import com.ruoyi.system.api.model.LoginUser; | import com.ruoyi.system.api.model.LoginUser; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| import org.springframework.data.domain.Page; | import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.PageImpl; | import org.springframework.data.domain.PageImpl; | ||||
| import org.springframework.data.domain.PageRequest; | import org.springframework.data.domain.PageRequest; | ||||
| @@ -45,14 +46,19 @@ public class CodeConfigServiceImpl implements CodeConfigService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public CodeConfig queryById(Long id) { | |||||
| return this.codeConfigDao.queryById(id); | |||||
| public CodeConfig queryById(Long id) throws Exception { | |||||
| CodeConfig codeConfig = this.codeConfigDao.queryById(id); | |||||
| if (codeConfig == null) { | |||||
| throw new Exception("未查询到代码配置"); | |||||
| } else { | |||||
| return this.codeConfigDao.queryById(id); | |||||
| } | |||||
| } | } | ||||
| @Override | @Override | ||||
| public CodeConfig insert(CodeConfig codeConfig) { | public CodeConfig insert(CodeConfig codeConfig) { | ||||
| Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName()); | Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName()); | ||||
| if(id != null){ | |||||
| if (id != null) { | |||||
| throw new IllegalStateException("代码仓库名称已存在"); | throw new IllegalStateException("代码仓库名称已存在"); | ||||
| } | } | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| @@ -67,14 +73,14 @@ public class CodeConfigServiceImpl implements CodeConfigService { | |||||
| @Override | @Override | ||||
| public CodeConfig update(CodeConfig codeConfig) { | public CodeConfig update(CodeConfig codeConfig) { | ||||
| Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName()); | Long id = this.codeConfigDao.queryByCodeRepoName(codeConfig.getCodeRepoName()); | ||||
| if(id != null && !id.equals(codeConfig.getId())){ | |||||
| if (id != null && !id.equals(codeConfig.getId())) { | |||||
| throw new IllegalStateException("代码仓库名称已存在"); | throw new IllegalStateException("代码仓库名称已存在"); | ||||
| } | } | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| codeConfig.setUpdateBy(loginUser.getUsername()); | codeConfig.setUpdateBy(loginUser.getUsername()); | ||||
| if (codeConfig.getCodeRepoVis().equals(Constant.Code_Repo_Pub)) { | |||||
| if (codeConfig.getIsPublic()) { | |||||
| codeConfig.setVerifyMode(null); | codeConfig.setVerifyMode(null); | ||||
| codeConfig.setGitUserName(null); | codeConfig.setGitUserName(null); | ||||
| codeConfig.setGitPassword(null); | codeConfig.setGitPassword(null); | ||||
| @@ -98,7 +104,7 @@ public class CodeConfigServiceImpl implements CodeConfigService { | |||||
| } | } | ||||
| HashMap<String, String> map = new HashMap<>(); | HashMap<String, String> map = new HashMap<>(); | ||||
| map.put("code_path", codeConfig.getGitUrl()); | |||||
| map.put("id", String.valueOf(codeConfig.getId())); | |||||
| List<Ray> rayList = rayDao.queryByCodeConfig(JSON.toJSONString(map)); | List<Ray> rayList = rayDao.queryByCodeConfig(JSON.toJSONString(map)); | ||||
| if (rayList != null && !rayList.isEmpty()) { | if (rayList != null && !rayList.isEmpty()) { | ||||
| String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); | String rays = String.join(",", rayList.stream().map(Ray::getName).collect(Collectors.toSet())); | ||||
| @@ -121,7 +127,7 @@ public class CodeConfigServiceImpl implements CodeConfigService { | |||||
| String username = loginUser.getUsername(); | String username = loginUser.getUsername(); | ||||
| String createBy = codeConfig.getCreateBy(); | String createBy = codeConfig.getCreateBy(); | ||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | ||||
| return "无权限删除该代码配置"; | |||||
| throw new Exception("无权限删除该代码配置"); | |||||
| } | } | ||||
| codeConfig.setState(Constant.State_invalid); | codeConfig.setState(Constant.State_invalid); | ||||
| return this.codeConfigDao.update(codeConfig) > 0 ? "删除成功" : "删除失败"; | return this.codeConfigDao.update(codeConfig) > 0 ? "删除成功" : "删除失败"; | ||||
| @@ -47,7 +47,7 @@ public class ComponentServiceImpl implements ComponentService { | |||||
| @Override | @Override | ||||
| public Component queryById(Integer id) { | public Component queryById(Integer id) { | ||||
| Component component = this.componentDao.queryById(id); | Component component = this.componentDao.queryById(id); | ||||
| if (component == null){ | |||||
| if (component == null) { | |||||
| throw new RuntimeException("组件不存在"); | throw new RuntimeException("组件不存在"); | ||||
| } | } | ||||
| @@ -58,14 +58,14 @@ public class ComponentServiceImpl implements ComponentService { | |||||
| public List<Map> queryAllGroupedByCategory() throws Exception { | public List<Map> queryAllGroupedByCategory() throws Exception { | ||||
| List<Component> componentList = this.componentDao.queryAll(); | List<Component> componentList = this.componentDao.queryAll(); | ||||
| List<Map> result = new ArrayList<>(); | List<Map> result = new ArrayList<>(); | ||||
| if (componentList.isEmpty()){ | |||||
| if (componentList.isEmpty()) { | |||||
| return result; | return result; | ||||
| } | } | ||||
| List<SysDictData> categoryTypeList = DictUtils.getDictCache("category_type"); | List<SysDictData> categoryTypeList = DictUtils.getDictCache("category_type"); | ||||
| Map<Integer,List<Component>> groupedComponent = componentList.stream().collect(Collectors.groupingBy(Component::getCategoryId)); | |||||
| for (Map.Entry <Integer,List<Component>> entry : groupedComponent.entrySet()) { | |||||
| Map<Integer, List<Component>> groupedComponent = componentList.stream().collect(Collectors.groupingBy(Component::getCategoryId)); | |||||
| for (Map.Entry<Integer, List<Component>> entry : groupedComponent.entrySet()) { | |||||
| List<SysDictData> categorys = categoryTypeList.stream().filter(sysDictData -> StringUtils.equals(sysDictData.getDictValue(), String.valueOf(entry.getKey()))).collect(Collectors.toList()); | List<SysDictData> categorys = categoryTypeList.stream().filter(sysDictData -> StringUtils.equals(sysDictData.getDictValue(), String.valueOf(entry.getKey()))).collect(Collectors.toList()); | ||||
| if (categorys.size() ==0){ | |||||
| if (categorys.size() == 0) { | |||||
| throw new Exception("组件类型不存在"); | throw new Exception("组件类型不存在"); | ||||
| } | } | ||||
| Map map = new HashMap(); | Map map = new HashMap(); | ||||
| @@ -80,8 +80,8 @@ public class ComponentServiceImpl implements ComponentService { | |||||
| /** | /** | ||||
| * 分页查询 | * 分页查询 | ||||
| * | * | ||||
| * @param component 筛选条件 | |||||
| * @param pageRequest 分页对象 | |||||
| * @param component 筛选条件 | |||||
| * @param pageRequest 分页对象 | |||||
| * @return 查询结果 | * @return 查询结果 | ||||
| */ | */ | ||||
| @Override | @Override | ||||
| @@ -104,7 +104,7 @@ public class ComponentServiceImpl implements ComponentService { | |||||
| component.setControlStrategy(controlStrategy); | component.setControlStrategy(controlStrategy); | ||||
| //json转换,存数据库 | //json转换,存数据库 | ||||
| String inParameters= gson.toJson(componentVo.getInParameters(), LinkedHashMap.class); | |||||
| String inParameters = gson.toJson(componentVo.getInParameters(), LinkedHashMap.class); | |||||
| String outParameters = gson.toJson(componentVo.getOutParameters(), LinkedHashMap.class); | String outParameters = gson.toJson(componentVo.getOutParameters(), LinkedHashMap.class); | ||||
| String envVariable = gson.toJson(componentVo.getEnvVirables(), LinkedHashMap.class); | String envVariable = gson.toJson(componentVo.getEnvVirables(), LinkedHashMap.class); | ||||
| component.setEnvVirables(envVariable); | component.setEnvVirables(envVariable); | ||||
| @@ -118,9 +118,9 @@ public class ComponentServiceImpl implements ComponentService { | |||||
| component.setState(1); | component.setState(1); | ||||
| // 检查相同category_id下的component_name是否已存在 | // 检查相同category_id下的component_name是否已存在 | ||||
| Integer existingCount = this.componentDao.countByNameAndCategoryId(component.getComponentName(),component.getCategoryId()); | |||||
| Integer existingCount = this.componentDao.countByNameAndCategoryId(component.getComponentName(), component.getCategoryId()); | |||||
| if(existingCount != null && existingCount > 0) { | |||||
| if (existingCount != null && existingCount > 0) { | |||||
| throw new RuntimeException("该类别下已有同名组件"); | throw new RuntimeException("该类别下已有同名组件"); | ||||
| } | } | ||||
| @@ -139,15 +139,15 @@ public class ComponentServiceImpl implements ComponentService { | |||||
| Component component = this.queryById(componentVo.getId()); | Component component = this.queryById(componentVo.getId()); | ||||
| //只能更新当前存在的组件 | //只能更新当前存在的组件 | ||||
| if (component == null){ | |||||
| if (component == null) { | |||||
| throw new RuntimeException("组件不存在,无法更新"); | throw new RuntimeException("组件不存在,无法更新"); | ||||
| } | } | ||||
| //将object转成string类型 | //将object转成string类型 | ||||
| component = ConvertUtil.entityToVo(componentVo,Component.class); | |||||
| component = ConvertUtil.entityToVo(componentVo, Component.class); | |||||
| Gson gson = new Gson(); | Gson gson = new Gson(); | ||||
| String inParameters= gson.toJson(componentVo.getInParameters(), LinkedHashMap.class); | |||||
| String inParameters = gson.toJson(componentVo.getInParameters(), LinkedHashMap.class); | |||||
| String outParameters = gson.toJson(componentVo.getOutParameters(), LinkedHashMap.class); | String outParameters = gson.toJson(componentVo.getOutParameters(), LinkedHashMap.class); | ||||
| String envVariable = gson.toJson(componentVo.getEnvVirables(), LinkedHashMap.class); | String envVariable = gson.toJson(componentVo.getEnvVirables(), LinkedHashMap.class); | ||||
| @@ -174,24 +174,24 @@ public class ComponentServiceImpl implements ComponentService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public String removeById(Integer id) { | |||||
| public String removeById(Integer id) throws Exception { | |||||
| Component component = this.componentDao.queryById(id); | Component component = this.componentDao.queryById(id); | ||||
| //先进行判断 组件是否存在 | //先进行判断 组件是否存在 | ||||
| if (component == null ){ | |||||
| return "组件不存在"; | |||||
| if (component == null) { | |||||
| throw new Exception("组件不存在"); | |||||
| } | } | ||||
| //判断权限,只有admin和创建者本身可以删除该组件 | //判断权限,只有admin和创建者本身可以删除该组件 | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| String username = loginUser.getUsername(); | String username = loginUser.getUsername(); | ||||
| String createdBy = component.getCreateBy(); | String createdBy = component.getCreateBy(); | ||||
| if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | |||||
| return "无权限删除该组件"; | |||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) { | |||||
| throw new Exception("无权限删除该组件"); | |||||
| } | } | ||||
| component.setState(0); | component.setState(0); | ||||
| return this.componentDao.update(component)>0?"删除成功":"删除失败"; | |||||
| return this.componentDao.update(component) > 0 ? "删除成功" : "删除失败"; | |||||
| } | } | ||||
| @@ -92,10 +92,10 @@ public class ComputingResourceServiceImpl implements ComputingResourceService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public String removeById(Integer id) { | |||||
| public String removeById(Integer id) throws Exception { | |||||
| ComputingResource computingResource = this.computingResourceDao.queryById(id); | ComputingResource computingResource = this.computingResourceDao.queryById(id); | ||||
| if (computingResource == null){ | if (computingResource == null){ | ||||
| return "计算资源不存在"; | |||||
| throw new Exception("计算资源不存在"); | |||||
| } | } | ||||
| //判断权限,只有admin和创建者本身可以删除该数据集 | //判断权限,只有admin和创建者本身可以删除该数据集 | ||||
| @@ -103,7 +103,7 @@ public class ComputingResourceServiceImpl implements ComputingResourceService { | |||||
| String username = loginUser.getUsername(); | String username = loginUser.getUsername(); | ||||
| String createdBy = computingResource.getCreateBy(); | String createdBy = computingResource.getCreateBy(); | ||||
| if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | ||||
| return "无权限删除该计算资源"; | |||||
| throw new Exception("无权限删除该计算资源"); | |||||
| } | } | ||||
| computingResource.setState(0); | computingResource.setState(0); | ||||
| @@ -128,17 +128,17 @@ public class DatasetVersionServiceImpl implements DatasetVersionService { | |||||
| @Override | @Override | ||||
| public String removeById(Integer id) { | |||||
| public String removeById(Integer id) throws Exception { | |||||
| DatasetVersion datasetVersion = this.datasetVersionDao.queryById(id); | DatasetVersion datasetVersion = this.datasetVersionDao.queryById(id); | ||||
| if (datasetVersion == null){ | if (datasetVersion == null){ | ||||
| return "数据集版本信息不存在"; | |||||
| throw new Exception("数据集版本信息不存在"); | |||||
| } | } | ||||
| //判断权限,只有admin和创建者本身可以删除该数据集版本信息 | //判断权限,只有admin和创建者本身可以删除该数据集版本信息 | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| String username = loginUser.getUsername(); | String username = loginUser.getUsername(); | ||||
| String createdBy = datasetVersion.getCreateBy(); | String createdBy = datasetVersion.getCreateBy(); | ||||
| if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | ||||
| return "无权限删除该数据集版本"; | |||||
| throw new Exception("无权限删除该数据集版本"); | |||||
| } | } | ||||
| datasetVersion.setState(0); | datasetVersion.setState(0); | ||||
| @@ -175,7 +175,7 @@ public class DatasetVersionServiceImpl implements DatasetVersionService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public Map<Integer, String> deleteDatasetVersion(Integer datasetId, String version) { | |||||
| public Map<Integer, String> deleteDatasetVersion(Integer datasetId, String version) throws Exception { | |||||
| Map<Integer, String> results = new HashMap<Integer,String>(); | Map<Integer, String> results = new HashMap<Integer,String>(); | ||||
| // 根据模型ID和版本查询所有模型版本 | // 根据模型ID和版本查询所有模型版本 | ||||
| List<DatasetVersion> versions = this.datasetVersionDao.queryAllByDatasetVersion(datasetId, version); | List<DatasetVersion> versions = this.datasetVersionDao.queryAllByDatasetVersion(datasetId, version); | ||||
| @@ -109,8 +109,12 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { | |||||
| devEnvironment.setStandard(devEnvironmentVo.getStandard()); | devEnvironment.setStandard(devEnvironmentVo.getStandard()); | ||||
| devEnvironment.setEnvVariable(devEnvironmentVo.getEnvVariable()); | devEnvironment.setEnvVariable(devEnvironmentVo.getEnvVariable()); | ||||
| devEnvironment.setImage(JacksonUtil.toJSONString(devEnvironmentVo.getImage())); | devEnvironment.setImage(JacksonUtil.toJSONString(devEnvironmentVo.getImage())); | ||||
| devEnvironment.setDataset(JacksonUtil.toJSONString(devEnvironmentVo.getDataset())); | |||||
| devEnvironment.setModel(JacksonUtil.toJSONString(devEnvironmentVo.getModel())); | |||||
| if (devEnvironmentVo.getDataset() != null) { | |||||
| devEnvironment.setDataset(JacksonUtil.toJSONString(devEnvironmentVo.getDataset())); | |||||
| } | |||||
| if (devEnvironmentVo.getModel() != null) { | |||||
| devEnvironment.setModel(JacksonUtil.toJSONString(devEnvironmentVo.getModel())); | |||||
| } | |||||
| devEnvironment.setCreateBy(loginUser.getUsername()); | devEnvironment.setCreateBy(loginUser.getUsername()); | ||||
| devEnvironment.setUpdateBy(loginUser.getUsername()); | devEnvironment.setUpdateBy(loginUser.getUsername()); | ||||
| devEnvironment.setUpdateTime(new Date()); | devEnvironment.setUpdateTime(new Date()); | ||||
| @@ -154,7 +158,7 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { | |||||
| public String removeById(Integer id) throws Exception { | public String removeById(Integer id) throws Exception { | ||||
| DevEnvironment devEnvironment = this.devEnvironmentDao.queryById(id); | DevEnvironment devEnvironment = this.devEnvironmentDao.queryById(id); | ||||
| if (devEnvironment == null) { | if (devEnvironment == null) { | ||||
| return "开发环境信息不存在"; | |||||
| throw new RuntimeException("开发环境信息不存在"); | |||||
| } | } | ||||
| //判断权限,只有admin和创建者本身可以删除该数据集 | //判断权限,只有admin和创建者本身可以删除该数据集 | ||||
| @@ -162,7 +166,7 @@ public class DevEnvironmentServiceImpl implements DevEnvironmentService { | |||||
| String username = loginUser.getUsername(); | String username = loginUser.getUsername(); | ||||
| String createdBy = devEnvironment.getCreateBy(); | String createdBy = devEnvironment.getCreateBy(); | ||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) { | if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) { | ||||
| return "无权限删除该开发环境"; | |||||
| throw new RuntimeException("无权限删除该开发环境"); | |||||
| } | } | ||||
| jupyterService.stopJupyterService(id); | jupyterService.stopJupyterService(id); | ||||
| @@ -18,6 +18,8 @@ import com.ruoyi.platform.vo.PodLogVo; | |||||
| import com.ruoyi.system.api.constant.Constant; | import com.ruoyi.system.api.constant.Constant; | ||||
| import com.ruoyi.system.api.model.LoginUser; | import com.ruoyi.system.api.model.LoginUser; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.data.domain.Page; | import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.PageImpl; | import org.springframework.data.domain.PageImpl; | ||||
| @@ -27,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.text.SimpleDateFormat; | |||||
| import java.time.Instant; | |||||
| import java.util.*; | import java.util.*; | ||||
| /** | /** | ||||
| @@ -37,6 +41,8 @@ import java.util.*; | |||||
| */ | */ | ||||
| @Service("experimentInsService") | @Service("experimentInsService") | ||||
| public class ExperimentInsServiceImpl implements ExperimentInsService { | public class ExperimentInsServiceImpl implements ExperimentInsService { | ||||
| private static final Logger logger = LoggerFactory.getLogger(ExperimentInsServiceImpl.class); | |||||
| @Resource | @Resource | ||||
| private ExperimentInsDao experimentInsDao; | private ExperimentInsDao experimentInsDao; | ||||
| @Resource | @Resource | ||||
| @@ -200,8 +206,25 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| experimentIns.setUpdateBy(loginUser.getUsername()); | experimentIns.setUpdateBy(loginUser.getUsername()); | ||||
| experimentIns.setUpdateTime(new Date()); | experimentIns.setUpdateTime(new Date()); | ||||
| experimentIns = queryStatusFromArgo(experimentIns); | |||||
| this.experimentInsDao.update(experimentIns); | this.experimentInsDao.update(experimentIns); | ||||
| return this.queryById(experimentIns.getId()); | |||||
| updateExperimentStatus(experimentIns.getExperimentId()); | |||||
| if (Constant.Failed.equals(experimentIns.getStatus()) || Constant.Succeeded.equals(experimentIns.getStatus())) { | |||||
| if (StringUtils.isNotEmpty(experimentIns.getNodesStatus())) { | |||||
| Map<String, Object> nodesStatusMap = JsonUtils.jsonToMap(experimentIns.getNodesStatus()); | |||||
| for (String key : nodesStatusMap.keySet()) { | |||||
| Map<String, Object> value = (Map<String, Object>) nodesStatusMap.get(key); | |||||
| String startedAt = (String) value.get("startedAt"); | |||||
| Instant instant = Instant.parse(startedAt); | |||||
| Date startTime = Date.from(instant); | |||||
| String finishedAt = (String) value.get("finishedAt"); | |||||
| if (StringUtils.isNotEmpty(finishedAt)) { | |||||
| resourceOccupyService.endDeduce(Constant.TaskType_Workflow, null, Long.valueOf(experimentIns.getId()), key, startTime); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| return experimentIns; | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -209,7 +232,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| public String removeById(Integer id) { | public String removeById(Integer id) { | ||||
| ExperimentIns experimentIns = experimentInsDao.queryById(id); | ExperimentIns experimentIns = experimentInsDao.queryById(id); | ||||
| if (experimentIns == null) { | if (experimentIns == null) { | ||||
| return "实验实例不存在"; | |||||
| throw new RuntimeException("实验实例不存在"); | |||||
| } | } | ||||
| //判断权限,只有admin和创建者本身可以删除该实验实例 | //判断权限,只有admin和创建者本身可以删除该实验实例 | ||||
| @@ -217,16 +240,16 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| String username = loginUser.getUsername(); | String username = loginUser.getUsername(); | ||||
| String createdBy = experimentIns.getCreateBy(); | String createdBy = experimentIns.getCreateBy(); | ||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) { | if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createdBy))) { | ||||
| return "无权限删除该流水线"; | |||||
| throw new RuntimeException("无权限删除该实验实例"); | |||||
| } | } | ||||
| if (StringUtils.isEmpty(experimentIns.getStatus())) { | if (StringUtils.isEmpty(experimentIns.getStatus())) { | ||||
| experimentIns = queryStatusFromArgo(experimentIns); | experimentIns = queryStatusFromArgo(experimentIns); | ||||
| } | } | ||||
| if (StringUtils.equals(experimentIns.getStatus(), "Running")) { | |||||
| return "实验实例正在运行,不可删除"; | |||||
| if (StringUtils.equals(experimentIns.getStatus(), Constant.Running)) { | |||||
| throw new RuntimeException("实验实例正在运行,不可删除"); | |||||
| } | } | ||||
| experimentIns.setState(0); | |||||
| experimentIns.setState(Constant.State_invalid); | |||||
| int update = this.experimentInsDao.update(experimentIns); | int update = this.experimentInsDao.update(experimentIns); | ||||
| if (update > 0) { | if (update > 0) { | ||||
| resourceOccupyService.deleteTaskState(Constant.TaskType_Workflow, Long.valueOf(experimentIns.getExperimentId()), Long.valueOf(id)); | resourceOccupyService.deleteTaskState(Constant.TaskType_Workflow, Long.valueOf(experimentIns.getExperimentId()), Long.valueOf(id)); | ||||
| @@ -267,12 +290,10 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| @Override | @Override | ||||
| public ExperimentIns queryStatusFromArgo(ExperimentIns ins) { | public ExperimentIns queryStatusFromArgo(ExperimentIns ins) { | ||||
| String namespace = ins.getArgoInsNs(); | String namespace = ins.getArgoInsNs(); | ||||
| String name = ins.getArgoInsName(); | String name = ins.getArgoInsName(); | ||||
| Integer id = ins.getId(); | Integer id = ins.getId(); | ||||
| // 创建请求数据map | // 创建请求数据map | ||||
| ExperimentIns experimentIns = this.experimentInsDao.queryById(id); | |||||
| Map<String, Object> requestData = new HashMap<>(); | Map<String, Object> requestData = new HashMap<>(); | ||||
| requestData.put("namespace", namespace); | requestData.put("namespace", namespace); | ||||
| requestData.put("name", name); | requestData.put("name", name); | ||||
| @@ -305,7 +326,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| String finishedAtString = (String) status.get("finishedAt"); | String finishedAtString = (String) status.get("finishedAt"); | ||||
| if (finishedAtString != null && !finishedAtString.isEmpty()) { | if (finishedAtString != null && !finishedAtString.isEmpty()) { | ||||
| Date finishTime = DateUtils.convertUTCtoShanghaiDate(finishedAtString); | Date finishTime = DateUtils.convertUTCtoShanghaiDate(finishedAtString); | ||||
| experimentIns.setFinishTime(finishTime); | |||||
| ins.setFinishTime(finishTime); | |||||
| } | } | ||||
| // 解析nodes字段,提取节点状态并转换为JSON字符串 | // 解析nodes字段,提取节点状态并转换为JSON字符串 | ||||
| @@ -320,18 +341,16 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| } | } | ||||
| String nodeStatusJson = JsonUtils.mapToJson(modifiedNodes); | String nodeStatusJson = JsonUtils.mapToJson(modifiedNodes); | ||||
| experimentIns.setNodesStatus(nodeStatusJson); | |||||
| ins.setNodesStatus(nodeStatusJson); | |||||
| //终止态为终止不改 | //终止态为终止不改 | ||||
| if (!StringUtils.equals(experimentIns.getStatus(), "Terminated")) { | |||||
| experimentIns.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : "Pending"); | |||||
| if (!StringUtils.equals(ins.getStatus(), Constant.Terminated)) { | |||||
| ins.setStatus(StringUtils.isNotEmpty((String) status.get("phase")) ? (String) status.get("phase") : Constant.Pending); | |||||
| } | } | ||||
| if (StringUtils.equals(experimentIns.getStatus(), Constant.Error)) { | |||||
| experimentIns.setStatus("Failed"); | |||||
| if (StringUtils.equals(ins.getStatus(), Constant.Error)) { | |||||
| ins.setStatus(Constant.Failed); | |||||
| } | } | ||||
| return experimentIns; | |||||
| return ins; | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException("查询状态失败: " + e.getMessage(), e); | throw new RuntimeException("查询状态失败: " + e.getMessage(), e); | ||||
| @@ -362,7 +381,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| } | } | ||||
| // 只有状态是"Running"时才能终止实例 | // 只有状态是"Running"时才能终止实例 | ||||
| if (!currentStatus.equalsIgnoreCase("Running")) { | |||||
| if (!currentStatus.equalsIgnoreCase(Constant.Running)) { | |||||
| throw new Exception("终止错误,只有运行状态的实例才能终止"); // 如果不是"Running"状态,则不执行终止操作 | throw new Exception("终止错误,只有运行状态的实例才能终止"); // 如果不是"Running"状态,则不执行终止操作 | ||||
| } | } | ||||
| @@ -404,6 +423,9 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| // 如果值不等于 Succeeded,则赋值为 Failed | // 如果值不等于 Succeeded,则赋值为 Failed | ||||
| if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { | if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { | ||||
| innerMap.put("phase", Constant.Failed); | innerMap.put("phase", Constant.Failed); | ||||
| Calendar calendar = Calendar.getInstance(); | |||||
| calendar.add(Calendar.HOUR_OF_DAY, -8); | |||||
| innerMap.put("finishedAt", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(calendar.getTime())); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -430,40 +452,51 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| } | } | ||||
| void deleteExportVersion(ExperimentIns experimentIns) throws Exception { | |||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | |||||
| String ci4sUsername = loginUser.getUsername(); | |||||
| String nodesResult = experimentIns.getNodesResult(); | |||||
| if (StringUtils.isNotEmpty(nodesResult)) { | |||||
| Map<String, Object> nodesResultMap = JsonUtils.jsonToMap(nodesResult); | |||||
| Map<String, Object> paramOutput = (Map<String, Object>) nodesResultMap.get("param_output"); | |||||
| for (String key : paramOutput.keySet()) { | |||||
| //删除导出模型版本 | |||||
| if (key.contains("model-export")) { | |||||
| HashMap queryMap = new HashMap<String, Integer>(); | |||||
| queryMap.put("insId", experimentIns.getId()); | |||||
| ModelDependency1 modelDependency1 = modelDependency1Dao.queryByInsId(JSON.toJSONString(queryMap)); | |||||
| if (modelDependency1 != null) { | |||||
| if (StringUtils.isNotEmpty(modelDependency1.getVersion())) { | |||||
| String relativePath = ci4sUsername + "/model/" + modelDependency1.getRepoId() + "/" + modelDependency1.getIdentifier() + "/" + modelDependency1.getVersion() + "/model"; | |||||
| modelsService.deleteVersion(modelDependency1.getRepoId(), modelDependency1.getIdentifier(), modelDependency1.getOwner(), modelDependency1.getVersion(), relativePath); | |||||
| } else { | |||||
| modelDependency1Dao.deleteModelById(modelDependency1.getId()); | |||||
| void deleteExportVersion(ExperimentIns experimentIns) { | |||||
| try { | |||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | |||||
| String ci4sUsername = loginUser.getUsername(); | |||||
| String nodesResult = experimentIns.getNodesResult(); | |||||
| if (StringUtils.isNotEmpty(nodesResult)) { | |||||
| Map<String, Object> nodesResultMap = JsonUtils.jsonToMap(nodesResult); | |||||
| Map<String, Object> paramOutput = (Map<String, Object>) nodesResultMap.get("param_output"); | |||||
| Map<String, Object> nodesStatusMap = JsonUtils.jsonToMap(experimentIns.getNodesStatus()); | |||||
| for (String key : paramOutput.keySet()) { | |||||
| //删除导出模型版本 | |||||
| if (key.contains("model-export")) { | |||||
| Map<String, Object> modelExportMap = (Map<String, Object>) nodesStatusMap.get(key); | |||||
| if (modelExportMap != null && (Constant.Running.equals(modelExportMap.get("phase")) || Constant.Succeeded.equals(modelExportMap.get("phase")))) { | |||||
| HashMap queryMap = new HashMap<String, Integer>(); | |||||
| queryMap.put("insId", experimentIns.getId()); | |||||
| ModelDependency1 modelDependency1 = modelDependency1Dao.queryByInsId(JSON.toJSONString(queryMap)); | |||||
| if (modelDependency1 != null) { | |||||
| if (StringUtils.isNotEmpty(modelDependency1.getVersion())) { | |||||
| String relativePath = ci4sUsername + "/model/" + modelDependency1.getRepoId() + "/" + modelDependency1.getIdentifier() + "/" + modelDependency1.getVersion() + "/model"; | |||||
| modelsService.deleteVersion(modelDependency1.getRepoId(), modelDependency1.getIdentifier(), modelDependency1.getOwner(), modelDependency1.getVersion(), relativePath); | |||||
| } else { | |||||
| modelDependency1Dao.deleteModelById(modelDependency1.getId()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| //删除导出数据集版本 | |||||
| if (key.contains("dataset-export")) { | |||||
| Map<String, Object> datasetExportMap = (Map<String, Object>) nodesStatusMap.get(key); | |||||
| if (datasetExportMap != null && (Constant.Running.equals(datasetExportMap.get("phase")) || Constant.Succeeded.equals(datasetExportMap.get("phase")))) { | |||||
| HashMap queryMap = new HashMap<String, Integer>(); | |||||
| queryMap.put("ins_id", experimentIns.getId()); | |||||
| DatasetTempStorage datasetTempStorage = datasetTempStorageDao.queryByInsId(JSON.toJSONString(queryMap)); | |||||
| String relativePath = ci4sUsername + "/datasets/" + datasetTempStorage.getRepoId() + "/" + datasetTempStorage.getName() + "/" + datasetTempStorage.getVersion() + "/dataset"; | |||||
| newDatasetService.deleteDatasetVersionNew(datasetTempStorage.getRepoId(), datasetTempStorage.getName(), datasetTempStorage.getCreateBy(), datasetTempStorage.getVersion(), relativePath); | |||||
| } | } | ||||
| } | } | ||||
| } | |||||
| //删除导出数据集版本 | |||||
| if (key.contains("dataset-export")) { | |||||
| HashMap queryMap = new HashMap<String, Integer>(); | |||||
| queryMap.put("ins_id", experimentIns.getId()); | |||||
| DatasetTempStorage datasetTempStorage = datasetTempStorageDao.queryByInsId(JSON.toJSONString(queryMap)); | |||||
| String relativePath = ci4sUsername + "/datasets/" + datasetTempStorage.getRepoId() + "/" + datasetTempStorage.getName() + "/" + datasetTempStorage.getVersion() + "/dataset"; | |||||
| newDatasetService.deleteDatasetVersionNew(datasetTempStorage.getRepoId(), datasetTempStorage.getName(), datasetTempStorage.getCreateBy(), datasetTempStorage.getVersion(), relativePath); | |||||
| } | } | ||||
| } | } | ||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -649,7 +682,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| // 定义终止态的列表,例如 "Succeeded", "Failed" 等 | // 定义终止态的列表,例如 "Succeeded", "Failed" 等 | ||||
| String status = ins.getStatus(); | String status = ins.getStatus(); | ||||
| boolean flag = true; | boolean flag = true; | ||||
| List<String> terminatedStates = Arrays.asList("Succeeded", "Failed"); | |||||
| List<String> terminatedStates = Arrays.asList("Succeeded", Constant.Failed); | |||||
| flag = terminatedStates.contains(status); | flag = terminatedStates.contains(status); | ||||
| if (StringUtils.equals(status, "Terminated")) { | if (StringUtils.equals(status, "Terminated")) { | ||||
| //如果跟node_status里面不一样,就要去更新node_status的信息 | //如果跟node_status里面不一样,就要去更新node_status的信息 | ||||
| @@ -677,9 +710,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | String subStatus = statusList.toString().substring(1, statusList.toString().length() - 1); | ||||
| Experiment experiment = experimentDao.queryById(experimentId); | Experiment experiment = experimentDao.queryById(experimentId); | ||||
| experiment.setStatusList(subStatus); | experiment.setStatusList(subStatus); | ||||
| List<Experiment> updateExperiments = new ArrayList<>(); | |||||
| updateExperiments.add(experiment); | |||||
| experimentDao.insertOrUpdateBatch(updateExperiments); | |||||
| experimentDao.update(experiment); | |||||
| } | } | ||||
| } | } | ||||
| @@ -149,9 +149,7 @@ public class ExperimentServiceImpl implements ExperimentService { | |||||
| checkDeclaredName(experiment); | checkDeclaredName(experiment); | ||||
| experiment.setCreateBy(loginUser.getUsername()); | experiment.setCreateBy(loginUser.getUsername()); | ||||
| experiment.setUpdateBy(loginUser.getUsername()); | experiment.setUpdateBy(loginUser.getUsername()); | ||||
| experiment.setUpdateTime(new Date()); | |||||
| experiment.setCreateTime(new Date()); | |||||
| experiment.setState(1); | |||||
| experiment.setState(Constant.State_valid); | |||||
| this.experimentDao.insert(experiment); | this.experimentDao.insert(experiment); | ||||
| return experiment; | return experiment; | ||||
| } | } | ||||
| @@ -167,7 +165,6 @@ public class ExperimentServiceImpl implements ExperimentService { | |||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| checkDeclaredName(experiment); | checkDeclaredName(experiment); | ||||
| experiment.setUpdateBy(loginUser.getUsername()); | experiment.setUpdateBy(loginUser.getUsername()); | ||||
| experiment.setUpdateTime(new Date()); | |||||
| this.experimentDao.update(experiment); | this.experimentDao.update(experiment); | ||||
| return this.queryById(experiment.getId()); | return this.queryById(experiment.getId()); | ||||
| } | } | ||||
| @@ -237,6 +234,9 @@ public class ExperimentServiceImpl implements ExperimentService { | |||||
| throw new Exception("转换流水线失败"); | throw new Exception("转换流水线失败"); | ||||
| } | } | ||||
| Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | ||||
| if (converMap.get("data") == null) { | |||||
| throw new RuntimeException("转换流水线失败"); | |||||
| } | |||||
| // 判断积分和资源是否足够 | // 判断积分和资源是否足够 | ||||
| Map<String, Map<String, Object>> resourceInfo = (Map<String, Map<String, Object>>) converMap.get("resource_info"); | Map<String, Map<String, Object>> resourceInfo = (Map<String, Map<String, Object>>) converMap.get("resource_info"); | ||||
| @@ -321,7 +321,7 @@ public class ExperimentServiceImpl implements ExperimentService { | |||||
| resourceOccupyService.startDeduce((Integer) node.get("computing_resource_id"), 1, Constant.TaskType_Workflow, Long.valueOf(id), Long.valueOf(insert.getId()), experiment.getWorkflowId(), experiment.getName(), entry.getKey(), Constant.State_building); | resourceOccupyService.startDeduce((Integer) node.get("computing_resource_id"), 1, Constant.TaskType_Workflow, Long.valueOf(id), Long.valueOf(insert.getId()), experiment.getWorkflowId(), experiment.getName(), entry.getKey(), Constant.State_building); | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new Exception(e); | |||||
| throw new Exception(e.getMessage()); | |||||
| } | } | ||||
| List<ExperimentIns> updatedExperimentInsList = experimentInsService.getByExperimentId(id); | List<ExperimentIns> updatedExperimentInsList = experimentInsService.getByExperimentId(id); | ||||
| experiment.setExperimentInsList(updatedExperimentInsList); | experiment.setExperimentInsList(updatedExperimentInsList); | ||||
| @@ -815,7 +815,7 @@ public class ExperimentServiceImpl implements ExperimentService { | |||||
| try { | try { | ||||
| newExperiment = this.runExperiment(newExperiment.getId()); | newExperiment = this.runExperiment(newExperiment.getId()); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException(e); | |||||
| throw new RuntimeException(e.getMessage()); | |||||
| } | } | ||||
| return newExperiment; | return newExperiment; | ||||
| @@ -99,7 +99,7 @@ public class GitServiceImpl implements GitService { | |||||
| token = jedis.get(ci4sUsername + "_gitToken"); | token = jedis.get(ci4sUsername + "_gitToken"); | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException(e); | |||||
| throw new RuntimeException(e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| return token; | return token; | ||||
| @@ -240,4 +240,27 @@ public class GitServiceImpl implements GitService { | |||||
| throw new Exception("用户不可删除:" + resultMap.get("message")); | throw new Exception("用户不可删除:" + resultMap.get("message")); | ||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| public List<Map<String, Object>> PersonalQueryGitByPage(String token, String login, String name, Integer page) throws Exception { | |||||
| // 拼接查询url | |||||
| String url = gitendpoint + "/api/users/" + login + "/projects.json?page=" + page + "&limit=50&category=manage&sort_direction=praises_count&sort_by=desc"; | |||||
| if (StringUtils.isNotEmpty(name)) { | |||||
| url = url + "&search=" + name; | |||||
| } | |||||
| String req = httpUtils.sendGetWithToken(url, null, token); | |||||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||||
| return (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||||
| } | |||||
| public List<Map<String, Object>> PubilcQueryGitByPage(String token, String name, Integer page, Integer projectCategoryId) throws Exception { | |||||
| // 拼接查询url | |||||
| String url = gitendpoint + "/api/projects.json?page=" + page + "&limit=50sort_direction=praises_count&sort_by=desc&category_id=" + projectCategoryId; | |||||
| if (StringUtils.isNotEmpty(name)) { | |||||
| url = url + "&search=" + name; | |||||
| } | |||||
| String req = httpUtils.sendGetWithToken(url, null, token); | |||||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||||
| return (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||||
| } | |||||
| } | } | ||||
| @@ -275,7 +275,7 @@ public class ImageServiceImpl implements ImageService { | |||||
| imageVersion.setVersion(imageVo.getVersion()); | imageVersion.setVersion(imageVo.getVersion()); | ||||
| imageVersion.setTagName(imageVo.getTagName()); | imageVersion.setTagName(imageVo.getTagName()); | ||||
| imageVersion.setFileSize(imageVo.getFileSize()); | imageVersion.setFileSize(imageVo.getFileSize()); | ||||
| imageVersion.setDescription(imageVo.getDescription()); | |||||
| imageVersion.setDescription(imageVo.getVersionDescription()); | |||||
| imageVersion.setStatus(Constant.Building); | imageVersion.setStatus(Constant.Building); | ||||
| ImageVersion imageVersionInsert = this.imageVersionService.insert(imageVersion); | ImageVersion imageVersionInsert = this.imageVersionService.insert(imageVersion); | ||||
| if (imageVersionInsert == null) { | if (imageVersionInsert == null) { | ||||
| @@ -302,7 +302,7 @@ public class ImageServiceImpl implements ImageService { | |||||
| String fileSize = resultMap.get("fileSize"); | String fileSize = resultMap.get("fileSize"); | ||||
| imageVersion.setUrl(imageUrl); | imageVersion.setUrl(imageUrl); | ||||
| imageVersion.setFileSize(fileSize); | imageVersion.setFileSize(fileSize); | ||||
| imageVersion.setStatus("available"); | |||||
| imageVersion.setStatus(Constant.Available); | |||||
| imageVersionService.update(imageVersion); | imageVersionService.update(imageVersion); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| System.err.println("更新数据库失败: " + e.getMessage()); | System.err.println("更新数据库失败: " + e.getMessage()); | ||||
| @@ -466,7 +466,7 @@ public class ImageServiceImpl implements ImageService { | |||||
| imageVo.setValue(resultMap.get("imageName")); | imageVo.setValue(resultMap.get("imageName")); | ||||
| imageVo.setVersion(String.valueOf(imageVersion.getId())); | imageVo.setVersion(String.valueOf(imageVersion.getId())); | ||||
| resultMap.put("id", String.valueOf(oldImage.getId())); | |||||
| resultMap.put("id", String.valueOf(image.getId())); | |||||
| resultMap.put("version", String.valueOf(imageVersion.getId())); | resultMap.put("version", String.valueOf(imageVersion.getId())); | ||||
| resultMap.put("value",resultMap.get("imageName")); | resultMap.put("value",resultMap.get("imageName")); | ||||
| @@ -9,8 +9,11 @@ import com.ruoyi.platform.service.ResourceOccupyService; | |||||
| import com.ruoyi.platform.utils.DateUtils; | import com.ruoyi.platform.utils.DateUtils; | ||||
| import com.ruoyi.platform.utils.HttpUtils; | import com.ruoyi.platform.utils.HttpUtils; | ||||
| import com.ruoyi.platform.utils.JsonUtils; | import com.ruoyi.platform.utils.JsonUtils; | ||||
| import com.ruoyi.platform.utils.MinioUtil; | |||||
| import com.ruoyi.system.api.constant.Constant; | import com.ruoyi.system.api.constant.Constant; | ||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.data.domain.Page; | import org.springframework.data.domain.Page; | ||||
| @@ -19,10 +22,13 @@ import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.*; | import java.util.*; | ||||
| @Service | @Service | ||||
| public class MachineLearnInsServiceImpl implements MachineLearnInsService { | public class MachineLearnInsServiceImpl implements MachineLearnInsService { | ||||
| private static final Logger logger = LoggerFactory.getLogger(MachineLearnInsServiceImpl.class); | |||||
| @Value("${argo.url}") | @Value("${argo.url}") | ||||
| private String argoUrl; | private String argoUrl; | ||||
| @Value("${argo.workflowStatus}") | @Value("${argo.workflowStatus}") | ||||
| @@ -36,6 +42,8 @@ public class MachineLearnInsServiceImpl implements MachineLearnInsService { | |||||
| private MachineLearnDao machineLearnDao; | private MachineLearnDao machineLearnDao; | ||||
| @Resource | @Resource | ||||
| private ResourceOccupyService resourceOccupyService; | private ResourceOccupyService resourceOccupyService; | ||||
| @Resource | |||||
| private MinioUtil minioUtil; | |||||
| @Override | @Override | ||||
| public Page<MachineLearnIns> queryByPage(Long machineLearnId, PageRequest pageRequest) { | public Page<MachineLearnIns> queryByPage(Long machineLearnId, PageRequest pageRequest) { | ||||
| @@ -50,6 +58,18 @@ public class MachineLearnInsServiceImpl implements MachineLearnInsService { | |||||
| return machineLearnIns; | return machineLearnIns; | ||||
| } | } | ||||
| @Override | |||||
| public MachineLearnIns update(MachineLearnIns machineLearnIns) { | |||||
| machineLearnIns.setUpdateTime(new Date()); | |||||
| machineLearnIns = queryStatusFromArgo(machineLearnIns); | |||||
| machineLearnInsDao.update(machineLearnIns); | |||||
| updateMLStatus(machineLearnIns.getMachineLearnId()); | |||||
| if (Constant.Failed.equals(machineLearnIns.getStatus()) || Constant.Succeeded.equals(machineLearnIns.getStatus())) { | |||||
| resourceOccupyService.endDeduce(Constant.TaskType_ML, null, machineLearnIns.getId(), null, null); | |||||
| } | |||||
| return machineLearnIns; | |||||
| } | |||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| public String removeById(Long id) { | public String removeById(Long id) { | ||||
| @@ -211,6 +231,9 @@ public class MachineLearnInsServiceImpl implements MachineLearnInsService { | |||||
| // 如果值不等于 Succeeded,则赋值为 Failed | // 如果值不等于 Succeeded,则赋值为 Failed | ||||
| if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { | if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { | ||||
| innerMap.put("phase", Constant.Failed); | innerMap.put("phase", Constant.Failed); | ||||
| Calendar calendar = Calendar.getInstance(); | |||||
| calendar.add(Calendar.HOUR_OF_DAY, -8); | |||||
| innerMap.put("finishedAt", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(calendar.getTime())); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -237,6 +260,9 @@ public class MachineLearnInsServiceImpl implements MachineLearnInsService { | |||||
| if (Constant.Running.equals(machineLearnIns.getStatus()) || Constant.Pending.equals(machineLearnIns.getStatus())) { | if (Constant.Running.equals(machineLearnIns.getStatus()) || Constant.Pending.equals(machineLearnIns.getStatus())) { | ||||
| machineLearnIns = queryStatusFromArgo(machineLearnIns); | machineLearnIns = queryStatusFromArgo(machineLearnIns); | ||||
| } | } | ||||
| if (Constant.ML_VideoClassification.equals(machineLearnIns.getType())) { | |||||
| getFileList(machineLearnIns); | |||||
| } | |||||
| return machineLearnIns; | return machineLearnIns; | ||||
| } | } | ||||
| @@ -256,4 +282,24 @@ public class MachineLearnInsServiceImpl implements MachineLearnInsService { | |||||
| machineLearnDao.edit(machineLearn); | machineLearnDao.edit(machineLearn); | ||||
| } | } | ||||
| } | } | ||||
| public void getFileList(MachineLearnIns ins) { | |||||
| String directoryPath = ins.getResultPath(); | |||||
| try { | |||||
| String bucketName = directoryPath.substring(0, directoryPath.indexOf("/")); | |||||
| String prefix = directoryPath.substring(directoryPath.indexOf("/") + 1, directoryPath.length()) + "/"; | |||||
| List<Map> fileMaps = minioUtil.listRayFilesInDirectory(bucketName, prefix); | |||||
| Map<Object, Object> fileMap = new HashMap<>(); | |||||
| fileMap.put("children", fileMaps); | |||||
| fileMap.put("url", directoryPath); | |||||
| fileMap.put("isDirectory", true); | |||||
| fileMap.put("size", "0 B"); | |||||
| fileMap.put("name", "result file"); | |||||
| ins.setFileMap(fileMap); | |||||
| } catch (Exception e) { | |||||
| logger.error("未找到结果文件"); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -63,7 +63,7 @@ public class MachineLearnServiceImpl implements MachineLearnService { | |||||
| @Override | @Override | ||||
| public MachineLearn add(MachineLearn machineLearn) { | public MachineLearn add(MachineLearn machineLearn) { | ||||
| if (machineLearn.getName().length() >= 64) { | |||||
| if (machineLearn.getName().length() > 64) { | |||||
| throw new RuntimeException("实验名称大于最大长度"); | throw new RuntimeException("实验名称大于最大长度"); | ||||
| } | } | ||||
| MachineLearn machineLearnByName = machineLearnDao.getMachineLearnByName(machineLearn.getName()); | MachineLearn machineLearnByName = machineLearnDao.getMachineLearnByName(machineLearn.getName()); | ||||
| @@ -105,6 +105,12 @@ public class MachineLearnServiceImpl implements MachineLearnService { | |||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | ||||
| throw new RuntimeException("无权限删除该实验"); | throw new RuntimeException("无权限删除该实验"); | ||||
| } | } | ||||
| List<MachineLearnIns> insList = machineLearnInsDao.getByMachineLearnId(machineLearn.getId()); | |||||
| if (!insList.isEmpty()) { | |||||
| throw new RuntimeException("该实验存在实例,无法删除"); | |||||
| } | |||||
| machineLearn.setUpdateBy(SecurityUtils.getLoginUser().getUsername()); | machineLearn.setUpdateBy(SecurityUtils.getLoginUser().getUsername()); | ||||
| machineLearn.setState(Constant.State_invalid); | machineLearn.setState(Constant.State_invalid); | ||||
| resourceOccupyService.deleteTaskState(Constant.TaskType_ML, id, null); | resourceOccupyService.deleteTaskState(Constant.TaskType_ML, id, null); | ||||
| @@ -159,6 +165,12 @@ public class MachineLearnServiceImpl implements MachineLearnService { | |||||
| if (convertRes == null || StringUtils.isEmpty(convertRes)) { | if (convertRes == null || StringUtils.isEmpty(convertRes)) { | ||||
| throw new RuntimeException("转换流水线失败"); | throw new RuntimeException("转换流水线失败"); | ||||
| } | } | ||||
| Map<String, Object> convertResMap = JsonUtils.jsonToMap(convertRes); | |||||
| if (convertResMap.get("data")== null) { | |||||
| throw new RuntimeException("转换流水线失败"); | |||||
| } | |||||
| Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | ||||
| // 组装运行接口json | // 组装运行接口json | ||||
| Map<String, Object> output = (Map<String, Object>) converMap.get("output"); | Map<String, Object> output = (Map<String, Object>) converMap.get("output"); | ||||
| @@ -191,7 +203,8 @@ public class MachineLearnServiceImpl implements MachineLearnService { | |||||
| Map<String, Object> param_output = (Map<String, Object>) output.get("param_output"); | Map<String, Object> param_output = (Map<String, Object>) output.get("param_output"); | ||||
| List output1 = (ArrayList) param_output.values().toArray()[0]; | List output1 = (ArrayList) param_output.values().toArray()[0]; | ||||
| Map<String, String> output2 = (Map<String, String>) output1.get(0); | Map<String, String> output2 = (Map<String, String>) output1.get(0); | ||||
| String outputPath = minioEndpoint + "/" + output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")) + "/"; | |||||
| String outputStr = output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")); | |||||
| String outputPath = minioEndpoint + "/" + outputStr + "/"; | |||||
| switch (machineLearn.getType()) { | switch (machineLearn.getType()) { | ||||
| case Constant.ML_CSV: { | case Constant.ML_CSV: { | ||||
| @@ -208,13 +221,13 @@ public class MachineLearnServiceImpl implements MachineLearnService { | |||||
| } | } | ||||
| case Constant.ML_TextClassification: { | case Constant.ML_TextClassification: { | ||||
| machineLearnIns.setModelPath(outputPath + "saved_dict/" + modelType + ".ckpt"); | machineLearnIns.setModelPath(outputPath + "saved_dict/" + modelType + ".ckpt"); | ||||
| machineLearnIns.setRunHistoryPath(output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")).substring("data/".length()) + "/log/" + modelType); | |||||
| machineLearnIns.setRunHistoryPath(outputStr.substring("data/".length()) + "/log/" + modelType); | |||||
| machineLearnIns.setResultPath(outputPath + "log/" + modelType + "/result.txt"); | machineLearnIns.setResultPath(outputPath + "log/" + modelType + "/result.txt"); | ||||
| break; | break; | ||||
| } | } | ||||
| case Constant.ML_VideoClassification: { | case Constant.ML_VideoClassification: { | ||||
| machineLearnIns.setResultPath(outputPath); | |||||
| machineLearnIns.setRunHistoryPath(output2.get("path").replace("{{workflow.name}}", (String) metadata.get("name")).substring("data/".length()) + "/log"); | |||||
| machineLearnIns.setResultPath(outputStr); | |||||
| machineLearnIns.setRunHistoryPath(outputStr.substring("data/".length()) + "/log"); | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| @@ -225,7 +238,7 @@ public class MachineLearnServiceImpl implements MachineLearnService { | |||||
| resourceOccupyService.startDeduce(computingResourceId, 1, Constant.TaskType_ML, id, machineLearnIns.getId(), null, machineLearn.getName(), null, null); | resourceOccupyService.startDeduce(computingResourceId, 1, Constant.TaskType_ML, id, machineLearnIns.getId(), null, machineLearn.getName(), null, null); | ||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException(e); | |||||
| throw new RuntimeException(e.getMessage()); | |||||
| } | } | ||||
| return "执行成功"; | return "执行成功"; | ||||
| } | } | ||||
| @@ -245,7 +245,7 @@ public class ModelDependencyServiceImpl implements ModelDependencyService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public String removeById(Integer id) { | |||||
| public String removeById(Integer id) throws Exception { | |||||
| ModelDependency modelDependency = this.modelDependencyDao.queryById(id); | ModelDependency modelDependency = this.modelDependencyDao.queryById(id); | ||||
| if (modelDependency == null){ | if (modelDependency == null){ | ||||
| return "模型依赖信息不存在"; | return "模型依赖信息不存在"; | ||||
| @@ -256,7 +256,7 @@ public class ModelDependencyServiceImpl implements ModelDependencyService { | |||||
| String username = loginUser.getUsername(); | String username = loginUser.getUsername(); | ||||
| String createdBy = modelDependency.getCreateBy(); | String createdBy = modelDependency.getCreateBy(); | ||||
| if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | ||||
| return "无权限删除"; | |||||
| throw new Exception("无权限删除"); | |||||
| } | } | ||||
| modelDependency.setState(0); | modelDependency.setState(0); | ||||
| @@ -112,6 +112,10 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| String gitendpoint; | String gitendpoint; | ||||
| @Value("${git.cloneEndpoint}") | @Value("${git.cloneEndpoint}") | ||||
| String gitCloneEndpoint; | String gitCloneEndpoint; | ||||
| @Value("${git.cloneEndpointIp}") | |||||
| String gitCloneEndpointIp; | |||||
| @Value("${git.projectModelId}") | |||||
| Integer projectModelId; | |||||
| @Value("${git.localPath}") | @Value("${git.localPath}") | ||||
| String localPath; | String localPath; | ||||
| @Value("${minio.accessKey}") | @Value("${minio.accessKey}") | ||||
| @@ -578,7 +582,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| ModelDependency1 modelDependency = new ModelDependency1(); | ModelDependency1 modelDependency = new ModelDependency1(); | ||||
| List<ModelDependency1> oldModelDependencys = modelDependency1Dao.queryModelDependency(modelsVo.getName(), null, gitLinkUsername); | List<ModelDependency1> oldModelDependencys = modelDependency1Dao.queryModelDependency(modelsVo.getName(), null, gitLinkUsername); | ||||
| if (oldModelDependencys != null && !oldModelDependencys.isEmpty()) { | if (oldModelDependencys != null && !oldModelDependencys.isEmpty()) { | ||||
| throw new Exception("创建模型失败:项目名称已被使用."); | |||||
| throw new RuntimeException("创建模型失败:项目名称已被使用"); | |||||
| } | } | ||||
| //新建模型 | //新建模型 | ||||
| @@ -589,13 +593,13 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| gitProjectVo.setDescription(modelsVo.getDescription()); | gitProjectVo.setDescription(modelsVo.getDescription()); | ||||
| gitProjectVo.setPrivate(!modelsVo.getIsPublic()); | gitProjectVo.setPrivate(!modelsVo.getIsPublic()); | ||||
| gitProjectVo.setUserId(userId); | gitProjectVo.setUserId(userId); | ||||
| gitProjectVo.setProjectCategoryId(Constant.Git_Category_Id); | |||||
| gitProjectVo.setProjectCategoryId(projectModelId); | |||||
| // 创建项目 | // 创建项目 | ||||
| Map project = gitService.createProject(token, gitProjectVo); | Map project = gitService.createProject(token, gitProjectVo); | ||||
| Integer gitlinIid = (Integer) project.get("id"); | Integer gitlinIid = (Integer) project.get("id"); | ||||
| if (gitlinIid == null) { | if (gitlinIid == null) { | ||||
| throw new Exception("创建模型失败:" + project.get("message")); | |||||
| throw new RuntimeException("创建模型失败:" + project.get("message")); | |||||
| } | } | ||||
| String branchName = modelsVo.getVersion(); | String branchName = modelsVo.getVersion(); | ||||
| @@ -632,9 +636,10 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| modelMetaVo.setCreateBy(String.valueOf(StringUtils.isNotEmpty((String) userInfo.get("nickname")) ? userInfo.get("nickname") : userInfo.get("login"))); | modelMetaVo.setCreateBy(String.valueOf(StringUtils.isNotEmpty((String) userInfo.get("nickname")) ? userInfo.get("nickname") : userInfo.get("login"))); | ||||
| modelMetaVo.setCreateTime(DateUtils.getTime()); | modelMetaVo.setCreateTime(DateUtils.getTime()); | ||||
| modelMetaVo.setUpdateTime(DateUtils.getTime()); | modelMetaVo.setUpdateTime(DateUtils.getTime()); | ||||
| String projectUrlIp = gitCloneEndpointIp + "/" + owner + "/" + repositoryName + ".git"; | |||||
| modelMetaVo.setUsage("<pre><code>" + | modelMetaVo.setUsage("<pre><code>" + | ||||
| "# 克隆模型配置文件与存储参数到本地\n" + | "# 克隆模型配置文件与存储参数到本地\n" + | ||||
| "git clone -b " + branchName + " " + projectUrl + "\n" + | |||||
| "git clone -b " + branchName + " " + projectUrlIp + "\n" + | |||||
| "# 远程拉取配置文件\n" + | "# 远程拉取配置文件\n" + | ||||
| "dvc pull\n" + | "dvc pull\n" + | ||||
| "</code></pre>"); | "</code></pre>"); | ||||
| @@ -678,7 +683,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| dvcUtils.dvcPush(rootPath); | dvcUtils.dvcPush(rootPath); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage(), e); | logger.error(e.getMessage(), e); | ||||
| throw new RuntimeException(e); | |||||
| throw new RuntimeException(e.getMessage()); | |||||
| } | } | ||||
| return null; | return null; | ||||
| }); | }); | ||||
| @@ -686,7 +691,7 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| return "新增模型成功"; | return "新增模型成功"; | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage()); | logger.error(e.getMessage()); | ||||
| throw new RuntimeException(e); | |||||
| throw new RuntimeException(e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -931,55 +936,45 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| String ci4sUsername = loginUser.getUsername(); | String ci4sUsername = loginUser.getUsername(); | ||||
| String gitLinkPassword = loginUser.getSysUser().getOriginPassword(); | String gitLinkPassword = loginUser.getSysUser().getOriginPassword(); | ||||
| Map<String, Object> userInfo = getUserInfo(ci4sUsername, gitLinkPassword); | Map<String, Object> userInfo = getUserInfo(ci4sUsername, gitLinkPassword); | ||||
| String token = (String) userInfo.get("token"); | String token = (String) userInfo.get("token"); | ||||
| String login = (String) userInfo.get("login"); | |||||
| //拼接查询url | |||||
| String modelTagName = modelsVo.getModelTag(); | |||||
| String modelTypeName = modelsVo.getModelType(); | |||||
| String url = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage"; | |||||
| String name = modelsVo.getName(); | |||||
| if (StringUtils.isNotEmpty(name)) { | |||||
| url = url + "&search=" + name; | |||||
| List<ModelsVo> collect = new ArrayList<>(); | |||||
| for (int i = 1; ; i++) { | |||||
| List<Map<String, Object>> projects = gitService.PersonalQueryGitByPage(token, login, modelsVo.getName(), i); | |||||
| if (projects.isEmpty()) { | |||||
| break; | |||||
| } else { | |||||
| List<ModelsVo> collecti = convert(projects, Constant.Topic_model, modelsVo.getModelTag(), modelsVo.getModelType()); | |||||
| collect.addAll(collecti); | |||||
| } | |||||
| } | } | ||||
| String req = httpUtils.sendGetWithToken(url, null, token); | |||||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||||
| List<ModelsVo> collect = convert(projects, Constant.Topic_model, modelTagName, modelTypeName); | |||||
| List<ModelsVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | |||||
| List<ModelsVo> result = collect.stream().sorted(Comparator.comparing(ModelsVo::getPraisesCount).reversed()).skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | |||||
| collect(Collectors.toList()); | collect(Collectors.toList()); | ||||
| return new PageImpl<>(result, pageRequest, collect.size()); | return new PageImpl<>(result, pageRequest, collect.size()); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public Page<ModelsVo> newPubilcQueryByPage(ModelsVo modelsVo, PageRequest pageRequest) throws Exception { | public Page<ModelsVo> newPubilcQueryByPage(ModelsVo modelsVo, PageRequest pageRequest) throws Exception { | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| String ci4sUsername = loginUser.getUsername(); | String ci4sUsername = loginUser.getUsername(); | ||||
| String gitLinkPassword = loginUser.getSysUser().getOriginPassword(); | String gitLinkPassword = loginUser.getSysUser().getOriginPassword(); | ||||
| Map<String, Object> userInfo = getUserInfo(ci4sUsername, gitLinkPassword); | Map<String, Object> userInfo = getUserInfo(ci4sUsername, gitLinkPassword); | ||||
| String token = (String) userInfo.get("token"); | String token = (String) userInfo.get("token"); | ||||
| String modelTagName = modelsVo.getModelTag(); | |||||
| String modelTypeName = modelsVo.getModelType(); | |||||
| //拼接查询url | |||||
| String url = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id; | |||||
| String name = modelsVo.getName(); | |||||
| if (StringUtils.isNotEmpty(name)) { | |||||
| url = url + "&search=" + name; | |||||
| List<ModelsVo> collect = new ArrayList<>(); | |||||
| for (int i = 1; ; i++) { | |||||
| List<Map<String, Object>> projects = gitService.PubilcQueryGitByPage(token, modelsVo.getName(), i, projectModelId); | |||||
| if (projects.isEmpty()) { | |||||
| break; | |||||
| } else { | |||||
| List<ModelsVo> collecti = convert(projects, Constant.Topic_model, modelsVo.getModelTag(), modelsVo.getModelType()); | |||||
| collect.addAll(collecti); | |||||
| } | |||||
| } | } | ||||
| String req = httpUtils.sendGetWithToken(url, null, token); | |||||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||||
| List<ModelsVo> collect = convert(projects, Constant.Topic_model, modelTagName, modelTypeName); | |||||
| List<ModelsVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | |||||
| List<ModelsVo> result = collect.stream().sorted(Comparator.comparing(ModelsVo::getPraisesCount).reversed()).skip((long) pageRequest.getPageNumber() * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | |||||
| collect(Collectors.toList()); | collect(Collectors.toList()); | ||||
| return new PageImpl<>(result, pageRequest, collect.size()); | return new PageImpl<>(result, pageRequest, collect.size()); | ||||
| } | } | ||||
| @@ -194,7 +194,7 @@ public class ModelsVersionServiceImpl implements ModelsVersionService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public Map<Integer, String> deleteModelsVersion(Integer modelsId, String version) throws IOException { | |||||
| public Map<Integer, String> deleteModelsVersion(Integer modelsId, String version) throws Exception { | |||||
| Map<Integer, String> results = new HashMap<Integer,String>(); | Map<Integer, String> results = new HashMap<Integer,String>(); | ||||
| // 根据模型ID和版本查询所有模型版本 | // 根据模型ID和版本查询所有模型版本 | ||||
| List<ModelsVersion> versions = this.modelsVersionDao.queryAllByModelsVersion(modelsId, version); | List<ModelsVersion> versions = this.modelsVersionDao.queryAllByModelsVersion(modelsId, version); | ||||
| @@ -73,6 +73,11 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| String gitendpoint; | String gitendpoint; | ||||
| @Value("${git.cloneEndpoint}") | @Value("${git.cloneEndpoint}") | ||||
| String gitCloneEndpoint; | String gitCloneEndpoint; | ||||
| @Value("${git.cloneEndpointIp}") | |||||
| String gitCloneEndpointIp; | |||||
| @Value("${git.projectDatasetId}") | |||||
| Integer projectDatasetId; | |||||
| @Value("${minio.dataReleaseBucketName}") | @Value("${minio.dataReleaseBucketName}") | ||||
| private String bucketName; | private String bucketName; | ||||
| @Value("${git.localPath}") | @Value("${git.localPath}") | ||||
| @@ -111,7 +116,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| gitProjectVo.setDescription(datasetVo.getDescription()); | gitProjectVo.setDescription(datasetVo.getDescription()); | ||||
| gitProjectVo.setPrivate(!datasetVo.getIsPublic()); | gitProjectVo.setPrivate(!datasetVo.getIsPublic()); | ||||
| gitProjectVo.setUserId(userId); | gitProjectVo.setUserId(userId); | ||||
| gitProjectVo.setProjectCategoryId(Constant.Git_Category_Id); | |||||
| gitProjectVo.setProjectCategoryId(projectDatasetId); | |||||
| // 创建项目 | // 创建项目 | ||||
| Map project = gitService.createProject(token, gitProjectVo); | Map project = gitService.createProject(token, gitProjectVo); | ||||
| Integer gitlinIid = (Integer) project.get("id"); | Integer gitlinIid = (Integer) project.get("id"); | ||||
| @@ -183,7 +188,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| dvcUtils.dvcPush(localPath); | dvcUtils.dvcPush(localPath); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error(e.getMessage(), e); | logger.error(e.getMessage(), e); | ||||
| throw new RuntimeException(e); | |||||
| throw new RuntimeException(e.getMessage()); | |||||
| } | } | ||||
| return null; | return null; | ||||
| }); | }); | ||||
| @@ -260,9 +265,10 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| // 拼接生产的元数据后写入yaml文件 | // 拼接生产的元数据后写入yaml文件 | ||||
| datasetVo.setCreateBy(String.valueOf(StringUtils.isNotEmpty((String) userInfo.get("nickname")) ? userInfo.get("nickname") : userInfo.get("login"))); | datasetVo.setCreateBy(String.valueOf(StringUtils.isNotEmpty((String) userInfo.get("nickname")) ? userInfo.get("nickname") : userInfo.get("login"))); | ||||
| datasetVo.setUpdateTime(DateUtils.getTime()); | datasetVo.setUpdateTime(DateUtils.getTime()); | ||||
| String projectUrlIp = gitCloneEndpointIp + "/" + owner + "/" + repositoryName + ".git"; | |||||
| datasetVo.setUsage("<pre><code>" + | datasetVo.setUsage("<pre><code>" + | ||||
| "# 克隆数据集配置文件与存储参数到本地\n" + | "# 克隆数据集配置文件与存储参数到本地\n" + | ||||
| "git clone -b " + branchName + " " + projectUrl + "\n" + | |||||
| "git clone -b " + branchName + " " + projectUrlIp + "\n" + | |||||
| "# 远程拉取配置文件\n" + | "# 远程拉取配置文件\n" + | ||||
| "dvc pull\n" + | "dvc pull\n" + | ||||
| "</code></pre>"); | "</code></pre>"); | ||||
| @@ -321,19 +327,18 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| String ci4sUsername = loginUser.getUsername(); | String ci4sUsername = loginUser.getUsername(); | ||||
| String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); | String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); | ||||
| Map<String, Object> userInfo = JsonUtils.jsonToMap(userReq); | Map<String, Object> userInfo = JsonUtils.jsonToMap(userReq); | ||||
| // 拼接查询url | |||||
| String url = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage"; | |||||
| String name = dataset.getName(); | |||||
| if (StringUtils.isNotEmpty(name)) { | |||||
| url = url + "&search=" + name; | |||||
| String login = (String) userInfo.get("login"); | |||||
| List<NewDatasetVo> collect = new ArrayList<>(); | |||||
| for (int i = 1; ; i++) { | |||||
| List<Map<String, Object>> projects = gitService.PersonalQueryGitByPage(token, login, dataset.getName(), i); | |||||
| if (projects.isEmpty()) { | |||||
| break; | |||||
| } else { | |||||
| List<NewDatasetVo> collecti = convert(projects, Constant.Topic_Dataset, dataset.getDataTag(), dataset.getDataType()); | |||||
| collect.addAll(collecti); | |||||
| } | |||||
| } | } | ||||
| String req = httpUtils.sendGetWithToken(url, null, token); | |||||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||||
| List<NewDatasetVo> collect = convert(projects, Constant.Topic_Dataset, dataset.getDataTag(), dataset.getDataType()); | |||||
| List<NewDatasetVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | |||||
| List<NewDatasetVo> result = collect.stream().sorted(Comparator.comparing(NewDatasetVo::getPraisesCount).reversed()).skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | |||||
| collect(Collectors.toList()); | collect(Collectors.toList()); | ||||
| return new PageImpl<>(result, pageRequest, collect.size()); | return new PageImpl<>(result, pageRequest, collect.size()); | ||||
| } | } | ||||
| @@ -341,22 +346,18 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| @Override | @Override | ||||
| public Page<NewDatasetVo> newPubilcQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception { | public Page<NewDatasetVo> newPubilcQueryByPage(Dataset dataset, PageRequest pageRequest) throws Exception { | ||||
| String token = gitService.checkoutToken(); | String token = gitService.checkoutToken(); | ||||
| // 拼接查询url | |||||
| String url = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id; | |||||
| String name = dataset.getName(); | |||||
| if (StringUtils.isNotEmpty(name)) { | |||||
| url = url + "&search=" + name; | |||||
| } | |||||
| String req = httpUtils.sendGetWithToken(url, null, token); | |||||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||||
| if (projects == null) { | |||||
| return new PageImpl<>(new ArrayList<>(), pageRequest, 0); | |||||
| List<NewDatasetVo> collect = new ArrayList<>(); | |||||
| for (int i = 1; ; i++) { | |||||
| List<Map<String, Object>> projects = gitService.PubilcQueryGitByPage(token, dataset.getName(), i, projectDatasetId); | |||||
| if (projects.isEmpty()) { | |||||
| break; | |||||
| } else { | |||||
| List<NewDatasetVo> collecti = convert(projects, Constant.Topic_Dataset, dataset.getDataTag(), dataset.getDataType()); | |||||
| collect.addAll(collecti); | |||||
| } | |||||
| } | } | ||||
| List<NewDatasetVo> collect = convert(projects, Constant.Topic_Dataset, dataset.getDataTag(), dataset.getDataType()); | |||||
| List<NewDatasetVo> result = collect.stream().skip((pageRequest.getPageNumber()) * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | |||||
| List<NewDatasetVo> result = collect.stream().sorted(Comparator.comparing(NewDatasetVo::getPraisesCount).reversed()).skip((long) pageRequest.getPageNumber() * pageRequest.getPageSize()).limit(pageRequest.getPageSize()). | |||||
| collect(Collectors.toList()); | collect(Collectors.toList()); | ||||
| return new PageImpl<>(result, pageRequest, collect.size()); | return new PageImpl<>(result, pageRequest, collect.size()); | ||||
| } | } | ||||
| @@ -646,7 +647,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| @Override | @Override | ||||
| public List<NewDatasetVo> convert(List<Map<String, Object>> lst, String datasetTopic, String datasetTagName, String datasetTypeName) { | public List<NewDatasetVo> convert(List<Map<String, Object>> lst, String datasetTopic, String datasetTagName, String datasetTypeName) { | ||||
| if (lst != null && lst.size() > 0) { | |||||
| if (lst != null && !lst.isEmpty()) { | |||||
| List<NewDatasetVo> result = new ArrayList<>(); | List<NewDatasetVo> result = new ArrayList<>(); | ||||
| List<NewDatasetVo> newDatasetVos = ConvertUtil.convertListMapToObjectList(lst, NewDatasetVo.class); | List<NewDatasetVo> newDatasetVos = ConvertUtil.convertListMapToObjectList(lst, NewDatasetVo.class); | ||||
| @@ -674,7 +675,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| } | } | ||||
| } | } | ||||
| if (datasetTopicName != null && datasetTopic.equals(datasetTopicName)) { | |||||
| if (datasetTopic.equals(datasetTopicName)) { | |||||
| if (StringUtils.isNotEmpty(datasetTagName) && !datasetTagName.toLowerCase().equals(datasetTag)) { | if (StringUtils.isNotEmpty(datasetTagName) && !datasetTagName.toLowerCase().equals(datasetTag)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| @@ -710,7 +711,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||||
| sourceMap.remove("preprocess_code"); | sourceMap.remove("preprocess_code"); | ||||
| datasetVo.setTrainTask((HashMap<String, Object>) sourceMap); | datasetVo.setTrainTask((HashMap<String, Object>) sourceMap); | ||||
| datasetVo.setProcessingCode((HashMap<String, Object>) preprocessCode); | datasetVo.setProcessingCode((HashMap<String, Object>) preprocessCode); | ||||
| datasetTempStorage.setState(0); | |||||
| datasetTempStorage.setState(Constant.State_invalid); | |||||
| datasetTempStorageService.update(datasetTempStorage); | datasetTempStorageService.update(datasetTempStorage); | ||||
| } | } | ||||
| return datasetVo; | return datasetVo; | ||||
| @@ -23,6 +23,7 @@ import java.io.IOException; | |||||
| import java.net.URLEncoder; | import java.net.URLEncoder; | ||||
| import java.nio.file.Path; | import java.nio.file.Path; | ||||
| import java.nio.file.Paths; | import java.nio.file.Paths; | ||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| @@ -69,6 +70,18 @@ public class RayInsServiceImpl implements RayInsService { | |||||
| return rayIns; | return rayIns; | ||||
| } | } | ||||
| @Override | |||||
| public RayIns update(RayIns rayIns) { | |||||
| rayIns.setUpdateTime(new Date()); | |||||
| rayIns = queryStatusFromArgo(rayIns); | |||||
| rayInsDao.update(rayIns); | |||||
| updateRayStatus(rayIns.getRayId()); | |||||
| if (Constant.Failed.equals(rayIns.getStatus()) || Constant.Succeeded.equals(rayIns.getStatus())) { | |||||
| resourceOccupyService.endDeduce(Constant.TaskType_Ray, null, rayIns.getId(), null, null); | |||||
| } | |||||
| return rayIns; | |||||
| } | |||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| public String deleteById(Long id) { | public String deleteById(Long id) { | ||||
| @@ -162,6 +175,9 @@ public class RayInsServiceImpl implements RayInsService { | |||||
| // 如果值不等于 Succeeded,则赋值为 Failed | // 如果值不等于 Succeeded,则赋值为 Failed | ||||
| if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { | if (!StringUtils.equals(Constant.Succeeded, phaseValue)) { | ||||
| innerMap.put("phase", Constant.Failed); | innerMap.put("phase", Constant.Failed); | ||||
| Calendar calendar = Calendar.getInstance(); | |||||
| calendar.add(Calendar.HOUR_OF_DAY, -8); | |||||
| innerMap.put("finishedAt", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").format(calendar.getTime())); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -63,7 +63,7 @@ public class RayServiceImpl implements RayService { | |||||
| @Override | @Override | ||||
| public Ray save(RayVo rayVo) throws Exception { | public Ray save(RayVo rayVo) throws Exception { | ||||
| if (rayVo.getName().length() >= 64) { | |||||
| if (rayVo.getName().length() > 64) { | |||||
| throw new RuntimeException("实验名称大于最大长度"); | throw new RuntimeException("实验名称大于最大长度"); | ||||
| } | } | ||||
| Ray rayByName = rayDao.getRayByName(rayVo.getName()); | Ray rayByName = rayDao.getRayByName(rayVo.getName()); | ||||
| @@ -137,15 +137,19 @@ public class RayServiceImpl implements RayService { | |||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| public String delete(Long id) { | |||||
| public String delete(Long id) throws Exception { | |||||
| Ray ray = rayDao.getRayById(id); | Ray ray = rayDao.getRayById(id); | ||||
| if (ray == null) { | if (ray == null) { | ||||
| throw new RuntimeException("实验不存在"); | |||||
| throw new Exception("实验不存在"); | |||||
| } | } | ||||
| String username = SecurityUtils.getLoginUser().getUsername(); | String username = SecurityUtils.getLoginUser().getUsername(); | ||||
| String createBy = ray.getCreateBy(); | String createBy = ray.getCreateBy(); | ||||
| if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | if (!(StringUtils.equals(username, "admin") || StringUtils.equals(username, createBy))) { | ||||
| throw new RuntimeException("无权限删除该实验"); | |||||
| throw new Exception("无权限删除该实验"); | |||||
| } | |||||
| List<RayIns> insList = rayInsDao.getByRayId(id); | |||||
| if (!insList.isEmpty()) { | |||||
| throw new Exception("该实验存在实例,无法删除"); | |||||
| } | } | ||||
| ray.setState(Constant.State_invalid); | ray.setState(Constant.State_invalid); | ||||
| resourceOccupyService.deleteTaskState(Constant.TaskType_Ray, id, null); | resourceOccupyService.deleteTaskState(Constant.TaskType_Ray, id, null); | ||||
| @@ -175,7 +179,12 @@ public class RayServiceImpl implements RayService { | |||||
| if (convertRes == null || StringUtils.isEmpty(convertRes)) { | if (convertRes == null || StringUtils.isEmpty(convertRes)) { | ||||
| throw new RuntimeException("转换流水线失败"); | throw new RuntimeException("转换流水线失败"); | ||||
| } | } | ||||
| Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); | ||||
| if (converMap.get("data") == null) { | |||||
| throw new RuntimeException("转换流水线失败"); | |||||
| } | |||||
| // 组装运行接口json | // 组装运行接口json | ||||
| Map<String, Object> output = (Map<String, Object>) converMap.get("output"); | Map<String, Object> output = (Map<String, Object>) converMap.get("output"); | ||||
| Map<String, Object> runReqMap = new HashMap<>(); | Map<String, Object> runReqMap = new HashMap<>(); | ||||
| @@ -214,7 +223,7 @@ public class RayServiceImpl implements RayService { | |||||
| // 记录开始扣除积分 | // 记录开始扣除积分 | ||||
| resourceOccupyService.startDeduce(ray.getComputingResourceId(), 1, Constant.TaskType_Ray, id, rayIns.getId(), null, ray.getName(), null, null); | resourceOccupyService.startDeduce(ray.getComputingResourceId(), 1, Constant.TaskType_Ray, id, rayIns.getId(), null, ray.getName(), null, null); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new RuntimeException(e); | |||||
| throw new RuntimeException(e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| return "执行成功"; | return "执行成功"; | ||||
| @@ -15,6 +15,7 @@ import org.springframework.stereotype.Service; | |||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.math.BigDecimal; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -113,9 +114,10 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService { | |||||
| } | } | ||||
| Double hours = (double) timeDifferenceMillis / (1000 * 60 * 60); | Double hours = (double) timeDifferenceMillis / (1000 * 60 * 60); | ||||
| Double deduceCredit = resourceOccupy.getCreditPerHour() * hours; | Double deduceCredit = resourceOccupy.getCreditPerHour() * hours; | ||||
| deduceCredit = deduceCredit > 0 ? deduceCredit : 0.01; | |||||
| resourceOccupyDao.deduceCredit(deduceCredit, resourceOccupy.getUserId()); | resourceOccupyDao.deduceCredit(deduceCredit, resourceOccupy.getUserId()); | ||||
| resourceOccupy.setDeduceCredit(resourceOccupy.getDeduceCredit() + deduceCredit); | |||||
| resourceOccupy.setDeduceCredit(new BigDecimal(resourceOccupy.getDeduceCredit() + deduceCredit).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); | |||||
| resourceOccupy.setDeduceLastTime(now); | resourceOccupy.setDeduceLastTime(now); | ||||
| resourceOccupy.setState(Constant.State_valid); | resourceOccupy.setState(Constant.State_valid); | ||||
| resourceOccupyDao.edit(resourceOccupy); | resourceOccupyDao.edit(resourceOccupy); | ||||
| @@ -132,45 +134,51 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService { | |||||
| public Map<String, Double> queryCredit() { | public Map<String, Double> queryCredit() { | ||||
| Double userCredit = resourceOccupyDao.getUserCredit(SecurityUtils.getLoginUser().getUserid()); | Double userCredit = resourceOccupyDao.getUserCredit(SecurityUtils.getLoginUser().getUserid()); | ||||
| Double deduceCredit = resourceOccupyDao.getDeduceCredit(SecurityUtils.getLoginUser().getUserid()); | Double deduceCredit = resourceOccupyDao.getDeduceCredit(SecurityUtils.getLoginUser().getUserid()); | ||||
| deduceCredit = deduceCredit != null ? deduceCredit : 0; | |||||
| HashMap<String, Double> result = new HashMap<>(); | HashMap<String, Double> result = new HashMap<>(); | ||||
| result.put("userCredit", userCredit); | |||||
| result.put("deduceCredit", deduceCredit); | |||||
| result.put("userCredit", new BigDecimal(userCredit).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); | |||||
| result.put("deduceCredit", new BigDecimal(deduceCredit).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); | |||||
| return result; | return result; | ||||
| } | } | ||||
| @Override | @Override | ||||
| @Transactional | @Transactional | ||||
| public void update(String taskType, Long taskId, Long taskInsId, Integer computingResourceId, Integer replicas) { | |||||
| ResourceOccupy resourceOccupy = resourceOccupyDao.getResourceOccupyByTask(taskType, taskId, taskInsId, null).get(0); | |||||
| ComputingResource oldComputingResource = computingResourceDao.queryById(resourceOccupy.getComputingResourceId()); | |||||
| ComputingResource computingResource = computingResourceDao.queryById(computingResourceId); | |||||
| public void update(String taskType, Long taskId, Long taskInsId, Integer computingResourceId, Integer replicas, String taskName) { | |||||
| List<ResourceOccupy> resourceOccupyList = resourceOccupyDao.getResourceOccupyByTask(taskType, taskId, taskInsId, null); | |||||
| if (resourceOccupyList.isEmpty()) { | |||||
| startDeduce(computingResourceId, replicas, taskType, taskId, taskInsId, null, taskName, null, Constant.State_building); | |||||
| } else { | |||||
| ResourceOccupy resourceOccupy = resourceOccupyList.get(0); | |||||
| ComputingResource oldComputingResource = computingResourceDao.queryById(resourceOccupy.getComputingResourceId()); | |||||
| ComputingResource computingResource = computingResourceDao.queryById(computingResourceId); | |||||
| int occupy_num = (int) (resourceOccupy.getCreditPerHour() / oldComputingResource.getCreditPerHour()); | |||||
| int occupy_num = (int) (resourceOccupy.getCreditPerHour() / oldComputingResource.getCreditPerHour()); | |||||
| if (Constant.Computing_Resource_GPU.equals(oldComputingResource.getComputingResource())) { | |||||
| resourceOccupyDao.updateUnUsed(oldComputingResource.getResourceId(), oldComputingResource.getGpuNums() * occupy_num); | |||||
| } else { | |||||
| resourceOccupyDao.updateUnUsed(oldComputingResource.getResourceId(), computingResource.getCpuCores() * occupy_num); | |||||
| } | |||||
| if (Constant.Computing_Resource_GPU.equals(oldComputingResource.getComputingResource())) { | |||||
| resourceOccupyDao.updateUnUsed(oldComputingResource.getResourceId(), oldComputingResource.getGpuNums() * occupy_num); | |||||
| } else { | |||||
| resourceOccupyDao.updateUnUsed(oldComputingResource.getResourceId(), computingResource.getCpuCores() * occupy_num); | |||||
| } | |||||
| if (Constant.Computing_Resource_GPU.equals(computingResource.getComputingResource())) { | |||||
| resourceOccupyDao.updateUsed(computingResource.getResourceId(), computingResource.getGpuNums() * replicas); | |||||
| } else { | |||||
| resourceOccupyDao.updateUsed(computingResource.getResourceId(), computingResource.getCpuCores() * replicas); | |||||
| } | |||||
| if (Constant.Computing_Resource_GPU.equals(computingResource.getComputingResource())) { | |||||
| resourceOccupyDao.updateUsed(computingResource.getResourceId(), computingResource.getGpuNums() * replicas); | |||||
| } else { | |||||
| resourceOccupyDao.updateUsed(computingResource.getResourceId(), computingResource.getCpuCores() * replicas); | |||||
| } | |||||
| if (replicas > 1) { | |||||
| resourceOccupy.setDescription(replicas + " * [" + computingResource.getDescription() + "]"); | |||||
| } else { | |||||
| resourceOccupy.setDescription(computingResource.getDescription()); | |||||
| if (replicas > 1) { | |||||
| resourceOccupy.setDescription(replicas + " * [" + computingResource.getDescription() + "]"); | |||||
| } else { | |||||
| resourceOccupy.setDescription(computingResource.getDescription()); | |||||
| } | |||||
| resourceOccupy.setCreditPerHour(computingResource.getCreditPerHour() * replicas); | |||||
| resourceOccupy.setComputingResourceId(computingResourceId); | |||||
| resourceOccupyDao.edit(resourceOccupy); | |||||
| } | } | ||||
| resourceOccupy.setCreditPerHour(computingResource.getCreditPerHour() * replicas); | |||||
| resourceOccupy.setComputingResourceId(computingResourceId); | |||||
| resourceOccupyDao.edit(resourceOccupy); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void deleteTaskState(String taskType, Long taskId, Long taskInsId) { | public void deleteTaskState(String taskType, Long taskId, Long taskInsId) { | ||||
| resourceOccupyDao.deleteTaskState(taskType,taskId,taskInsId); | |||||
| resourceOccupyDao.deleteTaskState(taskType, taskId, taskInsId); | |||||
| } | } | ||||
| } | } | ||||
| @@ -191,7 +191,7 @@ public class ServiceServiceImpl implements ServiceService { | |||||
| serviceVersionVo.setDocPath(baseUrl + "/redoc"); | serviceVersionVo.setDocPath(baseUrl + "/redoc"); | ||||
| serviceVersionVo.setPagePath(baseUrl + "/gradio"); | serviceVersionVo.setPagePath(baseUrl + "/gradio"); | ||||
| } catch (MalformedURLException e) { | } catch (MalformedURLException e) { | ||||
| throw new RuntimeException(e); | |||||
| throw new RuntimeException(e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| return serviceVersionVo; | return serviceVersionVo; | ||||
| @@ -351,7 +351,7 @@ public class ServiceServiceImpl implements ServiceService { | |||||
| if (reRun) { | if (reRun) { | ||||
| resourceOccupyService.startDeduce(serviceVersion.getComputingResourceId(), serviceVersion.getReplicas(), Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), null, service.getServiceName(), null, Constant.State_building); | resourceOccupyService.startDeduce(serviceVersion.getComputingResourceId(), serviceVersion.getReplicas(), Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), null, service.getServiceName(), null, Constant.State_building); | ||||
| } else if (Constant.Running.equals(serviceVersionById.getRunState()) || Constant.Pending.equals(serviceVersionById.getRunState())) { | } else if (Constant.Running.equals(serviceVersionById.getRunState()) || Constant.Pending.equals(serviceVersionById.getRunState())) { | ||||
| resourceOccupyService.update(Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), serviceVersion.getComputingResourceId(), serviceVersion.getReplicas()); | |||||
| resourceOccupyService.update(Constant.TaskType_Service, serviceVersion.getServiceId(), serviceVersion.getId(), serviceVersion.getComputingResourceId(), serviceVersion.getReplicas(), service.getServiceName()); | |||||
| } | } | ||||
| return "修改成功"; | return "修改成功"; | ||||
| } else { | } else { | ||||
| @@ -8,6 +8,7 @@ import com.ruoyi.platform.service.TensorBoardService; | |||||
| import com.ruoyi.platform.utils.K8sClientUtil; | import com.ruoyi.platform.utils.K8sClientUtil; | ||||
| import com.ruoyi.platform.vo.FrameLogPathVo; | import com.ruoyi.platform.vo.FrameLogPathVo; | ||||
| import com.ruoyi.platform.vo.PodStatusVo; | import com.ruoyi.platform.vo.PodStatusVo; | ||||
| import com.ruoyi.system.api.constant.Constant; | |||||
| import com.ruoyi.system.api.model.LoginUser; | import com.ruoyi.system.api.model.LoginUser; | ||||
| import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -66,7 +67,7 @@ public class TensorBoardServiceImpl implements TensorBoardService { | |||||
| throw new Exception("存储路径为空"); | throw new Exception("存储路径为空"); | ||||
| } | } | ||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| String podName = loginUser.getUsername().toLowerCase()+"-"+frameLogPathVo.getPath().split("/")[1]+ "-tensorboard-pod"; | |||||
| String podName = loginUser.getUsername().toLowerCase() + "-" + frameLogPathVo.getPath().split("/")[1] + "-tensorboard-pod"; | |||||
| // Integer podPort = k8sClientUtil.createPodWithSubPath(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace()) ? "default" : frameLogPathVo.getNamespace(), port, mountPath, frameLogPathVo.getPath(), frameLogPathVo.getPvcName(), image); | // Integer podPort = k8sClientUtil.createPodWithSubPath(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace()) ? "default" : frameLogPathVo.getNamespace(), port, mountPath, frameLogPathVo.getPath(), frameLogPathVo.getPvcName(), image); | ||||
| Integer podPort = k8sClientUtil.createPodWithSubPath(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace()) ? "default" : frameLogPathVo.getNamespace(), port, mountPath, frameLogPathVo.getPath(), image); | Integer podPort = k8sClientUtil.createPodWithSubPath(podName, StringUtils.isEmpty(frameLogPathVo.getNamespace()) ? "default" : frameLogPathVo.getNamespace(), port, mountPath, frameLogPathVo.getPath(), image); | ||||
| @@ -80,10 +80,10 @@ public class WorkflowParamServiceImpl implements WorkflowParamService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public String removeById(Integer id) { | |||||
| public String removeById(Integer id) throws Exception { | |||||
| WorkflowParam workflowParam = this.workflowParamDao.queryById(id); | WorkflowParam workflowParam = this.workflowParamDao.queryById(id); | ||||
| if (workflowParam == null){ | if (workflowParam == null){ | ||||
| return "流水线参数不存在"; | |||||
| throw new Exception("流水线参数不存在"); | |||||
| } | } | ||||
| //判断权限,只有admin和创建者本身可以删除 | //判断权限,只有admin和创建者本身可以删除 | ||||
| @@ -93,7 +93,7 @@ public class WorkflowParamServiceImpl implements WorkflowParamService { | |||||
| String createdBy = workflowParam.getCreateBy(); | String createdBy = workflowParam.getCreateBy(); | ||||
| if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | if (!(StringUtils.equals(username,"admin") || StringUtils.equals(username,createdBy))){ | ||||
| return "无权限删除该流水线参数"; | |||||
| throw new Exception("无权限删除该流水线参数"); | |||||
| } | } | ||||
| workflowParam.setState(0); | workflowParam.setState(0); | ||||
| @@ -105,7 +105,7 @@ public class WorkflowServiceImpl implements WorkflowService { | |||||
| workflow.setUpdateBy(loginUser.getUsername()); | workflow.setUpdateBy(loginUser.getUsername()); | ||||
| workflow.setUpdateTime(new Date()); | workflow.setUpdateTime(new Date()); | ||||
| workflow.setCreateTime(new Date()); | workflow.setCreateTime(new Date()); | ||||
| workflow.setState(1); | |||||
| workflow.setState(Constant.State_valid); | |||||
| this.workflowDao.insert(workflow); | this.workflowDao.insert(workflow); | ||||
| saveAssetWorkFlow(workflow); | saveAssetWorkFlow(workflow); | ||||
| return workflow; | return workflow; | ||||
| @@ -163,7 +163,7 @@ public class WorkflowServiceImpl implements WorkflowService { | |||||
| if (experimentList != null && experimentList.size() > 0) { | if (experimentList != null && experimentList.size() > 0) { | ||||
| throw new Exception("该流水线存在实验,无法删除"); | throw new Exception("该流水线存在实验,无法删除"); | ||||
| } | } | ||||
| workflow.setState(0); | |||||
| workflow.setState(Constant.State_invalid); | |||||
| assetWorkflowDao.deleteByWorkFlowId(id); | assetWorkflowDao.deleteByWorkFlowId(id); | ||||
| return this.workflowDao.update(workflow) > 0 ? "删除成功" : "删除失败"; | return this.workflowDao.update(workflow) > 0 ? "删除成功" : "删除失败"; | ||||
| } | } | ||||
| @@ -180,12 +180,13 @@ public class WorkflowServiceImpl implements WorkflowService { | |||||
| Workflow workflow = this.queryById(id); | Workflow workflow = this.queryById(id); | ||||
| if (workflow != null) { | if (workflow != null) { | ||||
| try { | try { | ||||
| if (workflow.getName().length() >= 64) { | |||||
| Workflow duplicateWorkflow = new Workflow(); | |||||
| duplicateWorkflow.setName(workflow.getName() + "-copy-" + UUID.randomUUID().toString().substring(0, 6)); | |||||
| if (duplicateWorkflow.getName().length() > 64) { | |||||
| throw new RuntimeException("流水线名称大于最大长度"); | throw new RuntimeException("流水线名称大于最大长度"); | ||||
| } | } | ||||
| Workflow duplicateWorkflow = new Workflow(); | |||||
| duplicateWorkflow.setName(workflow.getName() + "-copy-" + UUID.randomUUID().toString().substring(0, 6)); | |||||
| String oldDag = workflow.getDag(); | String oldDag = workflow.getDag(); | ||||
| // 创建请求数据的Json(map) | // 创建请求数据的Json(map) | ||||
| Map<String, Object> requestData = new HashMap<>(); | Map<String, Object> requestData = new HashMap<>(); | ||||
| @@ -334,7 +335,7 @@ public class WorkflowServiceImpl implements WorkflowService { | |||||
| Map<String, Object> image = (Map<String, Object>) paramMap.get("--image"); | Map<String, Object> image = (Map<String, Object>) paramMap.get("--image"); | ||||
| saveImageWorkFlow((String) image.get("value"), workflowId, workflowName); | saveImageWorkFlow((String) image.get("value"), workflowId, workflowName); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| throw new Exception(e); | |||||
| throw new Exception(e.getMessage()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -4,16 +4,15 @@ import com.ruoyi.common.security.utils.SecurityUtils; | |||||
| import com.ruoyi.platform.domain.*; | import com.ruoyi.platform.domain.*; | ||||
| import com.ruoyi.platform.mapper.*; | import com.ruoyi.platform.mapper.*; | ||||
| import com.ruoyi.platform.service.*; | import com.ruoyi.platform.service.*; | ||||
| import com.ruoyi.platform.utils.JacksonUtil; | |||||
| import com.ruoyi.platform.utils.JsonUtils; | |||||
| import com.ruoyi.platform.utils.NewHttpUtils; | import com.ruoyi.platform.utils.NewHttpUtils; | ||||
| import com.ruoyi.platform.vo.ModelsVo; | import com.ruoyi.platform.vo.ModelsVo; | ||||
| import com.ruoyi.platform.vo.NewDatasetVo; | import com.ruoyi.platform.vo.NewDatasetVo; | ||||
| import com.ruoyi.system.api.constant.Constant; | import com.ruoyi.system.api.constant.Constant; | ||||
| import com.ruoyi.system.api.model.LoginUser; | import com.ruoyi.system.api.model.LoginUser; | ||||
| import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
| import org.springframework.data.domain.Page; | |||||
| import org.springframework.data.domain.PageRequest; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import redis.clients.jedis.Jedis; | |||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import java.util.HashMap; | import java.util.HashMap; | ||||
| @@ -36,20 +35,13 @@ public class WorkspaceServiceImpl implements WorkspaceService { | |||||
| @Resource | @Resource | ||||
| private ComponentDao componentDao; | private ComponentDao componentDao; | ||||
| @Resource | @Resource | ||||
| private GitService gitService; | |||||
| private CodeConfigDao codeConfigDao; | |||||
| @Resource | @Resource | ||||
| private NewDatasetService newDatasetService; | private NewDatasetService newDatasetService; | ||||
| @Resource | @Resource | ||||
| private ModelsService modelsService; | private ModelsService modelsService; | ||||
| @Resource | @Resource | ||||
| private NewHttpUtils httpUtils; | |||||
| @Value("${git.endpoint}") | |||||
| String gitendpoint; | |||||
| @Value("${spring.redis.host}") | |||||
| private String redisHost; | |||||
| @Value("${spring.redis.port}") | |||||
| private Integer redisPort; | |||||
| private ServiceDao serviceDao; | |||||
| @Override | @Override | ||||
| public Map<String, Object> getOverview() { | public Map<String, Object> getOverview() { | ||||
| @@ -87,41 +79,32 @@ public class WorkspaceServiceImpl implements WorkspaceService { | |||||
| @Override | @Override | ||||
| public Map<String, Integer> getAssetCount(Boolean isPublic) throws Exception { | public Map<String, Integer> getAssetCount(Boolean isPublic) throws Exception { | ||||
| Map<String, Integer> assetCountMap = new HashMap<>(); | Map<String, Integer> assetCountMap = new HashMap<>(); | ||||
| String token = gitService.checkoutToken(); | |||||
| int availableRange = isPublic ? Constant.Image_Type_Pub : Constant.Image_Type_Pri; | int availableRange = isPublic ? Constant.Image_Type_Pub : Constant.Image_Type_Pri; | ||||
| String datasetUrl; | |||||
| String modelUrl; | |||||
| Page<NewDatasetVo> newDatasetVos; | |||||
| Page<ModelsVo> modelsVos; | |||||
| if (isPublic) { | if (isPublic) { | ||||
| // 数据集 | // 数据集 | ||||
| datasetUrl = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id; | |||||
| newDatasetVos = newDatasetService.newPubilcQueryByPage(new Dataset(), PageRequest.of(0, Integer.MAX_VALUE)); | |||||
| // 模型 | // 模型 | ||||
| modelUrl = gitendpoint + "/api/projects.json?sort_direction=updated_on&sort_by=desc&category_id=" + Constant.Git_Category_Id; | |||||
| modelsVos = modelsService.newPubilcQueryByPage(new ModelsVo(), PageRequest.of(0, Integer.MAX_VALUE)); | |||||
| } else { | } else { | ||||
| Jedis jedis = new Jedis(redisHost, redisPort); | |||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | |||||
| String ci4sUsername = loginUser.getUsername(); | |||||
| String userReq = jedis.get(ci4sUsername + "_gitUserInfo"); | |||||
| Map<String, Object> userInfo = JsonUtils.jsonToMap(userReq); | |||||
| datasetUrl = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage"; | |||||
| modelUrl = gitendpoint + "/api/users/" + userInfo.get("login") + "/projects.json?category=manage"; | |||||
| // 数据集 | |||||
| newDatasetVos = newDatasetService.newPersonalQueryByPage(new Dataset(), PageRequest.of(0, Integer.MAX_VALUE)); | |||||
| // 模型 | |||||
| modelsVos = modelsService.newPersonalQueryByPage(new ModelsVo(), PageRequest.of(0, Integer.MAX_VALUE)); | |||||
| } | } | ||||
| String req = httpUtils.sendGetWithToken(datasetUrl, null, token); | |||||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||||
| List<NewDatasetVo> collect1 = newDatasetService.convert(projects, Constant.Topic_Dataset, null, null); | |||||
| assetCountMap.put("dataset", collect1.size()); | |||||
| req = httpUtils.sendGetWithToken(modelUrl, null, token); | |||||
| stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||||
| projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||||
| List<ModelsVo> collect2 = modelsService.convert(projects, Constant.Topic_model, null, null); | |||||
| assetCountMap.put("model", collect2.size()); | |||||
| assetCountMap.put("dataset", (int) newDatasetVos.getTotalElements()); | |||||
| assetCountMap.put("model", (int) modelsVos.getTotalElements()); | |||||
| // 镜像 | // 镜像 | ||||
| Image image = new Image(); | Image image = new Image(); | ||||
| image.setImageType(Constant.Image_Type_Pub); | |||||
| if (isPublic) { | |||||
| image.setImageType(Constant.Image_Type_Pub); | |||||
| } else { | |||||
| LoginUser loginUser = SecurityUtils.getLoginUser(); | |||||
| image.setCreateBy(loginUser.getUsername()); | |||||
| image.setImageType(Constant.Image_Type_Pri); | |||||
| } | |||||
| Integer imageCount = (int) this.imageDao.count(image); | Integer imageCount = (int) this.imageDao.count(image); | ||||
| assetCountMap.put("image", imageCount); | assetCountMap.put("image", imageCount); | ||||
| //统计组件数量 | //统计组件数量 | ||||
| @@ -133,7 +116,15 @@ public class WorkspaceServiceImpl implements WorkspaceService { | |||||
| Workflow workflow = new Workflow(); | Workflow workflow = new Workflow(); | ||||
| Integer workflowCount = (int) this.workflowDao.count(workflow); | Integer workflowCount = (int) this.workflowDao.count(workflow); | ||||
| assetCountMap.put("workflow", workflowCount); | assetCountMap.put("workflow", workflowCount); | ||||
| // 统计代码配置数量 | |||||
| CodeConfig codeConfig = new CodeConfig(); | |||||
| codeConfig.setIsPublic(isPublic); | |||||
| Integer codeConfigCount = (int) this.codeConfigDao.count(codeConfig); | |||||
| assetCountMap.put("codeConfig", codeConfigCount); | |||||
| // 统计服务数量 | |||||
| com.ruoyi.platform.domain.Service service = new com.ruoyi.platform.domain.Service(); | |||||
| Integer serviceCount = (int) serviceDao.countService(service); | |||||
| assetCountMap.put("service", serviceCount); | |||||
| return assetCountMap; | return assetCountMap; | ||||
| } | } | ||||
| } | } | ||||
| @@ -39,6 +39,7 @@ public class DVCUtils { | |||||
| @Value("${proxy.port}") | @Value("${proxy.port}") | ||||
| private Integer port; | private Integer port; | ||||
| private class ProxyConfigCallback implements TransportConfigCallback { | private class ProxyConfigCallback implements TransportConfigCallback { | ||||
| @Override | @Override | ||||
| public void configure(Transport transport) { | public void configure(Transport transport) { | ||||
| @@ -259,6 +260,7 @@ public class DVCUtils { | |||||
| log.error("Error occurred while creating local branch", e); | log.error("Error occurred while creating local branch", e); | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * 删除本地分支 | * 删除本地分支 | ||||
| * | * | ||||
| @@ -440,17 +442,19 @@ public class DVCUtils { | |||||
| .forEach(ref -> { | .forEach(ref -> { | ||||
| String fullBranchName = ref.getName(); | String fullBranchName = ref.getName(); | ||||
| String branchName = fullBranchName.replace("refs/remotes/origin/", ""); | String branchName = fullBranchName.replace("refs/remotes/origin/", ""); | ||||
| try { | |||||
| completionService.submit(() -> { | |||||
| try { | |||||
| processBranch(git, repository, credentialsProvider, fullBranchName, branchName); | |||||
| } catch (Exception e) { | |||||
| log.error("Failed to process branch: " + branchName, e); | |||||
| } | |||||
| return null; | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| log.error("Task submission rejected", e); | |||||
| if (!"master".equals(branchName)) { | |||||
| try { | |||||
| completionService.submit(() -> { | |||||
| try { | |||||
| processBranch(git, repository, credentialsProvider, fullBranchName, branchName); | |||||
| } catch (Exception e) { | |||||
| log.error("Failed to process branch: " + branchName, e); | |||||
| } | |||||
| return null; | |||||
| }); | |||||
| } catch (Exception e) { | |||||
| log.error("Task submission rejected", e); | |||||
| } | |||||
| } | } | ||||
| }); | }); | ||||
| @@ -523,8 +527,6 @@ public class DVCUtils { | |||||
| } | } | ||||
| public void gitFetch(String localPath, String username, String password) throws IOException, GitAPIException { | public void gitFetch(String localPath, String username, String password) throws IOException, GitAPIException { | ||||
| FileRepositoryBuilder builder = new FileRepositoryBuilder(); | FileRepositoryBuilder builder = new FileRepositoryBuilder(); | ||||
| Repository repository = builder.setGitDir(new File(localPath, ".git")) | Repository repository = builder.setGitDir(new File(localPath, ".git")) | ||||
| @@ -355,6 +355,10 @@ public class K8sClientUtil { | |||||
| int lastIndex = hostPath.lastIndexOf('/'); | int lastIndex = hostPath.lastIndexOf('/'); | ||||
| String newPath = hostPath.substring(0, lastIndex); | String newPath = hostPath.substring(0, lastIndex); | ||||
| V1Pod pod; | V1Pod pod; | ||||
| V1HTTPGetAction httpGetAction = new V1HTTPGetAction().path("/").port(new IntOrString(port)); | |||||
| V1Probe readinessProbe = new V1Probe().httpGet(httpGetAction).initialDelaySeconds(10).periodSeconds(5).failureThreshold(2); | |||||
| if (useProxy) { | if (useProxy) { | ||||
| pod = new V1PodBuilder() | pod = new V1PodBuilder() | ||||
| .withNewMetadata() | .withNewMetadata() | ||||
| @@ -368,6 +372,7 @@ public class K8sClientUtil { | |||||
| .withPorts(new V1ContainerPort().containerPort(port).protocol("TCP")) | .withPorts(new V1ContainerPort().containerPort(port).protocol("TCP")) | ||||
| .withVolumeMounts(new V1VolumeMount().name("workspace").mountPath(mountPath).subPath(subPath)) | .withVolumeMounts(new V1VolumeMount().name("workspace").mountPath(mountPath).subPath(subPath)) | ||||
| .withNewSecurityContext().withNewPrivileged(true).endSecurityContext() | .withNewSecurityContext().withNewPrivileged(true).endSecurityContext() | ||||
| .withReadinessProbe(readinessProbe) | |||||
| .addNewEnv() | .addNewEnv() | ||||
| .withName("HTTP_PROXY") | .withName("HTTP_PROXY") | ||||
| .withValue(proxyUrl) | .withValue(proxyUrl) | ||||
| @@ -402,6 +407,7 @@ public class K8sClientUtil { | |||||
| .withPorts(new V1ContainerPort().containerPort(port).protocol("TCP")) | .withPorts(new V1ContainerPort().containerPort(port).protocol("TCP")) | ||||
| .withVolumeMounts(new V1VolumeMount().name("workspace").mountPath(mountPath).subPath(subPath)) | .withVolumeMounts(new V1VolumeMount().name("workspace").mountPath(mountPath).subPath(subPath)) | ||||
| .withNewSecurityContext().withNewPrivileged(true).endSecurityContext() | .withNewSecurityContext().withNewPrivileged(true).endSecurityContext() | ||||
| .withReadinessProbe(readinessProbe) | |||||
| .addNewEnv() | .addNewEnv() | ||||
| .withName("NO_PROXY") | .withName("NO_PROXY") | ||||
| .withValue("localhost,kubernetes.default.svc") | .withValue("localhost,kubernetes.default.svc") | ||||
| @@ -523,6 +529,8 @@ public class K8sClientUtil { | |||||
| //配置资源 | //配置资源 | ||||
| V1ResourceRequirements v1ResourceRequirements = setPodResource(devEnvironment.getComputingResourceId()); | V1ResourceRequirements v1ResourceRequirements = setPodResource(devEnvironment.getComputingResourceId()); | ||||
| V1HTTPGetAction httpGetAction = new V1HTTPGetAction().path("/").port(new IntOrString(port)); | |||||
| V1Probe readinessProbe = new V1Probe().httpGet(httpGetAction).initialDelaySeconds(10).periodSeconds(5).failureThreshold(2); | |||||
| String image = (String) JsonUtils.jsonToMap(devEnvironment.getImage()).get("value"); | String image = (String) JsonUtils.jsonToMap(devEnvironment.getImage()).get("value"); | ||||
| @@ -538,6 +546,7 @@ public class K8sClientUtil { | |||||
| .withPorts(new V1ContainerPort().containerPort(port).protocol("TCP")) | .withPorts(new V1ContainerPort().containerPort(port).protocol("TCP")) | ||||
| .withVolumeMounts(volumeMounts) | .withVolumeMounts(volumeMounts) | ||||
| .withResources(v1ResourceRequirements) | .withResources(v1ResourceRequirements) | ||||
| .withReadinessProbe(readinessProbe) | |||||
| .endContainer() | .endContainer() | ||||
| .withVolumes(volumes) | .withVolumes(volumes) | ||||
| .withNodeSelector(nodeSelector) | .withNodeSelector(nodeSelector) | ||||
| @@ -629,7 +638,23 @@ public class K8sClientUtil { | |||||
| public String getPodStatus(String podName, String namespace) throws Exception { | public String getPodStatus(String podName, String namespace) throws Exception { | ||||
| CoreV1Api api = new CoreV1Api(apiClient); | CoreV1Api api = new CoreV1Api(apiClient); | ||||
| V1Pod pod = api.readNamespacedPod(podName, namespace, null, null, null); | V1Pod pod = api.readNamespacedPod(podName, namespace, null, null, null); | ||||
| return pod.getStatus().getPhase(); | |||||
| String status = pod.getStatus().getPhase(); | |||||
| Boolean podReady = false; | |||||
| List<V1PodCondition> conditions = pod.getStatus().getConditions(); | |||||
| if (conditions != null) { | |||||
| for (V1PodCondition condition : conditions) { | |||||
| if (Constant.Ready.equals(condition.getType()) && Constant.True.equals(condition.getStatus())) { | |||||
| podReady = true; | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| if (Constant.Running.equals(status) && !podReady) { | |||||
| return Constant.Pending; | |||||
| } | |||||
| return status; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -350,7 +350,7 @@ public class MinioUtil { | |||||
| map.put("name", fileName); | map.put("name", fileName); | ||||
| map.put("size", formattedSize); | map.put("size", formattedSize); | ||||
| if ((fileName.startsWith("run") || fileName.startsWith("checkpoint")) && fileSize == 0) { | |||||
| if ((fileName.startsWith("run") || fileName.startsWith("checkpoint") || fileName.equals("log")) && fileSize == 0) { | |||||
| map.put("isDirectory", true); | map.put("isDirectory", true); | ||||
| map.put("children", listRayFilesInDirectory(bucketName, fullPath)); | map.put("children", listRayFilesInDirectory(bucketName, fullPath)); | ||||
| } else { | } else { | ||||
| @@ -1,5 +1,7 @@ | |||||
| package com.ruoyi.platform.utils; | package com.ruoyi.platform.utils; | ||||
| import com.ruoyi.common.core.utils.StringUtils; | |||||
| import com.ruoyi.platform.vo.HttpDeleteWithBody; | |||||
| import org.apache.http.HttpHost; | import org.apache.http.HttpHost; | ||||
| import org.apache.http.client.methods.*; | import org.apache.http.client.methods.*; | ||||
| import org.apache.http.client.utils.URIBuilder; | import org.apache.http.client.utils.URIBuilder; | ||||
| @@ -80,7 +82,11 @@ public class NewHttpUtils { | |||||
| } | } | ||||
| public static String sendDeleteWithToken(String url, String param, String token, String body) throws Exception { | public static String sendDeleteWithToken(String url, String param, String token, String body) throws Exception { | ||||
| return sendRequest(new HttpDelete(), url, param, token, body); | |||||
| if (StringUtils.isNotEmpty(body)) { | |||||
| return sendRequest(new HttpDeleteWithBody(), url, param, token, body); | |||||
| } else { | |||||
| return sendRequest(new HttpDelete(), url, param, token, body); | |||||
| } | |||||
| } | } | ||||
| public static String sendPatchWithToken(String url, String param, String token, String body) throws Exception { | public static String sendPatchWithToken(String url, String param, String token, String body) throws Exception { | ||||
| @@ -1,183 +0,0 @@ | |||||
| package com.ruoyi.platform.vo; | |||||
| import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | |||||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | |||||
| import io.swagger.annotations.ApiModel; | |||||
| import io.swagger.annotations.ApiModelProperty; | |||||
| import lombok.Data; | |||||
| import java.util.Date; | |||||
| import java.util.Map; | |||||
| @Data | |||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | |||||
| @ApiModel(description = "自动机器学习") | |||||
| public class AutoMlVo { | |||||
| private Long id; | |||||
| @ApiModelProperty(value = "实验名称") | |||||
| private String mlName; | |||||
| @ApiModelProperty(value = "实验描述") | |||||
| private String mlDescription; | |||||
| @ApiModelProperty(value = "任务类型:classification或regression") | |||||
| private String taskType; | |||||
| @ApiModelProperty(value = "搜索合适模型的时间限制(以秒为单位)。通过增加这个值,auto-sklearn有更高的机会找到更好的模型。默认3600,非必传。") | |||||
| private Integer timeLeftForThisTask; | |||||
| @ApiModelProperty(value = "单次调用机器学习模型的时间限制(以秒为单位)。如果机器学习算法运行超过时间限制,将终止模型拟合。将这个值设置得足够高,这样典型的机器学习算法就可以适用于训练数据。默认600,非必传。") | |||||
| private Integer perRunTimeLimit; | |||||
| @ApiModelProperty(value = "集成模型数量,如果设置为0,则没有集成。默认50,非必传。") | |||||
| private Integer ensembleSize; | |||||
| @ApiModelProperty(value = "设置为None将禁用集成构建,设置为SingleBest仅使用单个最佳模型而不是集成,设置为default,它将对单目标问题使用EnsembleSelection,对多目标问题使用MultiObjectiveDummyEnsemble。默认default,非必传。") | |||||
| private String ensembleClass; | |||||
| @ApiModelProperty(value = "在构建集成时只考虑ensemble_nbest模型。这是受到了“最大限度地利用集成选择”中引入的库修剪概念的启发。这是独立于ensemble_class参数的,并且这个修剪步骤是在构造集成之前完成的。默认50,非必传。") | |||||
| private Integer ensembleNbest; | |||||
| @ApiModelProperty(value = "定义在磁盘中保存的模型的最大数量。额外的模型数量将被永久删除。由于这个变量的性质,它设置了一个集成可以使用多少个模型的上限。必须是大于等于1的整数。如果设置为None,则所有模型都保留在磁盘上。默认50,非必传。") | |||||
| private Integer maxModelsOnDisc; | |||||
| @ApiModelProperty(value = "随机种子,将决定输出文件名。默认1,非必传。") | |||||
| private Integer seed; | |||||
| @ApiModelProperty(value = "机器学习算法的内存限制(MB)。如果auto-sklearn试图分配超过memory_limit MB,它将停止拟合机器学习算法。默认3072,非必传。") | |||||
| private Integer memoryLimit; | |||||
| @ApiModelProperty(value = "如果为None,则使用所有可能的分类算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components/<step>/*。与参数exclude不兼容。多选,逗号分隔。包含:adaboost\n" + | |||||
| "bernoulli_nb\n" + | |||||
| "decision_tree\n" + | |||||
| "extra_trees\n" + | |||||
| "gaussian_nb\n" + | |||||
| "gradient_boosting\n" + | |||||
| "k_nearest_neighbors\n" + | |||||
| "lda\n" + | |||||
| "liblinear_svc\n" + | |||||
| "libsvm_svc\n" + | |||||
| "mlp\n" + | |||||
| "multinomial_nb\n" + | |||||
| "passive_aggressive\n" + | |||||
| "qda\n" + | |||||
| "random_forest\n" + | |||||
| "sgd") | |||||
| private String includeClassifier; | |||||
| @ApiModelProperty(value = "如果为None,则使用所有可能的特征预处理算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components/<step>/*。与参数exclude不兼容。多选,逗号分隔。包含:densifier\n" + | |||||
| "extra_trees_preproc_for_classification\n" + | |||||
| "extra_trees_preproc_for_regression\n" + | |||||
| "fast_ica\n" + | |||||
| "feature_agglomeration\n" + | |||||
| "kernel_pca\n" + | |||||
| "kitchen_sinks\n" + | |||||
| "liblinear_svc_preprocessor\n" + | |||||
| "no_preprocessing\n" + | |||||
| "nystroem_sampler\n" + | |||||
| "pca\n" + | |||||
| "polynomial\n" + | |||||
| "random_trees_embedding\n" + | |||||
| "select_percentile_classification\n" + | |||||
| "select_percentile_regression\n" + | |||||
| "select_rates_classification\n" + | |||||
| "select_rates_regression\n" + | |||||
| "truncatedSVD") | |||||
| private String includeFeaturePreprocessor; | |||||
| @ApiModelProperty(value = "如果为None,则使用所有可能的回归算法。否则,指定搜索中包含的步骤和组件。有关可用组件,请参见/pipeline/components/<step>/*。与参数exclude不兼容。多选,逗号分隔。包含:adaboost,\n" + | |||||
| "ard_regression,\n" + | |||||
| "decision_tree,\n" + | |||||
| "extra_trees,\n" + | |||||
| "gaussian_process,\n" + | |||||
| "gradient_boosting,\n" + | |||||
| "k_nearest_neighbors,\n" + | |||||
| "liblinear_svr,\n" + | |||||
| "libsvm_svr,\n" + | |||||
| "mlp,\n" + | |||||
| "random_forest,\n" + | |||||
| "sgd") | |||||
| private String includeRegressor; | |||||
| private String excludeClassifier; | |||||
| private String excludeRegressor; | |||||
| private String excludeFeaturePreprocessor; | |||||
| @ApiModelProperty(value = "测试集的比率,0到1之间") | |||||
| private Float testSize; | |||||
| @ApiModelProperty(value = "如何处理过拟合,如果使用基于“cv”的方法或Splitter对象,可能需要使用resampling_strategy_arguments。holdout或crossValid") | |||||
| private String resamplingStrategy; | |||||
| @ApiModelProperty(value = "重采样划分训练集和验证集,训练集的比率,0到1之间") | |||||
| private Float trainSize; | |||||
| @ApiModelProperty(value = "拆分数据前是否进行shuffle") | |||||
| private Boolean shuffle; | |||||
| @ApiModelProperty(value = "交叉验证的折数,当resamplingStrategy为crossValid时,此项必填,为整数") | |||||
| private Integer folds; | |||||
| @ApiModelProperty(value = "文件夹存放配置输出和日志文件,默认/tmp/automl") | |||||
| private String tmpFolder; | |||||
| @ApiModelProperty(value = "数据集csv文件中哪几列是预测目标列,逗号分隔") | |||||
| private String targetColumns; | |||||
| @ApiModelProperty(value = "自定义指标名称") | |||||
| private String metricName; | |||||
| @ApiModelProperty(value = "模型优化目标指标及权重,json格式。分类的指标包含:accuracy\n" + | |||||
| "balanced_accuracy\n" + | |||||
| "roc_auc\n" + | |||||
| "average_precision\n" + | |||||
| "log_loss\n" + | |||||
| "precision_macro\n" + | |||||
| "precision_micro\n" + | |||||
| "precision_samples\n" + | |||||
| "precision_weighted\n" + | |||||
| "recall_macro\n" + | |||||
| "recall_micro\n" + | |||||
| "recall_samples\n" + | |||||
| "recall_weighted\n" + | |||||
| "f1_macro\n" + | |||||
| "f1_micro\n" + | |||||
| "f1_samples\n" + | |||||
| "f1_weighted\n" + | |||||
| "回归的指标包含:mean_absolute_error\n" + | |||||
| "mean_squared_error\n" + | |||||
| "root_mean_squared_error\n" + | |||||
| "mean_squared_log_error\n" + | |||||
| "median_absolute_error\n" + | |||||
| "r2") | |||||
| private String metrics; | |||||
| @ApiModelProperty(value = "指标优化方向,是越大越好还是越小越好") | |||||
| private Boolean greaterIsBetter; | |||||
| @ApiModelProperty(value = "模型计算并打印指标") | |||||
| private String scoringFunctions; | |||||
| private Integer state; | |||||
| private String runState; | |||||
| private Double progress; | |||||
| private String createBy; | |||||
| private Date createTime; | |||||
| private String updateBy; | |||||
| private Date updateTime; | |||||
| /** | |||||
| * 对应数据集 | |||||
| */ | |||||
| private Map<String,Object> dataset; | |||||
| } | |||||
| @@ -0,0 +1,25 @@ | |||||
| package com.ruoyi.platform.vo; | |||||
| import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; | |||||
| import java.net.URI; | |||||
| public class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase { | |||||
| public static final String METHOD_NAME = "DELETE"; | |||||
| public HttpDeleteWithBody() { | |||||
| } | |||||
| public HttpDeleteWithBody(URI uri) { | |||||
| this.setURI(uri); | |||||
| } | |||||
| public HttpDeleteWithBody(String uri) { | |||||
| this.setURI(URI.create(uri)); | |||||
| } | |||||
| @Override | |||||
| public String getMethod() { | |||||
| return METHOD_NAME; | |||||
| } | |||||
| } | |||||
| @@ -22,6 +22,10 @@ public class ImageVo implements Serializable { | |||||
| */ | */ | ||||
| @ApiModelProperty(name = "description") | @ApiModelProperty(name = "description") | ||||
| private String description; | private String description; | ||||
| @ApiModelProperty(name = "version_description") | |||||
| private String versionDescription; | |||||
| /** | /** | ||||
| * 镜像类型 | * 镜像类型 | ||||
| */ | */ | ||||
| @@ -82,9 +82,12 @@ public class ModelMetaVo implements Serializable { | |||||
| @ApiModelProperty(value = "示例用法") | @ApiModelProperty(value = "示例用法") | ||||
| private String usage; | private String usage; | ||||
| @ApiModelProperty(name = "time_ago", value = "更新时间") | |||||
| @ApiModelProperty(name = "time_ago", value = "创建时间") | |||||
| private String timeAgo; | private String timeAgo; | ||||
| @ApiModelProperty(name = "full_last_update_time",value = "更新时间") | |||||
| private String fullLastUpdateTime; | |||||
| @ApiModelProperty(name = "owner", value = "项目所有者") | @ApiModelProperty(name = "owner", value = "项目所有者") | ||||
| private String owner; | private String owner; | ||||
| @@ -44,8 +44,12 @@ public class NewDatasetVo implements Serializable { | |||||
| @ApiModelProperty(name = "dataset_version_vos",value = "文件列表") | @ApiModelProperty(name = "dataset_version_vos",value = "文件列表") | ||||
| private List<VersionVo> datasetVersionVos; | private List<VersionVo> datasetVersionVos; | ||||
| @ApiModelProperty(name = "time_ago",value = "更新时间") | |||||
| @ApiModelProperty(name = "time_ago",value = "创建时间") | |||||
| private String timeAgo; | private String timeAgo; | ||||
| @ApiModelProperty(name = "full_last_update_time",value = "更新时间") | |||||
| private String fullLastUpdateTime; | |||||
| @ApiModelProperty(name = "id",value = "数据集仓库id") | @ApiModelProperty(name = "id",value = "数据集仓库id") | ||||
| private Integer id; | private Integer id; | ||||
| @ApiModelProperty(name = "visits",value = "访问次数") | @ApiModelProperty(name = "visits",value = "访问次数") | ||||
| @@ -2,28 +2,14 @@ package com.ruoyi.platform.vo; | |||||
| import com.fasterxml.jackson.databind.PropertyNamingStrategy; | import com.fasterxml.jackson.databind.PropertyNamingStrategy; | ||||
| import com.fasterxml.jackson.databind.annotation.JsonNaming; | import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||||
| import lombok.Data; | |||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) | ||||
| @Data | |||||
| public class PodStatusVo implements Serializable { | public class PodStatusVo implements Serializable { | ||||
| private String status; | private String status; | ||||
| private String url; | |||||
| public String getStatus() { | |||||
| return status; | |||||
| } | |||||
| public void setStatus(String status) { | |||||
| this.status = status; | |||||
| } | |||||
| public String getUrl() { | |||||
| return url; | |||||
| } | |||||
| public void setUrl(String url) { | |||||
| this.url = url; | |||||
| } | |||||
| private String url; | |||||
| } | } | ||||
| @@ -9,7 +9,7 @@ | |||||
| <select id="queryByPage" resultType="com.ruoyi.platform.domain.ActiveLearn"> | <select id="queryByPage" resultType="com.ruoyi.platform.domain.ActiveLearn"> | ||||
| select * from active_learn | select * from active_learn | ||||
| <include refid="common_condition"></include> | <include refid="common_condition"></include> | ||||
| order by create_time desc limit #{pageable.offset}, #{pageable.pageSize} | |||||
| order by update_time desc limit #{pageable.offset}, #{pageable.pageSize} | |||||
| </select> | </select> | ||||
| <select id="getActiveLearnByName" resultType="com.ruoyi.platform.domain.ActiveLearn"> | <select id="getActiveLearnByName" resultType="com.ruoyi.platform.domain.ActiveLearn"> | ||||
| @@ -93,9 +93,7 @@ | |||||
| <if test="activeLearn.computingResourceId != null"> | <if test="activeLearn.computingResourceId != null"> | ||||
| computing_resource_id = #{activeLearn.computingResourceId}, | computing_resource_id = #{activeLearn.computingResourceId}, | ||||
| </if> | </if> | ||||
| <if test="activeLearn.shuffle != null"> | |||||
| shuffle = #{activeLearn.shuffle}, | shuffle = #{activeLearn.shuffle}, | ||||
| </if> | |||||
| <if test="activeLearn.trainSize != null"> | <if test="activeLearn.trainSize != null"> | ||||
| train_size = #{activeLearn.trainSize}, | train_size = #{activeLearn.trainSize}, | ||||
| </if> | </if> | ||||
| @@ -132,12 +130,12 @@ | |||||
| <if test="activeLearn.updateBy != null and activeLearn.updateBy !=''"> | <if test="activeLearn.updateBy != null and activeLearn.updateBy !=''"> | ||||
| update_by = #{activeLearn.updateBy}, | update_by = #{activeLearn.updateBy}, | ||||
| </if> | </if> | ||||
| <if test="activeLearn.statusList != null and activeLearn.statusList !=''"> | |||||
| status_list = #{activeLearn.statusList}, | |||||
| </if> | |||||
| <if test="activeLearn.state != null"> | <if test="activeLearn.state != null"> | ||||
| state = #{activeLearn.state}, | state = #{activeLearn.state}, | ||||
| </if> | </if> | ||||
| <if test="activeLearn.statusList != null"> | |||||
| status_list = #{activeLearn.statusList}, | |||||
| </if> | |||||
| </set> | </set> | ||||
| where id = #{activeLearn.id} | where id = #{activeLearn.id} | ||||
| </update> | </update> | ||||
| @@ -1,149 +0,0 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.ruoyi.platform.mapper.AutoMlDao"> | |||||
| <insert id="save" keyProperty="id" useGeneratedKeys="true"> | |||||
| insert into auto_ml(ml_name, ml_description, task_type, dataset, time_left_for_this_task, | |||||
| per_run_time_limit, ensemble_size, ensemble_class, ensemble_nbest, max_models_on_disc, seed, | |||||
| memory_limit, | |||||
| include_classifier, include_feature_preprocessor, include_regressor, exclude_classifier, | |||||
| exclude_regressor, exclude_feature_preprocessor, test_size, resampling_strategy, train_size, | |||||
| shuffle, folds, target_columns, metric_name, metrics, greater_is_better, scoring_functions, | |||||
| tmp_folder, | |||||
| create_by, update_by) | |||||
| values (#{autoMl.mlName}, #{autoMl.mlDescription}, #{autoMl.taskType}, #{autoMl.dataset}, | |||||
| #{autoMl.timeLeftForThisTask}, #{autoMl.perRunTimeLimit}, | |||||
| #{autoMl.ensembleSize}, #{autoMl.ensembleClass}, #{autoMl.ensembleNbest}, | |||||
| #{autoMl.maxModelsOnDisc}, #{autoMl.seed}, | |||||
| #{autoMl.memoryLimit}, #{autoMl.includeClassifier}, #{autoMl.includeFeaturePreprocessor}, | |||||
| #{autoMl.includeRegressor}, #{autoMl.excludeClassifier}, | |||||
| #{autoMl.excludeRegressor}, #{autoMl.excludeFeaturePreprocessor}, #{autoMl.testSize}, | |||||
| #{autoMl.resamplingStrategy}, | |||||
| #{autoMl.trainSize}, #{autoMl.shuffle}, | |||||
| #{autoMl.folds}, | |||||
| #{autoMl.targetColumns}, #{autoMl.metricName}, #{autoMl.metrics}, #{autoMl.greaterIsBetter}, | |||||
| #{autoMl.scoringFunctions}, #{autoMl.tmpFolder}, | |||||
| #{autoMl.createBy}, #{autoMl.updateBy}) | |||||
| </insert> | |||||
| <update id="edit"> | |||||
| update auto_ml | |||||
| <set> | |||||
| <if test="autoMl.mlName != null and autoMl.mlName !=''"> | |||||
| ml_name = #{autoMl.mlName}, | |||||
| </if> | |||||
| <if test="autoMl.mlDescription != null and autoMl.mlDescription !=''"> | |||||
| ml_description = #{autoMl.mlDescription}, | |||||
| </if> | |||||
| <if test="autoMl.statusList != null and autoMl.statusList !=''"> | |||||
| status_list = #{autoMl.statusList}, | |||||
| </if> | |||||
| <if test="autoMl.taskType != null and autoMl.taskType !=''"> | |||||
| task_type = #{autoMl.taskType}, | |||||
| </if> | |||||
| <if test="autoMl.dataset != null and autoMl.dataset !=''"> | |||||
| dataset = #{autoMl.dataset}, | |||||
| </if> | |||||
| <if test="autoMl.timeLeftForThisTask != null"> | |||||
| time_left_for_this_task = #{autoMl.timeLeftForThisTask}, | |||||
| </if> | |||||
| <if test="autoMl.perRunTimeLimit != null"> | |||||
| per_run_time_limit = #{autoMl.perRunTimeLimit}, | |||||
| </if> | |||||
| <if test="autoMl.ensembleSize != null"> | |||||
| ensemble_size = #{autoMl.ensembleSize}, | |||||
| </if> | |||||
| <if test="autoMl.ensembleClass != null and autoMl.ensembleClass !=''"> | |||||
| ensemble_class = #{autoMl.ensembleClass}, | |||||
| </if> | |||||
| <if test="autoMl.ensembleNbest != null"> | |||||
| ensemble_nbest = #{autoMl.ensembleNbest}, | |||||
| </if> | |||||
| <if test="autoMl.maxModelsOnDisc != null"> | |||||
| max_models_on_disc = #{autoMl.maxModelsOnDisc}, | |||||
| </if> | |||||
| <if test="autoMl.seed != null"> | |||||
| seed = #{autoMl.seed}, | |||||
| </if> | |||||
| <if test="autoMl.memoryLimit != null"> | |||||
| memory_limit = #{autoMl.memoryLimit}, | |||||
| </if> | |||||
| include_classifier = #{autoMl.includeClassifier}, | |||||
| include_feature_preprocessor = #{autoMl.includeFeaturePreprocessor}, | |||||
| include_regressor = #{autoMl.includeRegressor}, | |||||
| exclude_classifier = #{autoMl.excludeClassifier}, | |||||
| exclude_regressor = #{autoMl.excludeRegressor}, | |||||
| exclude_feature_preprocessor = #{autoMl.excludeFeaturePreprocessor}, | |||||
| scoring_functions = #{autoMl.scoringFunctions}, | |||||
| metrics = #{autoMl.metrics}, | |||||
| metric_name = #{autoMl.metricName}, | |||||
| <if test="autoMl.testSize != null and autoMl.testSize !=''"> | |||||
| test_size = #{autoMl.testSize}, | |||||
| </if> | |||||
| <if test="autoMl.resamplingStrategy != null and autoMl.resamplingStrategy !=''"> | |||||
| resampling_strategy = #{autoMl.resamplingStrategy}, | |||||
| </if> | |||||
| <if test="autoMl.trainSize != null and autoMl.trainSize !=''"> | |||||
| train_size = #{autoMl.trainSize}, | |||||
| </if> | |||||
| <if test="autoMl.shuffle != null"> | |||||
| shuffle = #{autoMl.shuffle}, | |||||
| </if> | |||||
| <if test="autoMl.folds != null"> | |||||
| folds = #{autoMl.folds}, | |||||
| </if> | |||||
| <if test="autoMl.tmpFolder != null and autoMl.tmpFolder !=''"> | |||||
| tmp_folder = #{autoMl.tmpFolder}, | |||||
| </if> | |||||
| <if test="autoMl.greaterIsBetter != null"> | |||||
| greater_is_better = #{autoMl.greaterIsBetter}, | |||||
| </if> | |||||
| <if test="autoMl.targetColumns != null and autoMl.targetColumns !=''"> | |||||
| target_columns = #{autoMl.targetColumns}, | |||||
| </if> | |||||
| <if test="autoMl.state != null"> | |||||
| state = #{autoMl.state}, | |||||
| </if> | |||||
| </set> | |||||
| where id = #{autoMl.id} | |||||
| </update> | |||||
| <select id="count" resultType="java.lang.Long"> | |||||
| select count(1) from auto_ml | |||||
| <include refid="common_condition"></include> | |||||
| </select> | |||||
| <select id="queryByPage" resultType="com.ruoyi.platform.domain.AutoMl"> | |||||
| select * from auto_ml | |||||
| <include refid="common_condition"></include> | |||||
| order by create_time desc limit #{pageable.offset}, #{pageable.pageSize} | |||||
| </select> | |||||
| <select id="getAutoMlById" resultType="com.ruoyi.platform.domain.AutoMl"> | |||||
| select * | |||||
| from auto_ml | |||||
| where id = #{id} | |||||
| </select> | |||||
| <select id="getAutoMlByName" resultType="com.ruoyi.platform.domain.AutoMl"> | |||||
| select * | |||||
| from auto_ml | |||||
| where ml_name = #{mlName} | |||||
| and state = 1 | |||||
| </select> | |||||
| <select id="queryByDatasetId" resultType="com.ruoyi.platform.domain.AutoMl"> | |||||
| select * | |||||
| from auto_ml | |||||
| where JSON_CONTAINS(dataset, #{datasetId}) | |||||
| and state = 1 | |||||
| </select> | |||||
| <sql id="common_condition"> | |||||
| <where> | |||||
| state = 1 | |||||
| <if test="mlName != null and mlName != ''"> | |||||
| and ml_name like concat('%', #{mlName}, '%') | |||||
| </if> | |||||
| </where> | |||||
| </sql> | |||||
| </mapper> | |||||
| @@ -1,86 +0,0 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.ruoyi.platform.mapper.AutoMlInsDao"> | |||||
| <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | |||||
| insert into auto_ml_ins(auto_ml_id, result_path, model_path, img_path, run_history_path, node_status, | |||||
| node_result, param, source, argo_ins_name, argo_ins_ns, status) | |||||
| values (#{autoMlIns.autoMlId}, #{autoMlIns.resultPath}, #{autoMlIns.modelPath}, #{autoMlIns.imgPath}, | |||||
| #{autoMlIns.runHistoryPath}, #{autoMlIns.nodeStatus}, | |||||
| #{autoMlIns.nodeResult}, #{autoMlIns.param}, #{autoMlIns.source}, #{autoMlIns.argoInsName}, | |||||
| #{autoMlIns.argoInsNs}, #{autoMlIns.status}) | |||||
| </insert> | |||||
| <update id="update"> | |||||
| update auto_ml_ins | |||||
| <set> | |||||
| <if test="autoMlIns.modelPath != null and autoMlIns.modelPath != ''"> | |||||
| model_path = #{autoMlIns.modelPath}, | |||||
| </if> | |||||
| <if test="autoMlIns.imgPath != null and autoMlIns.imgPath != ''"> | |||||
| img_path = #{autoMlIns.imgPath}, | |||||
| </if> | |||||
| <if test="autoMlIns.status != null and autoMlIns.status != ''"> | |||||
| status = #{autoMlIns.status}, | |||||
| </if> | |||||
| <if test="autoMlIns.nodeStatus != null and autoMlIns.nodeStatus != ''"> | |||||
| node_status = #{autoMlIns.nodeStatus}, | |||||
| </if> | |||||
| <if test="autoMlIns.nodeResult != null and autoMlIns.nodeResult != ''"> | |||||
| node_result = #{autoMlIns.nodeResult}, | |||||
| </if> | |||||
| <if test="autoMlIns.state != null"> | |||||
| state = #{autoMlIns.state}, | |||||
| </if> | |||||
| <if test="autoMlIns.updateTime != null"> | |||||
| update_time = #{autoMlIns.updateTime}, | |||||
| </if> | |||||
| <if test="autoMlIns.finishTime != null"> | |||||
| finish_time = #{autoMlIns.finishTime}, | |||||
| </if> | |||||
| </set> | |||||
| where id = #{autoMlIns.id} | |||||
| </update> | |||||
| <select id="count" resultType="java.lang.Long"> | |||||
| select count(1) | |||||
| from auto_ml_ins | |||||
| <where> | |||||
| state = 1 | |||||
| and auto_ml_id = #{autoMlIns.autoMlId} | |||||
| </where> | |||||
| </select> | |||||
| <select id="queryAllByLimit" resultType="com.ruoyi.platform.domain.AutoMlIns"> | |||||
| select * from auto_ml_ins | |||||
| <where> | |||||
| state = 1 | |||||
| and auto_ml_id = #{autoMlIns.autoMlId} | |||||
| </where> | |||||
| order by update_time DESC | |||||
| limit #{pageable.offset}, #{pageable.pageSize} | |||||
| </select> | |||||
| <select id="queryById" resultType="com.ruoyi.platform.domain.AutoMlIns"> | |||||
| select * from auto_ml_ins | |||||
| <where> | |||||
| state = 1 and id = #{id} | |||||
| </where> | |||||
| </select> | |||||
| <select id="queryByAutoMlInsIsNotTerminated" resultType="com.ruoyi.platform.domain.AutoMlIns"> | |||||
| select * | |||||
| from auto_ml_ins | |||||
| where (status NOT IN ('Terminated', 'Succeeded', 'Failed') | |||||
| OR status IS NULL) | |||||
| and state = 1 | |||||
| </select> | |||||
| <select id="getByAutoMlId" resultType="com.ruoyi.platform.domain.AutoMlIns"> | |||||
| select * | |||||
| from auto_ml_ins | |||||
| where auto_ml_id = #{autoMlId} | |||||
| and state = 1 | |||||
| order by update_time DESC limit 5 | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -2,10 +2,10 @@ | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="com.ruoyi.platform.mapper.CodeConfigDao"> | <mapper namespace="com.ruoyi.platform.mapper.CodeConfigDao"> | ||||
| <insert id="insert"> | |||||
| insert into code_config(code_repo_name, code_repo_vis, git_url, git_branch, verify_mode, git_user_name, | |||||
| <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | |||||
| insert into code_config(code_repo_name, is_public, git_url, git_branch, verify_mode, git_user_name, | |||||
| git_password, ssh_key, create_by, create_time, update_by, update_time) | git_password, ssh_key, create_by, create_time, update_by, update_time) | ||||
| values (#{codeConfig.codeRepoName}, #{codeConfig.codeRepoVis}, #{codeConfig.gitUrl}, #{codeConfig.gitBranch}, | |||||
| values (#{codeConfig.codeRepoName}, #{codeConfig.isPublic}, #{codeConfig.gitUrl}, #{codeConfig.gitBranch}, | |||||
| #{codeConfig.verifyMode}, #{codeConfig.gitUserName}, #{codeConfig.gitPassword}, | #{codeConfig.verifyMode}, #{codeConfig.gitUserName}, #{codeConfig.gitPassword}, | ||||
| #{codeConfig.sshKey}, #{codeConfig.createBy}, #{codeConfig.createTime}, #{codeConfig.updateBy}, | #{codeConfig.sshKey}, #{codeConfig.createBy}, #{codeConfig.createTime}, #{codeConfig.updateBy}, | ||||
| #{codeConfig.updateTime}) | #{codeConfig.updateTime}) | ||||
| @@ -17,8 +17,8 @@ | |||||
| <if test="codeConfig.codeRepoName != null and codeConfig.codeRepoName != ''"> | <if test="codeConfig.codeRepoName != null and codeConfig.codeRepoName != ''"> | ||||
| code_repo_name = #{codeConfig.codeRepoName}, | code_repo_name = #{codeConfig.codeRepoName}, | ||||
| </if> | </if> | ||||
| <if test="codeConfig.codeRepoVis != null"> | |||||
| code_repo_vis = #{codeConfig.codeRepoVis}, | |||||
| <if test="codeConfig.isPublic != null"> | |||||
| is_public = #{codeConfig.isPublic}, | |||||
| </if> | </if> | ||||
| <if test="codeConfig.gitUrl != null"> | <if test="codeConfig.gitUrl != null"> | ||||
| git_url = #{codeConfig.gitUrl}, | git_url = #{codeConfig.gitUrl}, | ||||
| @@ -78,6 +78,7 @@ | |||||
| <sql id="common_condition"> | <sql id="common_condition"> | ||||
| <where> | <where> | ||||
| state = 1 | state = 1 | ||||
| and code_repo_vis = 1 | |||||
| <if test="codeConfig.id != null"> | <if test="codeConfig.id != null"> | ||||
| and id = #{codeConfig.id} | and id = #{codeConfig.id} | ||||
| </if> | </if> | ||||
| @@ -85,7 +86,7 @@ | |||||
| and code_repo_name LIKE CONCAT('%', #{codeConfig.codeRepoName}, '%') | and code_repo_name LIKE CONCAT('%', #{codeConfig.codeRepoName}, '%') | ||||
| </if> | </if> | ||||
| <if test="codeConfig.codeRepoVis != null"> | <if test="codeConfig.codeRepoVis != null"> | ||||
| and code_repo_vis = #{codeConfig.codeRepoVis} | |||||
| and is_public = #{codeConfig.isPublic} | |||||
| </if> | </if> | ||||
| <if test="codeConfig.gitUrl != null"> | <if test="codeConfig.gitUrl != null"> | ||||
| and git_url = #{codeConfig.gitUrl} | and git_url = #{codeConfig.gitUrl} | ||||
| @@ -65,7 +65,7 @@ | |||||
| and state = #{devEnvironment.state} | and state = #{devEnvironment.state} | ||||
| </if> | </if> | ||||
| </where> | </where> | ||||
| limit #{pageable.offset}, #{pageable.pageSize} | |||||
| order by create_time desc limit #{pageable.offset}, #{pageable.pageSize} | |||||
| </select> | </select> | ||||
| @@ -157,24 +157,24 @@ | |||||
| <!--新增所有列--> | <!--新增所有列--> | ||||
| <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | <insert id="insert" keyProperty="id" useGeneratedKeys="true"> | ||||
| insert into experiment(name,workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state) | |||||
| values (#{experiment.name},#{experiment.workflowId}, #{experiment.globalParam},#{experiment.statusList}, #{experiment.description}, #{experiment.createBy}, #{experiment.createTime}, #{experiment.updateBy}, #{experiment.updateTime}, #{experiment.state}) | |||||
| insert into experiment(name,workflow_id, global_param, status_list, description, create_by, update_by, state) | |||||
| values (#{experiment.name},#{experiment.workflowId}, #{experiment.globalParam},#{experiment.statusList}, #{experiment.description}, #{experiment.createBy}, #{experiment.updateBy}, #{experiment.state}) | |||||
| </insert> | </insert> | ||||
| <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> | <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> | ||||
| insert into experiment(name,workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state) | |||||
| insert into experiment(name,workflow_id, global_param, status_list, description, create_by, update_by, state) | |||||
| values | values | ||||
| <foreach collection="entities" item="entity" separator=","> | <foreach collection="entities" item="entity" separator=","> | ||||
| (#{entity.name},#{entity.workflowId}, #{entity.globalParam},#{entity.statusList}, #{entity.description}, #{entity.createBy}, #{entity.createTime}, | |||||
| #{entity.updateBy}, #{entity.updateTime}, #{entity.state}) | |||||
| (#{entity.name},#{entity.workflowId}, #{entity.globalParam},#{entity.statusList}, #{entity.description}, #{entity.createBy}, | |||||
| #{entity.updateBy}, #{entity.state}) | |||||
| </foreach> | </foreach> | ||||
| </insert> | </insert> | ||||
| <update id="insertOrUpdateBatch"> | <update id="insertOrUpdateBatch"> | ||||
| insert into experiment (id, name, workflow_id, global_param, status_list, description, create_by, create_time, update_by, update_time, state) | |||||
| insert into experiment (id, name, workflow_id, global_param, status_list, description, create_by, update_by, state) | |||||
| values | values | ||||
| <foreach collection="list" item="item" index="index" separator=","> | <foreach collection="list" item="item" index="index" separator=","> | ||||
| (#{item.id}, #{item.name}, #{item.workflowId}, #{item.globalParam}, #{item.statusList}, #{item.description}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.state}) | |||||
| (#{item.id}, #{item.name}, #{item.workflowId}, #{item.globalParam}, #{item.statusList}, #{item.description}, #{item.createBy}, #{item.updateBy}, #{item.state}) | |||||
| </foreach> | </foreach> | ||||
| ON DUPLICATE KEY UPDATE | ON DUPLICATE KEY UPDATE | ||||
| name = VALUES(name), | name = VALUES(name), | ||||
| @@ -183,9 +183,7 @@ | |||||
| status_list = VALUES(status_list), | status_list = VALUES(status_list), | ||||
| description = VALUES(description), | description = VALUES(description), | ||||
| create_by = VALUES(create_by), | create_by = VALUES(create_by), | ||||
| create_time = VALUES(create_time), | |||||
| update_by = VALUES(update_by), | update_by = VALUES(update_by), | ||||
| update_time = VALUES(update_time), | |||||
| state = VALUES(state); | state = VALUES(state); | ||||
| </update> | </update> | ||||
| @@ -203,27 +201,18 @@ | |||||
| <if test="globalParam != null and globalParam != ''"> | <if test="globalParam != null and globalParam != ''"> | ||||
| global_param = #{globalParam}, | global_param = #{globalParam}, | ||||
| </if> | </if> | ||||
| <if test="statusList != null and statusList != ''"> | |||||
| status_list = #{statusList}, | |||||
| </if> | |||||
| <if test="description != null and description != ''"> | <if test="description != null and description != ''"> | ||||
| description = #{description}, | description = #{description}, | ||||
| </if> | </if> | ||||
| <if test="createBy != null and createBy != ''"> | |||||
| create_by = #{createBy}, | |||||
| </if> | |||||
| <if test="createTime != null"> | |||||
| create_time = #{createTime}, | |||||
| </if> | |||||
| <if test="updateBy != null and updateBy != ''"> | <if test="updateBy != null and updateBy != ''"> | ||||
| update_by = #{updateBy}, | update_by = #{updateBy}, | ||||
| </if> | </if> | ||||
| <if test="updateTime != null"> | |||||
| update_time = #{updateTime}, | |||||
| </if> | |||||
| <if test="state != null"> | <if test="state != null"> | ||||
| state = #{state}, | state = #{state}, | ||||
| </if> | </if> | ||||
| <if test="statusList != null"> | |||||
| status_list = #{statusList}, | |||||
| </if> | |||||
| </set> | </set> | ||||
| where id = #{id} | where id = #{id} | ||||
| </update> | </update> | ||||
| @@ -10,7 +10,7 @@ | |||||
| <select id="queryByPage" resultType="com.ruoyi.platform.domain.MachineLearn"> | <select id="queryByPage" resultType="com.ruoyi.platform.domain.MachineLearn"> | ||||
| select * from machine_learn | select * from machine_learn | ||||
| <include refid="common_condition"></include> | <include refid="common_condition"></include> | ||||
| order by create_time desc limit #{pageable.offset}, #{pageable.pageSize} | |||||
| order by update_time desc limit #{pageable.offset}, #{pageable.pageSize} | |||||
| </select> | </select> | ||||
| <insert id="save" keyProperty="id" useGeneratedKeys="true"> | <insert id="save" keyProperty="id" useGeneratedKeys="true"> | ||||
| @@ -34,15 +34,15 @@ | |||||
| <if test="machineLearn.param != null and machineLearn.param !=''"> | <if test="machineLearn.param != null and machineLearn.param !=''"> | ||||
| param = #{machineLearn.param}, | param = #{machineLearn.param}, | ||||
| </if> | </if> | ||||
| <if test="machineLearn.statusList != null and machineLearn.statusList !=''"> | |||||
| status_list = #{machineLearn.statusList}, | |||||
| </if> | |||||
| <if test="machineLearn.state != null"> | <if test="machineLearn.state != null"> | ||||
| state = #{machineLearn.state}, | state = #{machineLearn.state}, | ||||
| </if> | </if> | ||||
| <if test="machineLearn.updateBy != null and machineLearn.updateBy !=''"> | <if test="machineLearn.updateBy != null and machineLearn.updateBy !=''"> | ||||
| update_by = #{machineLearn.updateBy}, | update_by = #{machineLearn.updateBy}, | ||||
| </if> | </if> | ||||
| <if test="machineLearn.statusList != null"> | |||||
| status_list = #{machineLearn.statusList}, | |||||
| </if> | |||||
| </set> | </set> | ||||
| where id = #{machineLearn.id} | where id = #{machineLearn.id} | ||||
| </update> | </update> | ||||
| @@ -25,9 +25,6 @@ | |||||
| <if test="ray.dataset != null and ray.dataset !=''"> | <if test="ray.dataset != null and ray.dataset !=''"> | ||||
| dataset = #{ray.dataset}, | dataset = #{ray.dataset}, | ||||
| </if> | </if> | ||||
| <if test="ray.model != null and ray.model !=''"> | |||||
| model = #{ray.model}, | |||||
| </if> | |||||
| <if test="ray.codeConfig != null and ray.codeConfig !=''"> | <if test="ray.codeConfig != null and ray.codeConfig !=''"> | ||||
| code_config = #{ray.codeConfig}, | code_config = #{ray.codeConfig}, | ||||
| </if> | </if> | ||||
| @@ -49,12 +46,6 @@ | |||||
| <if test="ray.storagePath != null and ray.storagePath !=''"> | <if test="ray.storagePath != null and ray.storagePath !=''"> | ||||
| storage_path = #{ray.storagePath}, | storage_path = #{ray.storagePath}, | ||||
| </if> | </if> | ||||
| <if test="ray.searchAlg != null and ray.searchAlg !=''"> | |||||
| search_alg = #{ray.searchAlg}, | |||||
| </if> | |||||
| <if test="ray.scheduler != null and ray.scheduler !=''"> | |||||
| scheduler = #{ray.scheduler}, | |||||
| </if> | |||||
| <if test="ray.metric != null and ray.metric !=''"> | <if test="ray.metric != null and ray.metric !=''"> | ||||
| metric = #{ray.metric}, | metric = #{ray.metric}, | ||||
| </if> | </if> | ||||
| @@ -76,12 +67,15 @@ | |||||
| <if test="ray.updateBy != null and ray.updateBy !=''"> | <if test="ray.updateBy != null and ray.updateBy !=''"> | ||||
| update_by = #{ray.updateBy}, | update_by = #{ray.updateBy}, | ||||
| </if> | </if> | ||||
| <if test="ray.statusList != null and ray.statusList !=''"> | |||||
| status_list = #{ray.statusList}, | |||||
| </if> | |||||
| <if test="ray.state != null"> | <if test="ray.state != null"> | ||||
| state = #{ray.state}, | state = #{ray.state}, | ||||
| </if> | </if> | ||||
| <if test="ray.statusList != null"> | |||||
| status_list = #{ray.statusList}, | |||||
| </if> | |||||
| model = #{ray.model}, | |||||
| scheduler = #{ray.scheduler}, | |||||
| search_alg = #{ray.searchAlg}, | |||||
| </set> | </set> | ||||
| where id = #{ray.id} | where id = #{ray.id} | ||||
| </update> | </update> | ||||
| @@ -94,7 +88,7 @@ | |||||
| <select id="queryByPage" resultType="com.ruoyi.platform.domain.Ray"> | <select id="queryByPage" resultType="com.ruoyi.platform.domain.Ray"> | ||||
| select * from ray | select * from ray | ||||
| <include refid="common_condition"></include> | <include refid="common_condition"></include> | ||||
| order by create_time desc limit #{pageable.offset}, #{pageable.pageSize} | |||||
| order by update_time desc limit #{pageable.offset}, #{pageable.pageSize} | |||||
| </select> | </select> | ||||
| <select id="getRayByName" resultType="com.ruoyi.platform.domain.Ray"> | <select id="getRayByName" resultType="com.ruoyi.platform.domain.Ray"> | ||||
| @@ -104,7 +104,7 @@ | |||||
| user_id, | user_id, | ||||
| description, | description, | ||||
| credit_per_hour, | credit_per_hour, | ||||
| TRUNCATE(deduce_credit, 1) as deduce_credit, | |||||
| deduce_credit, | |||||
| start_time, | start_time, | ||||
| task_type, | task_type, | ||||
| task_id, | task_id, | ||||
| @@ -119,13 +119,15 @@ | |||||
| </select> | </select> | ||||
| <select id="getUserCredit" resultType="java.lang.Double"> | <select id="getUserCredit" resultType="java.lang.Double"> | ||||
| select TRUNCATE(credit, 1) as credit | |||||
| select | |||||
| credit | |||||
| from sys_user | from sys_user | ||||
| where user_id = #{userId} | where user_id = #{userId} | ||||
| </select> | </select> | ||||
| <select id="getDeduceCredit" resultType="java.lang.Double"> | <select id="getDeduceCredit" resultType="java.lang.Double"> | ||||
| select TRUNCATE(sum(deduce_credit), 1) as deduce_credit | |||||
| select | |||||
| sum(deduce_credit) as deduce_credit | |||||
| from resource_occupy | from resource_occupy | ||||
| where user_id = #{userId} | where user_id = #{userId} | ||||
| </select> | </select> | ||||