| @@ -1,14 +1,12 @@ | |||
| package com.ruoyi.platform.service.impl; | |||
| import com.ruoyi.platform.domain.ExperimentIns; | |||
| import com.ruoyi.platform.domain.ModelDependency; | |||
| import com.ruoyi.platform.service.AimService; | |||
| import com.ruoyi.platform.service.ExperimentInsService; | |||
| import com.ruoyi.platform.service.ModelDependencyService; | |||
| import com.ruoyi.platform.utils.AIM64EncoderUtil; | |||
| import com.ruoyi.platform.utils.HttpUtils; | |||
| import com.ruoyi.platform.utils.JacksonUtil; | |||
| import com.ruoyi.platform.utils.JsonUtils; | |||
| import com.ruoyi.platform.utils.NewHttpUtils; | |||
| import com.ruoyi.platform.vo.InsMetricInfoVo; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| @@ -28,6 +26,8 @@ public class AimServiceImpl implements AimService { | |||
| private String aimUrl; | |||
| @Value("${aim.proxyUrl}") | |||
| private String aimProxyUrl; | |||
| @Resource | |||
| private NewHttpUtils httpUtils; | |||
| @Override | |||
| public List<InsMetricInfoVo> getExpTrainInfos(Integer experimentId) throws Exception { | |||
| @@ -52,7 +52,7 @@ public class AimServiceImpl implements AimService { | |||
| } | |||
| String encodedUrlString = URLEncoder.encode("run.experiment==\""+experimentName+"\"", "UTF-8"); | |||
| String url = aimProxyUrl+"/api/runs/search/run?query="+encodedUrlString; | |||
| String s = HttpUtils.sendGetRequest(url); | |||
| String s = httpUtils.sendGet(url,null); | |||
| List<Map<String, Object>> response = JacksonUtil.parseJSONStr2MapList(s); | |||
| System.out.println("response: "+JacksonUtil.toJSONString(response)); | |||
| if (response == null || response.size() == 0){ | |||
| @@ -56,6 +56,8 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||
| @Value("${minio.endpoint}") | |||
| private String minioEndpoint; | |||
| @Resource | |||
| private NewHttpUtils httpUtils; | |||
| @Resource | |||
| private K8sClientUtil k8sClientUtil; | |||
| private final MinioUtil minioUtil; | |||
| public ExperimentInsServiceImpl(MinioUtil minioUtil) { | |||
| @@ -263,7 +265,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||
| try { | |||
| // 发送POST请求到Argo工作流状态查询接口,并将请求数据转换为JSON | |||
| String req = HttpUtils.sendPost(argoUrl + argoWorkflowStatus, JsonUtils.mapToJson(res)); | |||
| String req = httpUtils.sendPost(argoUrl + argoWorkflowStatus,null, JsonUtils.mapToJson(res)); | |||
| // 检查响应是否为空或无内容 | |||
| if (req == null || StringUtils.isEmpty(req)) { | |||
| throw new RuntimeException("工作流状态响应为空。"); | |||
| @@ -357,7 +359,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||
| try { | |||
| // 发送POST请求到Argo工作流状态查询接口,并将请求数据转换为JSON | |||
| String req = HttpUtils.sendPost(argoUrl + argoWorkflowTermination, JsonUtils.mapToJson(res)); | |||
| String req = httpUtils.sendPost(argoUrl + argoWorkflowTermination,null, JsonUtils.mapToJson(res)); | |||
| // 检查响应是否为空或无内容 | |||
| if (StringUtils.isEmpty(req)) { | |||
| throw new RuntimeException("终止响应内容为空。"); | |||
| @@ -415,7 +417,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||
| try { | |||
| // 发送POST请求到Argo工作流日志查询接口,并将请求数据转换为JSON | |||
| String req = HttpUtils.sendPost(argoUrl + argoWorkflowLog, JsonUtils.mapToJson(res)); | |||
| String req = httpUtils.sendPost(argoUrl + argoWorkflowLog, null,JsonUtils.mapToJson(res)); | |||
| // 检查响应是否为空或无内容 | |||
| if (StringUtils.isEmpty(req)) { | |||
| throw new RuntimeException("响应内容为空"); | |||
| @@ -8,9 +8,9 @@ import com.ruoyi.platform.domain.dependencydomain.TrainTaskDepency; | |||
| import com.ruoyi.platform.mapper.ExperimentDao; | |||
| import com.ruoyi.platform.mapper.ExperimentInsDao; | |||
| import com.ruoyi.platform.service.*; | |||
| import com.ruoyi.platform.utils.HttpUtils; | |||
| import com.ruoyi.platform.utils.JacksonUtil; | |||
| import com.ruoyi.platform.utils.JsonUtils; | |||
| import com.ruoyi.platform.utils.NewHttpUtils; | |||
| import com.ruoyi.system.api.model.LoginUser; | |||
| import org.apache.commons.collections4.MapUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -55,7 +55,8 @@ public class ExperimentServiceImpl implements ExperimentService { | |||
| @Resource | |||
| @Lazy | |||
| private ExperimentInsService experimentInsService; | |||
| @Resource | |||
| private NewHttpUtils httpUtils; | |||
| @Value("${argo.url}") | |||
| private String argoUrl; | |||
| @Value("${argo.convert}") | |||
| @@ -222,7 +223,7 @@ public class ExperimentServiceImpl implements ExperimentService { | |||
| String dag = workflow.getDag(); | |||
| // 调argo转换接口 | |||
| try { | |||
| String convertRes = HttpUtils.sendPost(argoUrl + argoConvert, dag); | |||
| String convertRes = httpUtils.sendPost(argoUrl + argoConvert,null, dag); | |||
| if (convertRes == null || StringUtils.isEmpty(convertRes)) { | |||
| throw new RuntimeException("转换流水线失败"); | |||
| } | |||
| @@ -241,7 +242,7 @@ public class ExperimentServiceImpl implements ExperimentService { | |||
| Map<String ,Object> output = (Map<String, Object>) converMap.get("output"); | |||
| // 调argo运行接口 | |||
| String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap)); | |||
| String runRes = httpUtils.sendPost(argoUrl + argoWorkflowRun,null, JsonUtils.mapToJson(runReqMap)); | |||
| if (runRes == null || StringUtils.isEmpty(runRes)) { | |||
| throw new RuntimeException("Failed to run workflow."); | |||
| @@ -2,9 +2,9 @@ package com.ruoyi.platform.service.impl; | |||
| import com.ruoyi.common.security.utils.SecurityUtils; | |||
| import com.ruoyi.platform.service.GitService; | |||
| import com.ruoyi.platform.utils.HttpUtils; | |||
| import com.ruoyi.platform.utils.JacksonUtil; | |||
| import com.ruoyi.platform.utils.JsonUtils; | |||
| import com.ruoyi.platform.utils.NewHttpUtils; | |||
| import com.ruoyi.platform.vo.GitProjectVo; | |||
| import com.ruoyi.system.api.model.LoginUser; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -16,9 +16,9 @@ import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.stereotype.Service; | |||
| import redis.clients.jedis.Jedis; | |||
| import javax.annotation.Resource; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| import java.util.Collections; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -32,7 +32,8 @@ public class GitServiceImpl implements GitService { | |||
| private Integer redisPort; | |||
| @Value("${git.endpoint}") | |||
| String gitendpoint; | |||
| @Resource | |||
| private NewHttpUtils httpUtils; | |||
| private static final Logger log = LoggerFactory.getLogger(GitServiceImpl.class); | |||
| @Override | |||
| @@ -46,7 +47,7 @@ public class GitServiceImpl implements GitService { | |||
| params.put("client_secret", "L3wBKTNnRo-wPen7bxR3F1myCvtVDgpWa6MnpfyWeJE"); | |||
| try { | |||
| // 发送POST请求 | |||
| String req = HttpUtils.sendPostRequest(gitendpoint + "/oauth/token", null, JsonUtils.mapToJson(params)); | |||
| String req = httpUtils.sendPost(gitendpoint + "/oauth/token", null,JsonUtils.mapToJson(params)); | |||
| // 解析响应JSON | |||
| if (StringUtils.isEmpty(req)) { | |||
| throw new RuntimeException("终止响应内容为空。"); | |||
| @@ -58,7 +59,7 @@ public class GitServiceImpl implements GitService { | |||
| String accessToken = (String) runResMap.get("access_token"); | |||
| //通过access_token获取用户信息 | |||
| String userReq = HttpUtils.sendGetWithToken(gitendpoint + "/api/users/get_user_info.json", null, accessToken); | |||
| String userReq = httpUtils.sendGetWithToken(gitendpoint + "/api/users/get_user_info.json", null, accessToken); | |||
| if (StringUtils.isEmpty(userReq)) { | |||
| throw new RuntimeException("终止响应内容为空。"); | |||
| } | |||
| @@ -103,7 +104,7 @@ public class GitServiceImpl implements GitService { | |||
| @Override | |||
| public Map createProject(String token,GitProjectVo gitProjectVo) throws Exception { | |||
| String userReq = HttpUtils.sendPostWithToken(gitendpoint + "/api/projects.json", JsonUtils.objectToJson(gitProjectVo), token); | |||
| String userReq = httpUtils.sendPostWithToken(gitendpoint + "/api/projects.json",null, token,JsonUtils.objectToJson(gitProjectVo)); | |||
| return JsonUtils.jsonToMap(userReq); | |||
| } | |||
| @@ -118,7 +119,7 @@ public class GitServiceImpl implements GitService { | |||
| Map<String, Object> resMap = new HashMap<>(); | |||
| resMap.put("new_branch_name", branchName); | |||
| resMap.put("old_branch_name", oldBranchName); | |||
| String req = HttpUtils.sendPostWithToken(createBranchUrl, JsonUtils.objectToJson(resMap), token); | |||
| String req = httpUtils.sendPostWithToken(createBranchUrl, null, token,JsonUtils.objectToJson(resMap)); | |||
| System.out.println(req); | |||
| } | |||
| @@ -128,12 +129,12 @@ public class GitServiceImpl implements GitService { | |||
| Map<String, Object> resMap = new HashMap<>(); | |||
| resMap.put("project_id", id); | |||
| resMap.put("name", topicName); | |||
| String req = HttpUtils.sendPostWithToken(gitendpoint + "/api/v1/project_topics.json", JsonUtils.objectToJson(resMap), token); | |||
| String req = httpUtils.sendPostWithToken(gitendpoint + "/api/v1/project_topics.json",null, token ,JsonUtils.objectToJson(resMap)); | |||
| } | |||
| @Override | |||
| public List<Map<String, Object>> getBrancheList(String token,String owner, String projectName) throws Exception { | |||
| String req = HttpUtils.sendGetWithToken(gitendpoint + "/api/v1/" + owner + "/" + projectName + "/branches/all.json", null, token); | |||
| String req = httpUtils.sendGetWithToken(gitendpoint + "/api/v1/" + owner + "/" + projectName + "/branches/all.json", null, token); | |||
| // 解析响应JSON | |||
| if (StringUtils.isEmpty(req)) { | |||
| throw new RuntimeException("终止响应内容为空。"); | |||
| @@ -145,7 +146,7 @@ public class GitServiceImpl implements GitService { | |||
| @Override | |||
| public void deleteProject(String token,String owner, String projectName) throws Exception { | |||
| HttpUtils.sendDeleteRequest(gitendpoint + "/api/" + owner + "/" + projectName + ".json", token); | |||
| httpUtils.sendDeleteWithToken(gitendpoint + "/api/" + owner + "/" + projectName + ".json", null, token); | |||
| } | |||
| @Override | |||
| @@ -156,12 +157,12 @@ public class GitServiceImpl implements GitService { | |||
| } catch (IOException | GitAPIException e) { | |||
| log.error("Exception occurred while creating local branch based on master",e); | |||
| } | |||
| HttpUtils.sendDeleteRequest(gitendpoint + "/api/v1/" + owner + "/" + projectName + "/branches/" + branchName + ".json", token); | |||
| httpUtils.sendDeleteWithToken(gitendpoint + "/api/v1/" + owner + "/" + projectName + "/branches/" + branchName + ".json", null, token); | |||
| } | |||
| @Override | |||
| public Map getUserInfo(String token) throws Exception { | |||
| String userReq = HttpUtils.sendGetWithToken(gitendpoint + "/api/users/get_user_info.json",null, token); | |||
| String userReq = httpUtils.sendGetWithToken(gitendpoint + "/api/users/get_user_info.json",null, token); | |||
| if (StringUtils.isEmpty(userReq)){ | |||
| return null; | |||
| } | |||
| @@ -76,7 +76,8 @@ public class ModelsServiceImpl implements ModelsService { | |||
| @Resource | |||
| private AssetIconService assetIconService; | |||
| @Resource | |||
| private NewHttpUtils httpUtils; | |||
| // 固定存储桶名 | |||
| @Value("${minio.dataReleaseBucketName}") | |||
| @@ -845,7 +846,7 @@ public class ModelsServiceImpl implements ModelsService { | |||
| url = url + "&search=" + name; | |||
| } | |||
| String req = HttpUtils.sendGetWithToken(url, null, token); | |||
| String req = httpUtils.sendGetWithToken(url, null, token); | |||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||
| Integer total = (Integer) stringObjectMap.get("count"); | |||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||
| @@ -876,7 +877,7 @@ public class ModelsServiceImpl implements ModelsService { | |||
| url = url + "&search=" + name; | |||
| } | |||
| String req = HttpUtils.sendGetWithToken(url, null, token); | |||
| String req = httpUtils.sendGetWithToken(url, null, token); | |||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||
| Integer total = (Integer) stringObjectMap.get("total_count"); | |||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||
| @@ -63,6 +63,8 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||
| @Value("${git.localPath}") | |||
| String localPathlocal; | |||
| @Resource | |||
| private NewHttpUtils httpUtils; | |||
| @Resource | |||
| private DatasetTempStorageService datasetTempStorageService; | |||
| @Override | |||
| public String newCreateDataset(NewDatasetVo datasetVo) throws Exception { | |||
| @@ -236,7 +238,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||
| if (StringUtils.isNotEmpty(name)){ | |||
| url =url + "&search=" + name; | |||
| } | |||
| String req = HttpUtils.sendGetWithToken(url, null, token); | |||
| String req = httpUtils.sendGetWithToken(url, null, token); | |||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||
| Integer total = (Integer) stringObjectMap.get("count"); | |||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||
| @@ -264,7 +266,7 @@ public class NewDatasetServiceImpl implements NewDatasetService { | |||
| url =url + "&search=" + name; | |||
| } | |||
| String req = HttpUtils.sendGetWithToken(url, null, token); | |||
| String req = httpUtils.sendGetWithToken(url, null, token); | |||
| Map<String, Object> stringObjectMap = JacksonUtil.parseJSONStr2Map(req); | |||
| Integer total = (Integer) stringObjectMap.get("total_count"); | |||
| List<Map<String, Object>> projects = (List<Map<String, Object>>) stringObjectMap.get("projects"); | |||
| @@ -2,15 +2,14 @@ package com.ruoyi.platform.service.impl; | |||
| import com.ruoyi.common.security.utils.SecurityUtils; | |||
| import com.ruoyi.platform.annotations.CheckDuplicate; | |||
| import com.ruoyi.platform.domain.Dataset; | |||
| import com.ruoyi.platform.domain.Experiment; | |||
| 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.platform.utils.NewHttpUtils; | |||
| import com.ruoyi.system.api.model.LoginUser; | |||
| import org.apache.commons.lang.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| @@ -45,7 +44,8 @@ public class WorkflowServiceImpl implements WorkflowService { | |||
| @Value("${argo.workflowCopy}") | |||
| private String argoWorkflowCopy; | |||
| @Resource | |||
| private NewHttpUtils httpUtils; | |||
| private final MinioUtil minioUtil; | |||
| public WorkflowServiceImpl(MinioUtil minioUtil) { | |||
| @@ -172,7 +172,7 @@ public class WorkflowServiceImpl implements WorkflowService { | |||
| Map<String,Object> requestData = new HashMap<>(); | |||
| requestData.put("data", oldDag); | |||
| // 发送POST请求到Argo工作流复制接口,并将请求数据转换为JSON | |||
| String req = HttpUtils.sendPost(argoUrl + argoWorkflowCopy , JsonUtils.mapToJson(requestData)); | |||
| String req = httpUtils.sendPost(argoUrl + argoWorkflowCopy,null , JsonUtils.mapToJson(requestData)); | |||
| // 检查响应是否为空或无内容 | |||
| if (StringUtils.isEmpty(req)) { | |||
| throw new RuntimeException("工作流复制接口响应内容为空"); | |||
| @@ -3,7 +3,7 @@ server: | |||
| port: 9201 | |||
| # Spring | |||
| spring: | |||
| spring: | |||
| application: | |||
| # 应用名称 | |||
| name: ruoyi-system | |||
| @@ -13,21 +13,13 @@ spring: | |||
| cloud: | |||
| nacos: | |||
| discovery: | |||
| namespace: 6caf5d79-c4ce-4e3b-a357-141b74e52a01 | |||
| # 服务注册地址 | |||
| server-addr: 172.20.32.181:8848 | |||
| username: nacos | |||
| password: h1n2x3j4y5@ | |||
| retry: | |||
| enabled: true | |||
| server-addr: 172.20.32.181:18847 | |||
| config: | |||
| namespace: 6caf5d79-c4ce-4e3b-a357-141b74e52a01 | |||
| # 配置中心地址 | |||
| server-addr: 172.20.32.181:8848 | |||
| server-addr: 172.20.32.181:18847 | |||
| # 配置文件格式 | |||
| file-extension: yml | |||
| # 共享配置 | |||
| shared-configs: | |||
| - data-id: application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} | |||
| group: DEFAULT_GROUP | |||
| refresh: true | |||
| - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} | |||