| @@ -59,10 +59,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)); | ||||
| } | } | ||||
| } | } | ||||
| @@ -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()); | |||||
| } | |||||
| } | } | ||||
| @@ -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); | ||||
| } | } | ||||
| } | } | ||||
| @@ -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; | |||||
| } | } | ||||
| @@ -33,7 +33,7 @@ public class ActiveLearnInsStatusTask { | |||||
| private List<Long> activeLearnIds = new ArrayList<>(); | private List<Long> activeLearnIds = new ArrayList<>(); | ||||
| @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(); | ||||
| @@ -29,7 +29,7 @@ public class AutoMlInsStatusTask { | |||||
| private List<Long> autoMlIds = new ArrayList<>(); | private List<Long> autoMlIds = new ArrayList<>(); | ||||
| @Scheduled(cron = "0/30 * * * * ?") // 每30S执行一次 | |||||
| @Scheduled(cron = "0/10 * * * * ?") // 每10S执行一次 | |||||
| public void executeAutoMlInsStatus() { | public void executeAutoMlInsStatus() { | ||||
| // 首先查到所有非终止态的实验实例 | // 首先查到所有非终止态的实验实例 | ||||
| List<AutoMlIns> autoMlInsList = autoMlInsService.queryByAutoMlInsIsNotTerminated(); | List<AutoMlIns> autoMlInsList = autoMlInsService.queryByAutoMlInsIsNotTerminated(); | ||||
| @@ -36,7 +36,7 @@ public class ExperimentInstanceStatusTask { | |||||
| private List<Integer> experimentIds = new ArrayList<>(); | private List<Integer> experimentIds = new ArrayList<>(); | ||||
| @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(); | ||||
| @@ -31,7 +31,7 @@ public class MLStatusTask { | |||||
| private List<Long> machineLearnIds = new ArrayList<>(); | private List<Long> machineLearnIds = new ArrayList<>(); | ||||
| @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(); | ||||
| @@ -33,7 +33,7 @@ public class RayInsStatusTask { | |||||
| private List<Long> rayIds = new ArrayList<>(); | private List<Long> rayIds = new ArrayList<>(); | ||||
| @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(); | ||||
| @@ -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()); | ||||
| @@ -66,7 +66,7 @@ public class AutoMlServiceImpl implements AutoMlService { | |||||
| @Override | @Override | ||||
| public AutoMl save(AutoMlVo autoMlVo) throws Exception { | public AutoMl save(AutoMlVo autoMlVo) throws Exception { | ||||
| if (autoMlVo.getMlName().length() >= 64) { | |||||
| if (autoMlVo.getMlName().length() > 64) { | |||||
| throw new RuntimeException("实验名称大于最大长度"); | throw new RuntimeException("实验名称大于最大长度"); | ||||
| } | } | ||||
| AutoMl autoMlByName = autoMlDao.getAutoMlByName(autoMlVo.getMlName()); | AutoMl autoMlByName = autoMlDao.getAutoMlByName(autoMlVo.getMlName()); | ||||
| @@ -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; | ||||
| @@ -37,6 +39,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 | ||||
| @@ -362,7 +366,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"状态,则不执行终止操作 | ||||
| } | } | ||||
| @@ -430,40 +434,44 @@ 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"); | |||||
| 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()); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } | |||||
| //删除导出数据集版本 | |||||
| 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); | |||||
| //删除导出数据集版本 | |||||
| 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()); | |||||
| } | } | ||||
| } | } | ||||
| @@ -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; | ||||
| @@ -23,6 +26,8 @@ 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 +41,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) { | ||||
| @@ -237,6 +244,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 +266,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); | ||||
| @@ -191,7 +197,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 +215,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; | ||||
| } | } | ||||
| } | } | ||||
| @@ -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()); | ||||
| @@ -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,11 @@ 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; | ||||
| resourceOccupyDao.deduceCredit(deduceCredit, resourceOccupy.getUserId()); | |||||
| double deduceCreditTrun = new BigDecimal(deduceCredit).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); | |||||
| deduceCreditTrun = deduceCreditTrun > 0 ? deduceCreditTrun : 0.01; | |||||
| resourceOccupyDao.deduceCredit(deduceCreditTrun, resourceOccupy.getUserId()); | |||||
| resourceOccupy.setDeduceCredit(resourceOccupy.getDeduceCredit() + deduceCredit); | |||||
| resourceOccupy.setDeduceCredit(resourceOccupy.getDeduceCredit() + deduceCreditTrun); | |||||
| resourceOccupy.setDeduceLastTime(now); | resourceOccupy.setDeduceLastTime(now); | ||||
| resourceOccupy.setState(Constant.State_valid); | resourceOccupy.setState(Constant.State_valid); | ||||
| resourceOccupyDao.edit(resourceOccupy); | resourceOccupyDao.edit(resourceOccupy); | ||||
| @@ -171,6 +174,6 @@ public class ResourceOccupyServiceImpl implements ResourceOccupyService { | |||||
| @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); | |||||
| } | } | ||||
| } | } | ||||
| @@ -180,7 +180,7 @@ 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) { | |||||
| if (workflow.getName().length() > 64) { | |||||
| throw new RuntimeException("流水线名称大于最大长度"); | throw new RuntimeException("流水线名称大于最大长度"); | ||||
| } | } | ||||
| @@ -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 { | ||||
| @@ -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> | ||||