Browse Source

Merge remote-tracking branch 'origin/dev' into dev

pull/56/head
fanshuai 1 year ago
parent
commit
305e6382de
5 changed files with 25 additions and 42 deletions
  1. +6
    -6
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ModelDependency.java
  2. +2
    -9
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/DatasetServiceImpl.java
  3. +1
    -2
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentInsServiceImpl.java
  4. +0
    -9
      ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/service/impl/ExperimentServiceImpl.java
  5. +16
    -16
      ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ModelDependencyDaoMapper.xml

+ 6
- 6
ruoyi-modules/management-platform/src/main/java/com/ruoyi/platform/domain/ModelDependency.java View File

@@ -24,9 +24,9 @@ public class ModelDependency implements Serializable {
*/ */
private Integer currentModelId; private Integer currentModelId;
/** /**
* 父模型id
* 父模型
*/ */
private Integer parentModelId;
private String parentModels;
/** /**
* 引用项目 * 引用项目
*/ */
@@ -88,12 +88,12 @@ public class ModelDependency implements Serializable {
this.currentModelId = currentModelId; this.currentModelId = currentModelId;
} }


public Integer getParentModelId() {
return parentModelId;
public String getParentModels() {
return parentModels;
} }


public void setParentModelId(Integer parentModelId) {
this.parentModelId = parentModelId;
public void setParentModels(String parentModels) {
this.parentModels = parentModels;
} }


public String getRefItem() { public String getRefItem() {


+ 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;
} }




+ 16
- 16
ruoyi-modules/management-platform/src/main/resources/mapper/managementPlatform/ModelDependencyDaoMapper.xml View File

@@ -5,7 +5,7 @@
<resultMap type="com.ruoyi.platform.domain.ModelDependency" id="ModelDependencyMap"> <resultMap type="com.ruoyi.platform.domain.ModelDependency" id="ModelDependencyMap">
<result property="id" column="id" jdbcType="INTEGER"/> <result property="id" column="id" jdbcType="INTEGER"/>
<result property="currentModelId" column="current_model_id" jdbcType="INTEGER"/> <result property="currentModelId" column="current_model_id" jdbcType="INTEGER"/>
<result property="parentModelId" column="parent_model_id" jdbcType="INTEGER"/>
<result property="parentModels" column="parent_models" jdbcType="VARCHAR"/>
<result property="refItem" column="ref_item" jdbcType="VARCHAR"/> <result property="refItem" column="ref_item" jdbcType="VARCHAR"/>
<result property="trainTask" column="train_task" jdbcType="VARCHAR"/> <result property="trainTask" column="train_task" jdbcType="VARCHAR"/>
<result property="trainDataset" column="train_dataset" jdbcType="VARCHAR"/> <result property="trainDataset" column="train_dataset" jdbcType="VARCHAR"/>
@@ -21,7 +21,7 @@
<!--查询单个--> <!--查询单个-->
<select id="queryById" resultMap="ModelDependencyMap"> <select id="queryById" resultMap="ModelDependencyMap">
select select
id,current_model_id,parent_model_id,ref_item,train_task,train_dataset,test_dataset,project_dependency,create_by,create_time,update_by,update_time,state
id,current_model_id,parent_models,ref_item,train_task,train_dataset,test_dataset,project_dependency,create_by,create_time,update_by,update_time,state
from model_dependency from model_dependency
where id = #{id} where id = #{id}
</select> </select>
@@ -29,7 +29,7 @@
<!--查询指定行数据--> <!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="ModelDependencyMap"> <select id="queryAllByLimit" resultMap="ModelDependencyMap">
select select
id,current_model_id,parent_model_id,ref_item,train_task,train_dataset,test_dataset,project_dependency,create_by,create_time,update_by,update_time,state
id,current_model_id,parent_models,ref_item,train_task,train_dataset,test_dataset,project_dependency,create_by,create_time,update_by,update_time,state
from model_dependency from model_dependency
<where> <where>
<if test="modelDependency.id != null"> <if test="modelDependency.id != null">
@@ -38,8 +38,8 @@
<if test="modelDependency.currentModelId != null"> <if test="modelDependency.currentModelId != null">
and current_model_id = #{modelDependency.currentModelId} and current_model_id = #{modelDependency.currentModelId}
</if> </if>
<if test="modelDependency.parentModelId != null">
and parent_model_id = #{modelDependency.parentModelId}
<if test="modelDependency.parentModels != null">
and parent_models = #{modelDependency.parentModels}
</if> </if>
<if test="modelDependency.refItem != null and modelDependency.refItem != ''"> <if test="modelDependency.refItem != null and modelDependency.refItem != ''">
and ref_item = #{modelDependency.refItem} and ref_item = #{modelDependency.refItem}
@@ -86,8 +86,8 @@
<if test="modelDependency.currentModelId != null"> <if test="modelDependency.currentModelId != null">
and current_model_id = #{modelDependency.currentModelId} and current_model_id = #{modelDependency.currentModelId}
</if> </if>
<if test="modelDependency.parentModelId != null">
and parent_model_id = #{modelDependency.parentModelId}
<if test="modelDependency.parentModels != null">
and parent_models = #{modelDependency.parentModels}
</if> </if>
<if test="modelDependency.refItem != null and modelDependency.refItem != ''"> <if test="modelDependency.refItem != null and modelDependency.refItem != ''">
and ref_item = #{modelDependency.refItem} and ref_item = #{modelDependency.refItem}
@@ -126,7 +126,7 @@
<insert id="insert" keyProperty="id" useGeneratedKeys="true"> <insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into model_dependency ( insert into model_dependency (
current_model_id, current_model_id,
parent_model_id,
parent_models,
ref_item, ref_item,
train_task, train_task,
train_dataset, train_dataset,
@@ -140,7 +140,7 @@
) )
values ( values (
#{currentModelId}, #{currentModelId},
#{parentModelId},
#{parentModels},
#{refItem}, #{refItem},
#{trainTask}, #{trainTask},
#{trainDataset}, #{trainDataset},
@@ -158,7 +158,7 @@
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true"> <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into model_dependency ( insert into model_dependency (
current_model_id, current_model_id,
parent_model_id,
parent_models,
ref_item, ref_item,
train_task, train_task,
train_dataset, train_dataset,
@@ -174,7 +174,7 @@
<foreach collection="entities" item="entity" separator=","> <foreach collection="entities" item="entity" separator=",">
( (
#{entity.currentModelId}, #{entity.currentModelId},
#{entity.parentModelId},
#{entity.parentModels},
#{entity.refItem}, #{entity.refItem},
#{entity.trainTask}, #{entity.trainTask},
#{entity.trainDataset}, #{entity.trainDataset},
@@ -191,13 +191,13 @@




<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true"> <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
insert into model_dependency(current_model_idparent_model_idref_itemtrain_tasktrain_datasettest_datasetcreate_bycreate_timeupdate_byupdate_timestate)
insert into model_dependency(current_model_idparent_modelsref_itemtrain_tasktrain_datasettest_datasetcreate_bycreate_timeupdate_byupdate_timestate)
values values
<foreach collection="entities" item="entity" separator=","> <foreach collection="entities" item="entity" separator=",">
(#{entity.currentModelId}#{entity.parentModelId}#{entity.refItem}#{entity.trainTask}#{entity.trainDataset}#{entity.testDataset}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state})
(#{entity.currentModelId}#{entity.parentModels}#{entity.refItem}#{entity.trainTask}#{entity.trainDataset}#{entity.testDataset}#{entity.createBy}#{entity.createTime}#{entity.updateBy}#{entity.updateTime}#{entity.state})
</foreach> </foreach>
on duplicate key update on duplicate key update
current_model_id = values(current_model_id)parent_model_id = values(parent_model_id)ref_item = values(ref_item)train_task = values(train_task)train_dataset = values(train_dataset)test_dataset = values(test_dataset)create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state)
current_model_id = values(current_model_id)parent_models = values(parent_models)ref_item = values(ref_item)train_task = values(train_task)train_dataset = values(train_dataset)test_dataset = values(test_dataset)create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state)
</insert> </insert>


<!--通过主键修改数据--> <!--通过主键修改数据-->
@@ -207,8 +207,8 @@ current_model_id = values(current_model_id)parent_model_id = values(parent_model
<if test="modelDependency.currentModelId != null"> <if test="modelDependency.currentModelId != null">
current_model_id = #{modelDependency.currentModelId}, current_model_id = #{modelDependency.currentModelId},
</if> </if>
<if test="modelDependency.parentModelId != null">
parent_model_id = #{modelDependency.parentModelId},
<if test="modelDependency.parentModels != null">
parent_models = #{modelDependency.parentModels},
</if> </if>
<if test="modelDependency.refItem != null and modelDependency.refItem != ''"> <if test="modelDependency.refItem != null and modelDependency.refItem != ''">
ref_item = #{modelDependency.refItem}, ref_item = #{modelDependency.refItem},


Loading…
Cancel
Save