| @@ -68,7 +68,8 @@ public class DatasetController { | |||||
| @ApiOperation("分页查询当前用户的个人数据集,根据data_type筛选,1公开0私有") | @ApiOperation("分页查询当前用户的个人数据集,根据data_type筛选,1公开0私有") | ||||
| public AjaxResult queryByPagePersonal(Dataset dataset, @RequestParam("page") int page, | public AjaxResult queryByPagePersonal(Dataset dataset, @RequestParam("page") int page, | ||||
| @RequestParam("size") int size, | @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(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| // 设置筛选条件 | // 设置筛选条件 | ||||
| @@ -3,12 +3,14 @@ package com.ruoyi.platform.controller.experiment; | |||||
| import com.ruoyi.common.core.web.domain.AjaxResult; | import com.ruoyi.common.core.web.domain.AjaxResult; | ||||
| import com.ruoyi.platform.domain.ExperimentIns; | import com.ruoyi.platform.domain.ExperimentIns; | ||||
| import com.ruoyi.platform.service.ExperimentInsService; | import com.ruoyi.platform.service.ExperimentInsService; | ||||
| import com.ruoyi.platform.vo.LogRequestVo; | |||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| import org.springframework.data.domain.PageRequest; | import org.springframework.data.domain.PageRequest; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | import javax.annotation.Resource; | ||||
| import javax.ws.rs.POST; | |||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.Map; | import java.util.Map; | ||||
| @@ -126,6 +128,18 @@ public class ExperimentInsController { | |||||
| return AjaxResult.success(this.experimentInsService.showExperimentInsLog(id,componentId)); | 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)); | |||||
| } | |||||
| /** | /** | ||||
| @@ -51,10 +51,14 @@ public class ModelsController { | |||||
| public AjaxResult queryByPage(Models models, @RequestParam("page") int page, | public AjaxResult queryByPage(Models models, @RequestParam("page") int page, | ||||
| @RequestParam("size") int size, | @RequestParam("size") int size, | ||||
| //@RequestParam("available_range") int availableRange, | //@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){ | if (modelType != null){ | ||||
| models.setModelType(modelType); // 设置筛选条件 | models.setModelType(modelType); // 设置筛选条件 | ||||
| } | } | ||||
| if (modelTag != null){ | |||||
| models.setModelTag(modelTag); // 设置筛选条件 | |||||
| } | |||||
| models.setAvailableRange(1); // 设置筛选条件 | models.setAvailableRange(1); // 设置筛选条件 | ||||
| PageRequest pageRequest = PageRequest.of(page, size); | PageRequest pageRequest = PageRequest.of(page, size); | ||||
| return AjaxResult.success(this.modelsService.queryByPage(models, pageRequest)); | return AjaxResult.success(this.modelsService.queryByPage(models, pageRequest)); | ||||
| @@ -73,7 +77,8 @@ public class ModelsController { | |||||
| @ApiOperation("分页查询当前用户的个人模型 ,根据model_type筛选") | @ApiOperation("分页查询当前用户的个人模型 ,根据model_type筛选") | ||||
| public AjaxResult queryByPagePersonal(Models models, @RequestParam("page") int page, | public AjaxResult queryByPagePersonal(Models models, @RequestParam("page") int page, | ||||
| @RequestParam("size") int size, | @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(); | LoginUser loginUser = SecurityUtils.getLoginUser(); | ||||
| // 设置筛选条件 | // 设置筛选条件 | ||||
| @@ -81,6 +86,9 @@ public class ModelsController { | |||||
| if (modelType != null){ | if (modelType != null){ | ||||
| models.setModelType(modelType); // 设置筛选条件 | models.setModelType(modelType); // 设置筛选条件 | ||||
| } | } | ||||
| if (modelTag != null){ | |||||
| models.setModelTag(modelTag); // 设置筛选条件 | |||||
| } | |||||
| PageRequest pageRequest = PageRequest.of(page, size); | PageRequest pageRequest = PageRequest.of(page, size); | ||||
| return AjaxResult.success(this.modelsService.queryByPage(models, pageRequest)); | return AjaxResult.success(this.modelsService.queryByPage(models, pageRequest)); | ||||
| } | } | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.ruoyi.platform.service; | package com.ruoyi.platform.service; | ||||
| import com.ruoyi.platform.domain.ExperimentIns; | import com.ruoyi.platform.domain.ExperimentIns; | ||||
| import com.ruoyi.platform.vo.LogRequestVo; | |||||
| import org.springframework.data.domain.Page; | import org.springframework.data.domain.Page; | ||||
| import org.springframework.data.domain.PageRequest; | import org.springframework.data.domain.PageRequest; | ||||
| @@ -88,4 +89,7 @@ public interface ExperimentInsService { | |||||
| String showExperimentInsLog(Integer id, String componentId); | String showExperimentInsLog(Integer id, String componentId); | ||||
| List getNodeResult(Integer id, String nodeId) throws Exception; | List getNodeResult(Integer id, String nodeId) throws Exception; | ||||
| String getRealtimeWorkflowLog(LogRequestVo logRequest); | |||||
| } | } | ||||
| @@ -1,5 +1,6 @@ | |||||
| package com.ruoyi.platform.service.impl; | package com.ruoyi.platform.service.impl; | ||||
| import com.fasterxml.jackson.core.JsonProcessingException; | |||||
| import com.ruoyi.common.security.utils.SecurityUtils; | import com.ruoyi.common.security.utils.SecurityUtils; | ||||
| import com.ruoyi.platform.domain.Experiment; | import com.ruoyi.platform.domain.Experiment; | ||||
| import com.ruoyi.platform.domain.ExperimentIns; | 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.HttpUtils; | ||||
| import com.ruoyi.platform.utils.JsonUtils; | import com.ruoyi.platform.utils.JsonUtils; | ||||
| import com.ruoyi.platform.utils.MinioUtil; | import com.ruoyi.platform.utils.MinioUtil; | ||||
| import com.ruoyi.platform.vo.LogRequestVo; | |||||
| 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.beans.factory.annotation.Value; | ||||
| @@ -49,6 +51,8 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| private String argoWorkflowTermination; | private String argoWorkflowTermination; | ||||
| @Value("${argo.workflowLog}") | @Value("${argo.workflowLog}") | ||||
| private String argoWorkflowLog; | private String argoWorkflowLog; | ||||
| @Value("${argo.workflowRealTimeLog}") | |||||
| private String argoWorkflowRealTimeLog; | |||||
| private final MinioUtil minioUtil; | private final MinioUtil minioUtil; | ||||
| public ExperimentInsServiceImpl(MinioUtil minioUtil) { | public ExperimentInsServiceImpl(MinioUtil minioUtil) { | ||||
| @@ -452,6 +456,40 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| return results; | 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<String,Object> 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<String,Object> 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 { | private boolean isTerminatedState(ExperimentIns ins) throws IOException { | ||||
| // 定义终止态的列表,例如 "Succeeded", "Failed" 等 | // 定义终止态的列表,例如 "Succeeded", "Failed" 等 | ||||
| String status = ins.getStatus(); | String status = ins.getStatus(); | ||||
| @@ -195,11 +195,12 @@ public class ModelsServiceImpl implements ModelsService { | |||||
| ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); | ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray()); | ||||
| InputStreamResource resource = new InputStreamResource(inputStream); | InputStreamResource resource = new InputStreamResource(inputStream); | ||||
| return ResponseEntity.ok() | return ResponseEntity.ok() | ||||
| .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(extractFileName(objectName),"UTF-8") + "\"") | .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + URLEncoder.encode(extractFileName(objectName),"UTF-8") + "\"") | ||||
| .contentType(MediaType.APPLICATION_OCTET_STREAM) | .contentType(MediaType.APPLICATION_OCTET_STREAM) | ||||
| .body(resource); | .body(resource); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| throw new Exception("下载模型文件错误"); | throw new Exception("下载模型文件错误"); | ||||
| @@ -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; | |||||
| } | |||||
| } | |||||