|
|
|
@@ -5,6 +5,7 @@ import com.ruoyi.platform.domain.Experiment; |
|
|
|
import com.ruoyi.platform.domain.ExperimentIns; |
|
|
|
import com.ruoyi.platform.domain.Workflow; |
|
|
|
import com.ruoyi.platform.mapper.ExperimentDao; |
|
|
|
import com.ruoyi.platform.mapper.ExperimentInsDao; |
|
|
|
import com.ruoyi.platform.service.ExperimentInsService; |
|
|
|
import com.ruoyi.platform.service.ExperimentService; |
|
|
|
import com.ruoyi.platform.service.WorkflowService; |
|
|
|
@@ -35,6 +36,11 @@ public class ExperimentServiceImpl implements ExperimentService { |
|
|
|
@Resource |
|
|
|
private ExperimentDao experimentDao; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ExperimentInsDao experimentInsDao; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource |
|
|
|
@Lazy |
|
|
|
private WorkflowService workflowService; |
|
|
|
@@ -192,7 +198,7 @@ public class ExperimentServiceImpl implements ExperimentService { |
|
|
|
* @return 是否成功 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Experiment runExperiment(Integer id) { |
|
|
|
public Experiment runExperiment(Integer id) throws Exception { |
|
|
|
//先查出实验记录 |
|
|
|
Experiment experiment = this.queryById(id); |
|
|
|
|
|
|
|
@@ -200,13 +206,18 @@ public class ExperimentServiceImpl implements ExperimentService { |
|
|
|
System.out.println("No experiment"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Workflow workflow = workflowService.queryById(experiment.getWorkflowId()); |
|
|
|
if(workflow == null) { |
|
|
|
throw new RuntimeException("流水线不存在,请先创建流水线"); |
|
|
|
} |
|
|
|
|
|
|
|
String dag = workflow.getDag(); |
|
|
|
// 调argo转换接口 |
|
|
|
try { |
|
|
|
String convertRes = HttpUtils.sendPost(argoUrl + argoConvert, dag); |
|
|
|
if (convertRes == null || StringUtils.isEmpty(convertRes)) { |
|
|
|
throw new RuntimeException("Failed to convert workflow."); |
|
|
|
throw new RuntimeException("转换流水线失败"); |
|
|
|
} |
|
|
|
Map<String, Object> converMap = JsonUtils.jsonToMap(convertRes); |
|
|
|
// 组装运行接口json |
|
|
|
@@ -234,13 +245,16 @@ public class ExperimentServiceImpl implements ExperimentService { |
|
|
|
experimentIns.setArgoInsNs((String) metadata.get("namespace")); |
|
|
|
experimentIns.setArgoInsName((String) metadata.get("name")); |
|
|
|
//插入ExperimentIns表中 |
|
|
|
experimentInsService.insert(experimentIns); |
|
|
|
experimentInsDao.insert(experimentIns); |
|
|
|
|
|
|
|
}catch (Exception e){ |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
List<ExperimentIns> experimentIns = experimentInsService.queryByExperimentId(id); |
|
|
|
|
|
|
|
|
|
|
|
experiment.setExperimentInsList(experimentIns); |
|
|
|
|
|
|
|
return experiment; |
|
|
|
} |
|
|
|
|
|
|
|
@@ -253,7 +267,11 @@ public class ExperimentServiceImpl implements ExperimentService { |
|
|
|
throw new RuntimeException("Failed to add experiment."); |
|
|
|
} |
|
|
|
// 调用runExperiment方法运行实验 |
|
|
|
newExperiment = this.runExperiment(newExperiment.getId()); |
|
|
|
try { |
|
|
|
newExperiment = this.runExperiment(newExperiment.getId()); |
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
|
|
|
|
return newExperiment; |
|
|
|
} |
|
|
|
|