test 실행 시 회차별 데이터 적재하기 #121
@@ -122,4 +122,8 @@ public class ModelTrainJobCoreService {
|
||||
|
||||
if (Objects.equals(job.getTotalEpoch(), epoch)) {}
|
||||
}
|
||||
|
||||
public void insertModelTestTrainingRun(Long modelId, Long jobId, int epoch) {
|
||||
modelTrainJobRepository.insertModelTestTrainingRun(modelId, jobId, epoch);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.kamco.cd.training.postgres.entity;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.OffsetDateTime;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "tb_model_test_training_run")
|
||||
public class ModelTestTrainingRunEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "tsr_id", nullable = false)
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "model_id", nullable = false)
|
||||
private Long modelId;
|
||||
|
||||
@Column(name = "attempt_no")
|
||||
private Integer attemptNo;
|
||||
|
||||
@Column(name = "job_id")
|
||||
private Long jobId;
|
||||
|
||||
@Column(name = "epoch")
|
||||
private Integer epoch;
|
||||
|
||||
@ColumnDefault("now()")
|
||||
@Column(name = "created_dttm")
|
||||
private OffsetDateTime createdDttm;
|
||||
}
|
||||
@@ -9,4 +9,6 @@ public interface ModelTrainJobRepositoryCustom {
|
||||
Optional<ModelTrainJobEntity> findLatestByModelId(Long modelId);
|
||||
|
||||
Optional<ModelTrainJobEntity> findByContainerName(String containerName);
|
||||
|
||||
void insertModelTestTrainingRun(Long modelId, Long jobId, int epoch);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.kamco.cd.training.postgres.repository.train;
|
||||
|
||||
import static com.kamco.cd.training.postgres.entity.QModelTestTrainingRunEntity.modelTestTrainingRunEntity;
|
||||
|
||||
import com.kamco.cd.training.postgres.entity.ModelTrainJobEntity;
|
||||
import com.kamco.cd.training.postgres.entity.QModelTrainJobEntity;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
@@ -54,4 +56,26 @@ public class ModelTrainJobRepositoryImpl implements ModelTrainJobRepositoryCusto
|
||||
|
||||
return Optional.ofNullable(job);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertModelTestTrainingRun(Long modelId, Long jobId, int epoch) {
|
||||
Integer maxAttemptNo =
|
||||
queryFactory
|
||||
.select(modelTestTrainingRunEntity.attemptNo.max().coalesce(0))
|
||||
.from(modelTestTrainingRunEntity)
|
||||
.where(modelTestTrainingRunEntity.modelId.eq(modelId))
|
||||
.fetchOne();
|
||||
|
||||
int nextAttemptNo = (maxAttemptNo == null ? 1 : maxAttemptNo + 1);
|
||||
|
||||
queryFactory
|
||||
.insert(modelTestTrainingRunEntity)
|
||||
.columns(
|
||||
modelTestTrainingRunEntity.modelId,
|
||||
modelTestTrainingRunEntity.attemptNo,
|
||||
modelTestTrainingRunEntity.jobId,
|
||||
modelTestTrainingRunEntity.epoch)
|
||||
.values(modelId, nextAttemptNo, jobId, epoch)
|
||||
.execute();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,9 @@ public class TestJobService {
|
||||
// step2 시작으로 마킹
|
||||
modelTrainMngCoreService.markStep2InProgress(modelId, jobId);
|
||||
|
||||
// test training run 테이블에 적재하기
|
||||
modelTrainJobCoreService.insertModelTestTrainingRun(modelId, jobId, epoch);
|
||||
|
||||
eventPublisher.publishEvent(new ModelTrainJobQueuedEvent(jobId));
|
||||
return jobId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user