diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java index e7524042..1d8d695b 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/dataset/DatasetController.java @@ -68,7 +68,8 @@ public class DatasetController { @ApiOperation("分页查询当前用户的个人数据集,根据data_type筛选,1公开0私有") public AjaxResult queryByPagePersonal(Dataset dataset, @RequestParam("page") int page, @RequestParam("size") int size, - @RequestParam(value = "data_type", required = false) String dataType) { + @RequestParam(value = "data_type", required = false) String dataType, + @RequestParam(value = "data_tag", required = false) String dataTag) { // 获取当前用户的认证信息 LoginUser loginUser = SecurityUtils.getLoginUser(); // 设置筛选条件 diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java index ee8a58c9..678e6de5 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/experiment/ExperimentInsController.java @@ -3,12 +3,14 @@ package com.ruoyi.platform.controller.experiment; import com.ruoyi.common.core.web.domain.AjaxResult; import com.ruoyi.platform.domain.ExperimentIns; import com.ruoyi.platform.service.ExperimentInsService; +import com.ruoyi.platform.vo.LogRequestVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.data.domain.PageRequest; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.ws.rs.POST; import java.io.IOException; import java.util.Map; @@ -126,6 +128,18 @@ public class ExperimentInsController { return AjaxResult.success(this.experimentInsService.showExperimentInsLog(id,componentId)); } + /** + * 查询实验实时日志 + * + * @return 运行日志 + */ + + @PostMapping(("/realTimeLog")) + @ApiOperation("查询实例实时日志") + public AjaxResult getRealtimeWorkflowLog(@RequestBody LogRequestVo logRequest){ + return AjaxResult.success(this.experimentInsService.getRealtimeWorkflowLog(logRequest)); + } + /** diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsController.java index d5df7058..dea9e44c 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/model/ModelsController.java @@ -51,10 +51,14 @@ public class ModelsController { public AjaxResult queryByPage(Models models, @RequestParam("page") int page, @RequestParam("size") int size, //@RequestParam("available_range") int availableRange, - @RequestParam(value = "model_type", required = false) String modelType) { + @RequestParam(value = "model_type", required = false) String modelType, + @RequestParam(value = "model_tag", required = false) String modelTag) { if (modelType != null){ models.setModelType(modelType); // 设置筛选条件 } + if (modelTag != null){ + models.setModelTag(modelTag); // 设置筛选条件 + } models.setAvailableRange(1); // 设置筛选条件 PageRequest pageRequest = PageRequest.of(page, size); return AjaxResult.success(this.modelsService.queryByPage(models, pageRequest)); @@ -73,7 +77,8 @@ public class ModelsController { @ApiOperation("分页查询当前用户的个人模型 ,根据model_type筛选") public AjaxResult queryByPagePersonal(Models models, @RequestParam("page") int page, @RequestParam("size") int size, - @RequestParam(value = "model_type", required = false) String modelType) { + @RequestParam(value = "model_type", required = false) String modelType, + @RequestParam(value = "model_tag", required = false) String modelTag) { // 获取当前用户的认证信息 LoginUser loginUser = SecurityUtils.getLoginUser(); // 设置筛选条件 @@ -81,6 +86,9 @@ public class ModelsController { if (modelType != null){ models.setModelType(modelType); // 设置筛选条件 } + if (modelTag != null){ + models.setModelTag(modelTag); // 设置筛选条件 + } PageRequest pageRequest = PageRequest.of(page, size); return AjaxResult.success(this.modelsService.queryByPage(models, pageRequest)); } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentInsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentInsService.java index 7d542160..b6848de2 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentInsService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ExperimentInsService.java @@ -1,6 +1,7 @@ package com.ruoyi.platform.service; import com.ruoyi.platform.domain.ExperimentIns; +import com.ruoyi.platform.vo.LogRequestVo; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; @@ -88,4 +89,7 @@ public interface ExperimentInsService { String showExperimentInsLog(Integer id, String componentId); List getNodeResult(Integer id, String nodeId) throws Exception; + + String getRealtimeWorkflowLog(LogRequestVo logRequest); + } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java index 20366e3b..299a1c59 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.platform.service.impl; +import com.fasterxml.jackson.core.JsonProcessingException; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.platform.domain.Experiment; import com.ruoyi.platform.domain.ExperimentIns; @@ -11,6 +12,7 @@ import com.ruoyi.platform.utils.DateUtils; import com.ruoyi.platform.utils.HttpUtils; import com.ruoyi.platform.utils.JsonUtils; import com.ruoyi.platform.utils.MinioUtil; +import com.ruoyi.platform.vo.LogRequestVo; import com.ruoyi.system.api.model.LoginUser; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; @@ -49,6 +51,8 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { private String argoWorkflowTermination; @Value("${argo.workflowLog}") private String argoWorkflowLog; + @Value("${argo.workflowRealTimeLog}") + private String argoWorkflowRealTimeLog; private final MinioUtil minioUtil; public ExperimentInsServiceImpl(MinioUtil minioUtil) { @@ -452,6 +456,40 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { return results; } + @Override + public String getRealtimeWorkflowLog(LogRequestVo logRequest) { + + String componentId = logRequest.getComponentId(); + String nameSpace = logRequest.getNamespace(); + String name = logRequest.getName(); + String taskId = logRequest.getTaskId(); + String startTime = logRequest.getStartTime(); + // 创建请求数据的Json(map) + Map requestData = new HashMap<>(); + requestData.put("component_id", componentId); + requestData.put("namespace", nameSpace); + requestData.put("name", name); + requestData.put("task_id",taskId); + requestData.put("start_time",startTime); + // 创建发送数据map,将请求数据作为"data"键的值 + Map res = new HashMap<>(); + res.put("data", requestData); + + try { + // 将Map转换为JSON字符串 + String req = HttpUtils.sendPost(argoUrl + argoWorkflowRealTimeLog, JsonUtils.mapToJson(res)); + // 检查响应是否为空或无内容 + if (StringUtils.isEmpty(req)) { + throw new RuntimeException("响应内容为空"); + } + return req; + + } catch (Exception e) { + throw new RuntimeException("查询实验日志失败: " + e.getMessage(), e); + } + + } + private boolean isTerminatedState(ExperimentIns ins) throws IOException { // 定义终止态的列表,例如 "Succeeded", "Failed" 等 String status = ins.getStatus(); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java index 7f3cf1aa..cd256a58 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ImageServiceImpl.java @@ -252,7 +252,7 @@ public class ImageServiceImpl implements ImageService { throw new Exception("解析镜像压缩包失败,请检查镜像文件"); } }else { - throw new Exception("解析镜像压缩包失败,请检查镜像文件"); + throw new Exception("解析镜像压缩包失败,请检查镜像文件"); } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java index 92dd533a..98e9ea9f 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ModelsServiceImpl.java @@ -195,11 +195,12 @@ public class ModelsServiceImpl implements ModelsService { ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); InputStreamResource resource = new InputStreamResource(inputStream); - return ResponseEntity.ok() .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(extractFileName(objectName),"UTF-8") + "\"") .contentType(MediaType.APPLICATION_OCTET_STREAM) .body(resource); + + } catch (Exception e) { e.printStackTrace(); throw new Exception("下载模型文件错误"); diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java index 7b3c3c3d..c4c7992a 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/WorkflowServiceImpl.java @@ -6,8 +6,12 @@ import com.ruoyi.platform.domain.Workflow; import com.ruoyi.platform.mapper.WorkflowDao; import com.ruoyi.platform.service.ExperimentService; import com.ruoyi.platform.service.WorkflowService; +import com.ruoyi.platform.utils.HttpUtils; +import com.ruoyi.platform.utils.JsonUtils; +import com.ruoyi.platform.utils.MinioUtil; import com.ruoyi.system.api.model.LoginUser; import org.apache.commons.lang.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; @@ -15,7 +19,9 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * DAG workflow(Workflow)表服务实现类 @@ -31,6 +37,18 @@ public class WorkflowServiceImpl implements WorkflowService { @Resource private ExperimentService experimentService; + @Value("${argo.url}") + private String argoUrl; + + @Value("${argo.workflowCopy}") + private String argoWorkflowCopy; + + private final MinioUtil minioUtil; + + public WorkflowServiceImpl(MinioUtil minioUtil) { + this.minioUtil = minioUtil; + } + /** * 通过ID查询单条数据 * @@ -142,28 +160,40 @@ public class WorkflowServiceImpl implements WorkflowService { //先去查找数据库中存在的数据 Workflow workflow = this.queryById(id); if (workflow!= null) { - Workflow duplicateWorkflow = new Workflow(); - duplicateWorkflow.setName(workflow.getName()+"-copy"); - duplicateWorkflow.setDag(workflow.getDag()); - duplicateWorkflow.setDescription(workflow.getDescription()); - return this.insert(duplicateWorkflow); + try { + Workflow duplicateWorkflow = new Workflow(); + duplicateWorkflow.setName(workflow.getName()+"-copy"); + String oldDag = workflow.getDag(); + // 创建请求数据的Json(map) + Map requestData = new HashMap<>(); + requestData.put("data", oldDag); + // 发送POST请求到Argo工作流复制接口,并将请求数据转换为JSON + String req = HttpUtils.sendPost(argoUrl + argoWorkflowCopy , JsonUtils.mapToJson(requestData)); + // 检查响应是否为空或无内容 + if (StringUtils.isEmpty(req)) { + throw new RuntimeException("工作流复制接口响应内容为空"); + } + // 将响应的JSON字符串转换为Map对象 + Map runResMap = JsonUtils.jsonToMap(req); + // 从响应Map中获取"data"的值,也就是日志的值 + String newDag = (String) runResMap.get("data"); + if (newDag == null){ + throw new RuntimeException("响应内容为空。"); + } + duplicateWorkflow.setDag(newDag); + duplicateWorkflow.setDescription(workflow.getDescription()); + return this.insert(duplicateWorkflow); + } catch (Exception e) { + throw new RuntimeException("复制流水线失败: " + e.getMessage(), e); + + } + } return null; + } -// @Override -// public Workflow saveWorkflow(Long id) { -// Workflow workflow = this.queryById(id); -// if (workflow!= null) { -// workflow.setState(1); -// -// //todo (set DAG) -// return this.update(workflow); -// } -// -// return null; -// -// } + } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/LogRequestVo.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/LogRequestVo.java new file mode 100644 index 00000000..a4622e70 --- /dev/null +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/vo/LogRequestVo.java @@ -0,0 +1,64 @@ +package com.ruoyi.platform.vo; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import io.swagger.annotations.ApiModelProperty; + +@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) +public class LogRequestVo { + @JsonProperty("component_id") + private String componentId; + + private String namespace; + + private String name; + + @JsonProperty("task_id") + private String taskId; + + @JsonProperty("start_time") + private String startTime; + + // Getters and Setters + public String getComponentId() { + return componentId; + } + + public void setComponentId(String componentId) { + this.componentId = componentId; + } + + public String getNamespace() { + return namespace; + } + + public void setNamespace(String namespace) { + this.namespace = namespace; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + +}