test metrics 스케줄 추가
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package com.kamco.cd.training.postgres.core;
|
||||
|
||||
import com.kamco.cd.training.postgres.repository.schedule.ModelTestMetricsJobRepository;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ModelTestMetricsJobCoreService {
|
||||
|
||||
private final ModelTestMetricsJobRepository modelTestMetricsJobRepository;
|
||||
|
||||
@Transactional
|
||||
public void updateModelMetricsTrainSaveYn(Long modelId, String stepNo) {
|
||||
modelTestMetricsJobRepository.updateModelMetricsTrainSaveYn(modelId, stepNo);
|
||||
}
|
||||
|
||||
// Test 로직 시작
|
||||
public List<Long> getTestMetricSaveNotYetModelIds() {
|
||||
return modelTestMetricsJobRepository.getTestMetricSaveNotYetModelIds();
|
||||
}
|
||||
|
||||
public void insertModelMetricsTest(List<Object[]> batchArgs) {
|
||||
modelTestMetricsJobRepository.insertModelMetricsTest(batchArgs);
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,9 @@ import java.util.List;
|
||||
|
||||
public interface ModelTestMetricsJobRepositoryCustom {
|
||||
|
||||
List<Long> getTrainMetricSaveNotYetModelIds();
|
||||
|
||||
void insertModelMetricsTrain(List<Object[]> batchArgs);
|
||||
|
||||
void updateModelMetricsTrainSaveYn(Long modelId, String stepNo);
|
||||
|
||||
void insertModelMetricsValidation(List<Object[]> batchArgs);
|
||||
List<Long> getTestMetricSaveNotYetModelIds();
|
||||
|
||||
void insertModelMetricsTest(List<Object[]> batchArgs);
|
||||
}
|
||||
|
||||
@@ -22,33 +22,6 @@ public class ModelTestMetricsJobRepositoryImpl extends QuerydslRepositorySupport
|
||||
this.jdbcTemplate = jdbcTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getTrainMetricSaveNotYetModelIds() {
|
||||
return queryFactory
|
||||
.select(modelMasterEntity.id)
|
||||
.from(modelMasterEntity)
|
||||
.where(
|
||||
modelMasterEntity.step1EndDttm.isNotNull(),
|
||||
modelMasterEntity.step1State.eq(TrainStatusType.COMPLETED.getId()),
|
||||
modelMasterEntity
|
||||
.step1MetricSaveYn
|
||||
.isNull()
|
||||
.or(modelMasterEntity.step1MetricSaveYn.isFalse()))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertModelMetricsTrain(List<Object[]> batchArgs) {
|
||||
String sql =
|
||||
"""
|
||||
insert into tb_model_matrics_train
|
||||
(model_id, epoch, iteration, loss, lr, duration_time)
|
||||
values (?, ?, ?, ?, ?, ?)
|
||||
""";
|
||||
|
||||
jdbcTemplate.batchUpdate(sql, batchArgs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateModelMetricsTrainSaveYn(Long modelId, String stepNo) {
|
||||
queryFactory
|
||||
@@ -63,15 +36,30 @@ public class ModelTestMetricsJobRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertModelMetricsValidation(List<Object[]> batchArgs) {
|
||||
public List<Long> getTestMetricSaveNotYetModelIds() {
|
||||
return queryFactory
|
||||
.select(modelMasterEntity.id)
|
||||
.from(modelMasterEntity)
|
||||
.where(
|
||||
modelMasterEntity.step2EndDttm.isNotNull(),
|
||||
modelMasterEntity.step2State.eq(TrainStatusType.COMPLETED.getId()),
|
||||
modelMasterEntity
|
||||
.step2MetricSaveYn
|
||||
.isNull()
|
||||
.or(modelMasterEntity.step2MetricSaveYn.isFalse()))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertModelMetricsTest(List<Object[]> batchArgs) {
|
||||
String sql =
|
||||
"""
|
||||
insert into tb_model_matrics_validation
|
||||
(model_id, epoch, a_acc, m_fscore, m_precision, m_recall, m_iou, m_acc, changed_fscore, changed_precision, changed_recall,
|
||||
unchanged_fscore, unchanged_precision, unchanged_recall
|
||||
)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""";
|
||||
insert into tb_model_metrics_test
|
||||
(model_id, model, tp, fp, fn, precisions, recall, f1_score, accuracy, iou,
|
||||
detection_count, gt_count
|
||||
)
|
||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""";
|
||||
|
||||
jdbcTemplate.batchUpdate(sql, batchArgs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user