diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java index e5112ab5..4d4b4149 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/controller/activeLearn/ActiveLearnInsController.java @@ -6,6 +6,7 @@ import com.ruoyi.platform.domain.ActiveLearnIns; import com.ruoyi.platform.service.ActiveLearnInsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import org.springframework.data.domain.PageRequest; import org.springframework.web.bind.annotation.*; import org.springframework.data.domain.Page; @@ -57,4 +58,11 @@ public class ActiveLearnInsController extends BaseController { public GenericsAjaxResult getDetailById(@PathVariable("id") Long id) throws Exception { return genericsSuccess(this.activeLearnInsService.getDetailById(id)); } + + @PostMapping("/getExpMetrics") + @ApiOperation("获取当前实验的指标对比地址") + @ApiResponse + public GenericsAjaxResult getExpMetrics(@RequestBody String experimentInsId) throws Exception { + return genericsSuccess(activeLearnInsService.getExpMetrics(experimentInsId)); + } } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java index 09df121b..fa92becd 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/ActiveLearnInsService.java @@ -5,6 +5,7 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.util.List; public interface ActiveLearnInsService { @@ -25,4 +26,6 @@ public interface ActiveLearnInsService { ActiveLearnIns queryStatusFromArgo(ActiveLearnIns ins); List queryActiveLearnInsIsNotTerminated(); + + String getExpMetrics(String experimentInsId) throws Exception; } diff --git a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java index 60cb3868..97743273 100644 --- a/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java +++ b/ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ActiveLearnInsServiceImpl.java @@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.IOException; +import java.net.URLEncoder; import java.util.*; @Service @@ -34,6 +35,10 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { private String argoWorkflowTermination; @Value("${minio.endpointIp}") String endpoint; + @Value("${aim.url}") + private String aimUrl; + @Value("${aim.proxyUrl}") + private String aimProxyUrl; @Resource private ActiveLearnInsDao activeLearnInsDao; @@ -269,6 +274,22 @@ public class ActiveLearnInsServiceImpl implements ActiveLearnInsService { return activeLearnInsDao.queryActiveLearnInsIsNotTerminated(); } + @Override + public String getExpMetrics(String experimentInsId) throws Exception { + String encodedUrlString = URLEncoder.encode("run.id in " + experimentInsId, "UTF-8"); + String url = aimProxyUrl + "/api/runs/search/run?query=" + encodedUrlString; + String s = HttpUtils.sendGet(url, null); + List> responses = JacksonUtil.parseJSONStr2MapList(s); + + List runIds = new ArrayList<>(); + for (Map response : responses) { + runIds.add((String) response.get("run_hash")); + } + + String decode = AIM64EncoderUtil.decode(runIds); + return aimUrl + "/metrics?select=" + decode; + } + public void getTrialList(ActiveLearnIns ins) { String directoryPath = ins.getResultPath(); ins.setResultPath(endpoint + "/" + directoryPath + "/final_checkpoint/final_model_weights.pth");