Merge remote-tracking branch 'origin/feat/training_260202' into feat/training_260202

This commit is contained in:
2026-02-20 14:30:42 +09:00

View File

@@ -65,16 +65,48 @@ public class ModelTestMetricsJobRepositoryImpl extends QuerydslRepositorySupport
@Override @Override
public void insertModelMetricsTest(List<Object[]> batchArgs) { public void insertModelMetricsTest(List<Object[]> batchArgs) {
String sql = // AS-IS
""" // String sql =
insert into tb_model_metrics_test // """
(model_id, model, tp, fp, fn, precisions, recall, f1_score, accuracy, iou, // insert into tb_model_metrics_test
detection_count, gt_count // (model_id, model, tp, fp, fn, precisions, recall, f1_score, accuracy, iou,
) // detection_count, gt_count
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) // )
"""; // values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
// """;
//
// jdbcTemplate.batchUpdate(sql, batchArgs);
jdbcTemplate.batchUpdate(sql, batchArgs); // TO-BE: modelId, model(best_fscore_10) 같은 데이터가 있으면 update, 없으면 insert
String updateSql =
"""
UPDATE tb_model_metrics_test
SET tp=?, fp=?, fn=?, precisions=?, recall=?, f1_score=?, accuracy=?, iou=?,
detection_count=?, gt_count=?
WHERE model_id=? AND model=?
""";
String insertSql =
"""
INSERT INTO tb_model_metrics_test
(model_id, model, tp, fp, fn, precisions, recall, f1_score, accuracy, iou,
detection_count, gt_count)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""";
// row 단위 처리 (batch 안에서 upsert)
for (Object[] row : batchArgs) {
// row 순서: (model_id, model, tp, fp, fn, precisions, recall, f1_score, accuracy, iou,
// detection_count, gt_count)
int updated =
jdbcTemplate.update(
updateSql, row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10],
row[11], row[0], row[1]);
if (updated == 0) {
jdbcTemplate.update(insertSql, row);
}
}
} }
@Override @Override
@@ -99,11 +131,9 @@ public class ModelTestMetricsJobRepositoryImpl extends QuerydslRepositorySupport
.on( .on(
modelMetricsTestEntity.model.eq(modelMetricsTrainEntity.model), modelMetricsTestEntity.model.eq(modelMetricsTrainEntity.model),
modelMasterEntity.bestEpoch.eq(modelMetricsTrainEntity.epoch)) modelMasterEntity.bestEpoch.eq(modelMetricsTrainEntity.epoch))
.where( .where(modelMetricsTestEntity.model.id.eq(modelId))
modelMetricsTestEntity.model.id.eq(modelId), .orderBy(modelMetricsTestEntity.createdDttm.desc())
modelMetricsTestEntity.model1.eq( .fetchFirst();
"best_changed_fscore_epoch_" + modelMasterEntity.bestEpoch))
.fetchOne();
} }
@Override @Override