Browse Source

fix:修复bug

pull/56/head
西大锐 1 year ago
parent
commit
1e7bfbc8a7
3 changed files with 3 additions and 20 deletions
  1. +2
    -9
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java
  2. +1
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java
  3. +0
    -9
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java

+ 2
- 9
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java View File

@@ -353,22 +353,15 @@ public class DatasetServiceImpl implements DatasetService {
public void checkDeclaredName(Dataset insert) throws Exception { public void checkDeclaredName(Dataset insert) throws Exception {
Dataset existingDataset = datasetDao.findByName(insert.getName()); Dataset existingDataset = datasetDao.findByName(insert.getName());
if (existingDataset != null) { if (existingDataset != null) {
// Check if the found dataset is not the same as the one being inserted
// This is important if you are using this method for both insert and update operations
// You may need an identifier check here, e.g., if 'insert' has an ID and it's the same as 'existingDataset'
if (insert.getId() != null && insert.getId().equals(existingDataset.getId())) { if (insert.getId() != null && insert.getId().equals(existingDataset.getId())) {
// This is the same dataset, no duplicate name issue for update operation
// 相同数据集,无需判断
return; return;
} }


// Now we know there's another dataset with the same name
Field[] fields = Dataset.class.getDeclaredFields(); Field[] fields = Dataset.class.getDeclaredFields();

for (Field field : fields) { for (Field field : fields) {
field.setAccessible(true); // Make private fields accessible

field.setAccessible(true);
if ("name".equals(field.getName()) && field.isAnnotationPresent(CheckDuplicate.class)) { if ("name".equals(field.getName()) && field.isAnnotationPresent(CheckDuplicate.class)) {
// If the field is 'name' and is marked with CheckDuplicate annotation
CheckDuplicate annotation = field.getAnnotation(CheckDuplicate.class); CheckDuplicate annotation = field.getAnnotation(CheckDuplicate.class);
throw new Exception("重复的数据集名称: " + insert.getName() + ". " + annotation.message()); throw new Exception("重复的数据集名称: " + insert.getName() + ". " + annotation.message());
} }


+ 1
- 2
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java View File

@@ -427,7 +427,6 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
throw new RuntimeException("日志为空。"); throw new RuntimeException("日志为空。");
} }
//返回日志内容 //返回日志内容

return experimentInsLog; return experimentInsLog;
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException("查询实验日志失败: " + e.getMessage(), e); throw new RuntimeException("查询实验日志失败: " + e.getMessage(), e);
@@ -554,7 +553,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
// 查询具有相同状态的实例数量 // 查询具有相同状态的实例数量
Long count = experimentInsDao.count(experimentIns); Long count = experimentInsDao.count(experimentIns);


// 将状态及其对应的实例数量放入映射
// 将状态及其对应的实例数量放入map
statusCountMap.put(status.toString(), count); statusCountMap.put(status.toString(), count);
} }




+ 0
- 9
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java View File

@@ -238,20 +238,16 @@ public class ExperimentServiceImpl implements ExperimentService {
Map<String ,Object> output = (Map<String, Object>) converMap.get("output"); Map<String ,Object> output = (Map<String, Object>) converMap.get("output");
// 调argo运行接口 // 调argo运行接口
String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap)); String runRes = HttpUtils.sendPost(argoUrl + argoWorkflowRun, JsonUtils.mapToJson(runReqMap));

if (runRes == null || StringUtils.isEmpty(runRes)) { if (runRes == null || StringUtils.isEmpty(runRes)) {
throw new RuntimeException("Failed to run workflow."); throw new RuntimeException("Failed to run workflow.");
} }
Map<String, Object> runResMap = JsonUtils.jsonToMap(runRes); Map<String, Object> runResMap = JsonUtils.jsonToMap(runRes);
Map<String, Object> data = (Map<String, Object>) runResMap.get("data"); Map<String, Object> data = (Map<String, Object>) runResMap.get("data");

//判断data为空 //判断data为空
if (data == null || MapUtils.isEmpty(data)) { if (data == null || MapUtils.isEmpty(data)) {
throw new RuntimeException("Failed to run workflow."); throw new RuntimeException("Failed to run workflow.");
} }

Map<String, Object> metadata = (Map<String, Object>) data.get("metadata"); Map<String, Object> metadata = (Map<String, Object>) data.get("metadata");

// 插入记录到实验实例表 // 插入记录到实验实例表
ExperimentIns experimentIns = new ExperimentIns(); ExperimentIns experimentIns = new ExperimentIns();
experimentIns.setExperimentId(experiment.getId()); experimentIns.setExperimentId(experiment.getId());
@@ -260,22 +256,17 @@ public class ExperimentServiceImpl implements ExperimentService {
experimentIns.setStatus("Pending"); experimentIns.setStatus("Pending");


//传入实验全局参数 //传入实验全局参数

experimentIns.setGlobalParam(experiment.getGlobalParam()); experimentIns.setGlobalParam(experiment.getGlobalParam());

//替换argoInsName //替换argoInsName
String outputString = JsonUtils.mapToJson(output); String outputString = JsonUtils.mapToJson(output);
experimentIns.setNodesResult(outputString.replace("{{workflow.name}}", (String) metadata.get("name"))); experimentIns.setNodesResult(outputString.replace("{{workflow.name}}", (String) metadata.get("name")));
//插入ExperimentIns表中 //插入ExperimentIns表中
experimentInsService.insert(experimentIns); experimentInsService.insert(experimentIns);

}catch (Exception e){ }catch (Exception e){
throw new RuntimeException(e); throw new RuntimeException(e);
} }
List<ExperimentIns> updatedExperimentInsList = experimentInsService.getByExperimentId(id); List<ExperimentIns> updatedExperimentInsList = experimentInsService.getByExperimentId(id);

experiment.setExperimentInsList(updatedExperimentInsList); experiment.setExperimentInsList(updatedExperimentInsList);

return experiment; return experiment;
} }




Loading…
Cancel
Save