|
|
|
@@ -11,6 +11,8 @@ import com.ruoyi.platform.utils.HttpUtils; |
|
|
|
import com.ruoyi.platform.utils.JsonUtils; |
|
|
|
import com.ruoyi.platform.utils.MinioUtil; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.data.domain.Page; |
|
|
|
import org.springframework.data.domain.PageImpl; |
|
|
|
@@ -26,6 +28,8 @@ import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Service("rayInsService") |
|
|
|
public class RayInsServiceImpl implements RayInsService { |
|
|
|
private static final Logger logger = LoggerFactory.getLogger(RayInsServiceImpl.class); |
|
|
|
|
|
|
|
@Value("${argo.url}") |
|
|
|
private String argoUrl; |
|
|
|
@Value("${argo.workflowStatus}") |
|
|
|
@@ -34,8 +38,6 @@ public class RayInsServiceImpl implements RayInsService { |
|
|
|
private String argoWorkflowTermination; |
|
|
|
@Value("${minio.endpointIp}") |
|
|
|
String endpoint; |
|
|
|
@Value("${minio.dataReleaseBucketName}") |
|
|
|
private String bucketName; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private RayInsDao rayInsDao; |
|
|
|
@@ -174,8 +176,6 @@ public class RayInsServiceImpl implements RayInsService { |
|
|
|
rayIns = queryStatusFromArgo(rayIns); |
|
|
|
} |
|
|
|
getTrialList(rayIns); |
|
|
|
|
|
|
|
// rayIns.setTrialList(getTrialList(rayIns.getResultPath())); |
|
|
|
return rayIns; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -276,12 +276,12 @@ public class RayInsServiceImpl implements RayInsService { |
|
|
|
rayIns.setResultPath(endpoint + "/" + directoryPath); |
|
|
|
rayIns.setResultTxt(endpoint + "/" + directoryPath + "/result.txt"); |
|
|
|
|
|
|
|
String bucketName = directoryPath.substring(0, directoryPath.indexOf("/")); |
|
|
|
String prefix = directoryPath.substring(directoryPath.indexOf("/") + 1, directoryPath.length()) + "/"; |
|
|
|
List<Map> maps = minioUtil.listRayFilesInDirectory(bucketName, prefix); |
|
|
|
List<Map> fileMaps = minioUtil.listRayFilesInDirectory(bucketName, prefix); |
|
|
|
|
|
|
|
if (!maps.isEmpty()) { |
|
|
|
rayIns.setFileList(maps); |
|
|
|
List<Map> collect = maps.stream().filter(map -> map.get("name").toString().startsWith("experiment_state")).collect(Collectors.toList()); |
|
|
|
if (!fileMaps.isEmpty()) { |
|
|
|
List<Map> collect = fileMaps.stream().filter(map -> map.get("name").toString().startsWith("experiment_state")).collect(Collectors.toList()); |
|
|
|
if (!collect.isEmpty()) { |
|
|
|
Path experimentState = Paths.get(collect.get(0).get("name").toString()); |
|
|
|
String content = minioUtil.readObjectAsString(bucketName, prefix + "/" + experimentState); |
|
|
|
@@ -294,8 +294,9 @@ public class RayInsServiceImpl implements RayInsService { |
|
|
|
Map<String, Object> trial_data_0 = JsonUtils.jsonToMap((String) trial_data.get(0)); |
|
|
|
Map<String, Object> trial_data_1 = JsonUtils.jsonToMap((String) trial_data.get(1)); |
|
|
|
|
|
|
|
String trialId = (String) trial_data_0.get("trial_id"); |
|
|
|
Map<String, Object> trial = new HashMap<>(); |
|
|
|
trial.put("trial_id", trial_data_0.get("trial_id")); |
|
|
|
trial.put("trial_id", trialId); |
|
|
|
trial.put("config", trial_data_0.get("config")); |
|
|
|
trial.put("status", trial_data_0.get("status")); |
|
|
|
|
|
|
|
@@ -310,10 +311,44 @@ public class RayInsServiceImpl implements RayInsService { |
|
|
|
trial.put("metric_analysis", metric_analysis.get((String) param.get("metric"))); |
|
|
|
trial.put("metric", param.get("metric")); |
|
|
|
|
|
|
|
for (Map fileMap : fileMaps) { |
|
|
|
if (fileMap.get("name").toString().contains(trialId)) { |
|
|
|
trial.put("file", fileMap); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
String resultTxt = minioUtil.readObjectAsString(bucketName, prefix + "result.txt"); |
|
|
|
String bestTrialId = getStringBetween(resultTxt, "'trial_id': '", "'"); |
|
|
|
if (bestTrialId.equals(trialId)) { |
|
|
|
trial.put("is_best", true); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error("未找到结果文件:result.txt"); |
|
|
|
} |
|
|
|
trialList.add(trial); |
|
|
|
} |
|
|
|
rayIns.setTrialList(trialList); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String getStringBetween(String input, String startMarker, String endMarker) { |
|
|
|
int startIndex = input.indexOf(startMarker); |
|
|
|
if (startIndex == -1) { |
|
|
|
return ""; // 如果未找到起始标记,返回空字符串 |
|
|
|
} |
|
|
|
|
|
|
|
// 跳过起始标记 |
|
|
|
startIndex += startMarker.length(); |
|
|
|
|
|
|
|
int endIndex = input.indexOf(endMarker, startIndex); |
|
|
|
if (endIndex == -1) { |
|
|
|
return ""; // 如果未找到结束标记,返回空字符串 |
|
|
|
} |
|
|
|
|
|
|
|
return input.substring(startIndex, endIndex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|