新增字段参数记录

This commit is contained in:
fanshuai 2024-06-19 14:07:12 +08:00
parent 2ddfb77be5
commit 9e140d1944
3 changed files with 40 additions and 13 deletions

View File

@ -48,6 +48,9 @@ public class ExperimentIns implements Serializable {
@ApiModelProperty(value = "实验实例全局参数", notes = "以JSON字符串格式存储")
@JsonRawValue
private String globalParam;
@ApiModelProperty(value = "参数记录", notes = "以JSON字符串格式存储")
@JsonRawValue
private String metricRecord;
@ApiModelProperty(value = "开始时间")
private Date startTime;
@ -210,5 +213,12 @@ public class ExperimentIns implements Serializable {
public void setWorkflowId(Long workflowId) {this.workflowId = workflowId;}
public String getMetricRecord() {
return metricRecord;
}
public void setMetricRecord(String metricRecord) {
this.metricRecord = metricRecord;
}
}

View File

@ -251,6 +251,9 @@ public class ExperimentServiceImpl implements ExperimentService {
if (data == null || MapUtils.isEmpty(data)) {
throw new RuntimeException("Failed to run workflow.");
}
//获取训练参数
Map<String, Object> metricRecord = (Map<String, Object>) runResMap.get("metric_record");
Map<String, Object> metadata = (Map<String, Object>) data.get("metadata");
// 插入记录到实验实例表
ExperimentIns experimentIns = new ExperimentIns();

View File

@ -12,6 +12,7 @@
<result property="nodesResult" column="nodes_result" jdbcType="VARCHAR"/>
<result property="nodesLogs" column="nodes_logs" jdbcType="VARCHAR"/>
<result property="globalParam" column="global_param" jdbcType="VARCHAR"/>
<result property="metricRecord" column="metric_record" jdbcType="VARCHAR"/>
<result property="startTime" column="start_time" jdbcType="TIMESTAMP"/>
<result property="finishTime" column="finish_time" jdbcType="TIMESTAMP"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
@ -23,7 +24,7 @@
<!--查询非终止态的实例-->
<select id="queryByExperimentIsNotTerminated" resultMap="ExperimentInsMap">
select id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs,global_param, start_time, finish_time, create_by, create_time, update_by, update_time, state
select id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs,global_param,metric_record, start_time, finish_time, create_by, create_time, update_by, update_time, state
from experiment_ins
where (status NOT IN ('Terminated', 'Succeeded', 'Failed')
OR status IS NULL) and state = 1
@ -31,14 +32,14 @@
<!--查询单个-->
<select id="queryById" resultMap="ExperimentInsMap">
select id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs,global_param, start_time, finish_time, create_by, create_time, update_by, update_time, state
select id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs,global_param,metric_record, start_time, finish_time, create_by, create_time, update_by, update_time, state
from experiment_ins
where id = #{id} and state = 1
</select>
<!--查询列表-->
<select id="getByExperimentId" resultMap="ExperimentInsMap">
select id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs, global_param, start_time, finish_time, create_by, create_time, update_by, update_time, state
select id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs, global_param,metric_record, start_time, finish_time, create_by, create_time, update_by, update_time, state
from experiment_ins
where experiment_id = #{experiment_id} and state = 1
order by create_time DESC
@ -47,7 +48,7 @@
<!--查询最近的3个实例列表-->
<select id="getLatestInsList" resultMap="ExperimentInsMap">
select id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs, global_param, start_time, finish_time, create_by, create_time, update_by, update_time, state
select id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs, global_param,metric_record, start_time, finish_time, create_by, create_time, update_by, update_time, state
from experiment_ins
where state = 1
order by create_time DESC
@ -58,7 +59,7 @@
<select id="queryByExperiment" resultMap="ExperimentInsMap">
select
id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs,global_param, start_time, finish_time, create_by, create_time, update_by, update_time, state
id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs,global_param,metric_record, start_time, finish_time, create_by, create_time, update_by, update_time, state
from experiment_ins
<where>
state = 1
@ -86,6 +87,9 @@
<if test="experimentIns.globalParam != null and experimentIns.globalParam != ''">
and global_param = #{experimentIns.globalParam}
</if>
<if test="experimentIns.metricRecord != null and experimentIns.metricRecord != ''">
and metric_record = #{experimentIns.metricRecord}
</if>
<if test="experimentIns.startTime != null">
and start_time = #{experimentIns.startTime}
</if>
@ -110,7 +114,7 @@
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="ExperimentInsMap">
select
id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs,global_param, start_time, finish_time, create_by, create_time, update_by, update_time, state
id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs,global_param,metric_record, start_time, finish_time, create_by, create_time, update_by, update_time, state
from experiment_ins
<where>
state = 1
@ -138,6 +142,9 @@
<if test="experimentIns.globalParam != null and experimentIns.globalParam != ''">
and global_param = #{experimentIns.globalParam}
</if>
<if test="experimentIns.metricRecord != null and experimentIns.metricRecord != ''">
and metric_record = #{experimentIns.metricRecord}
</if>
<if test="experimentIns.startTime != null">
and start_time = #{experimentIns.startTime}
</if>
@ -191,6 +198,9 @@
<if test="experimentIns.globalParam != null and experimentIns.globalParam != ''">
and global_param = #{experimentIns.globalParam}
</if>
<if test="experimentIns.metricRecord != null and experimentIns.metricRecord != ''">
and metric_record = #{experimentIns.metricRecord}
</if>
<if test="experimentIns.startTime != null">
and start_time = #{experimentIns.startTime}
</if>
@ -213,23 +223,23 @@
</select>
<select id="queryByExperimentId" resultMap="ExperimentInsMap">
select id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs, global_param, start_time, finish_time, create_by, create_time, update_by, update_time, state
select id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status,nodes_result, nodes_logs, global_param,metric_record, start_time, finish_time, create_by, create_time, update_by, update_time, state
from experiment_ins
where experiment_id = #{id} and state = 1
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into experiment_ins(experiment_id,argo_ins_name,argo_ins_ns,status,nodes_status,nodes_result,nodes_logs,global_param,start_time,finish_time,create_by,create_time,update_by,update_time,state)
values (#{experimentIns.experimentId},#{experimentIns.argoInsName},#{experimentIns.argoInsNs},#{experimentIns.status},#{experimentIns.nodesStatus},#{experimentIns.nodesResult},#{experimentIns.nodesLogs},#{experimentIns.globalParam},#{experimentIns.startTime},#{experimentIns.finishTime},#{experimentIns.createBy},#{experimentIns.createTime},#{experimentIns.updateBy},#{experimentIns.updateTime},#{experimentIns.state})
insert into experiment_ins(experiment_id,argo_ins_name,argo_ins_ns,status,nodes_status,nodes_result,nodes_logs,global_param,metric_record,start_time,finish_time,create_by,create_time,update_by,update_time,state)
values (#{experimentIns.experimentId},#{experimentIns.argoInsName},#{experimentIns.argoInsNs},#{experimentIns.status},#{experimentIns.nodesStatus},#{experimentIns.nodesResult},#{experimentIns.nodesLogs},#{experimentIns.globalParam},#{experimentIns.metricRecord},#{experimentIns.startTime},#{experimentIns.finishTime},#{experimentIns.createBy},#{experimentIns.createTime},#{experimentIns.updateBy},#{experimentIns.updateTime},#{experimentIns.state})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into
experiment_ins(experiment_id,argo_ins_name,argo_ins_ns,status,nodes_status,nodes_result,nodes_logs,global_param,start_time,finish_time,create_by,create_time,update_by,update_time,state)
experiment_ins(experiment_id,argo_ins_name,argo_ins_ns,status,nodes_status,nodes_result,nodes_logs,global_param,metric_record,start_time,finish_time,create_by,create_time,update_by,update_time,state)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.experimentId},#{entity.argoInsName},#{entity.argoInsNs},#{entity.status},#{entity.nodesStatus},#{entity.nodesResult},#{entity.nodesLogs},#{entity.globalParam},#{entity.startTime},#{entity.finishTime},#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
(#{entity.experimentId},#{entity.argoInsName},#{entity.argoInsNs},#{entity.status},#{entity.nodesStatus},#{entity.nodesResult},#{entity.nodesLogs},#{entity.globalParam},#{entity.metricRecord},#{entity.startTime},#{entity.finishTime},#{entity.createBy},#{entity.createTime},#{entity.updateBy},#{entity.updateTime},#{entity.state})
</foreach>
</insert>
@ -244,10 +254,10 @@
<!-- experiment_id = values(experiment_id)argo_ins_name = values(argo_ins_name)argo_ins_ns = values(argo_ins_ns)status = values(status) nodes_status = values(nodes_status) create_by = values(create_by)create_time = values(create_time)update_by = values(update_by)update_time = values(update_time)state = values(state)-->
<!-- </insert>-->
<update id="insertOrUpdateBatch">
insert into experiment_ins (id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status, nodes_result, nodes_logs, global_param, start_time, finish_time, create_by, create_time, update_by, update_time, state)
insert into experiment_ins (id, experiment_id, argo_ins_name, argo_ins_ns, status, nodes_status, nodes_result, nodes_logs, global_param,metric_record, start_time, finish_time, create_by, create_time, update_by, update_time, state)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id}, #{item.experimentId}, #{item.argoInsName}, #{item.argoInsNs}, #{item.status}, #{item.nodesStatus}, #{item.nodesResult}, #{item.nodesLogs}, #{item.globalParam}, #{item.startTime}, #{item.finishTime}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.state})
(#{item.id}, #{item.experimentId}, #{item.argoInsName}, #{item.argoInsNs}, #{item.status}, #{item.nodesStatus}, #{item.nodesResult}, #{item.nodesLogs}, #{item.globalParam},#{item.metricRecord}, #{item.startTime}, #{item.finishTime}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.state})
</foreach>
ON DUPLICATE KEY UPDATE
experiment_id = VALUES(experiment_id),
@ -258,6 +268,7 @@
nodes_result = VALUES(nodes_result),
nodes_logs = VALUES(nodes_logs),
global_param = VALUES(global_param),
metric_record = VALUES(metric_record),
start_time = VALUES(start_time),
finish_time = VALUES(finish_time),
create_by = VALUES(create_by),
@ -294,6 +305,9 @@
<if test="experimentIns.globalParam != null and experimentIns.globalParam != ''">
global_param = #{experimentIns.globalParam},
</if>
<if test="experimentIns.metricRecord != null and experimentIns.metricRecord != ''">
and metric_record = #{experimentIns.metricRecord}
</if>
<if test="experimentIns.startTime != null">
start_time = #{experimentIns.startTime},
</if>