Compare commits
30 Commits
22aa071476
...
feat/dean/
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c34ea7dcb | |||
| 3547c28361 | |||
| 6c70bfed18 | |||
| 95a75e63f4 | |||
| 2a1dbee290 | |||
| 384a321bf3 | |||
| f4e97d389b | |||
| 590810ff0a | |||
| a01c872982 | |||
| 905a245070 | |||
| 860ce35a8f | |||
| 7f3f5dca40 | |||
| 4a0a4e35ed | |||
| ae055dca1e | |||
| 26e8e1492f | |||
| 8fa722011c | |||
| 17d47d6200 | |||
| e178f58fe2 | |||
| cd0cf5726d | |||
| 8e4bea53da | |||
| 7a22d8ba73 | |||
| 2df4a7a80b | |||
| b451f697bc | |||
| 7e9c867f34 | |||
| 130e85f8a1 | |||
| 9e713cb49d | |||
| 51dfa97900 | |||
| 87c6b599b4 | |||
| f50855a822 | |||
| 8d416317a8 |
43
build.gradle
43
build.gradle
@@ -3,6 +3,7 @@ plugins {
|
||||
id 'org.springframework.boot' version '3.5.7'
|
||||
id 'io.spring.dependency-management' version '1.1.7'
|
||||
id 'com.diffplug.spotless' version '6.25.0'
|
||||
id 'idea'
|
||||
}
|
||||
|
||||
group = 'com.kamco.cd'
|
||||
@@ -21,11 +22,23 @@ configurations {
|
||||
}
|
||||
}
|
||||
|
||||
// QueryDSL 생성된 소스 디렉토리 정의
|
||||
def generatedSourcesDir = file("$buildDir/generated/sources/annotationProcessor/java/main")
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url "https://repo.osgeo.org/repository/release/" }
|
||||
}
|
||||
|
||||
// Gradle이 생성된 소스를 컴파일 경로에 포함하도록 설정
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs += generatedSourcesDir
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
@@ -87,6 +100,21 @@ dependencies {
|
||||
implementation 'org.apache.commons:commons-csv:1.10.0'
|
||||
}
|
||||
|
||||
// IntelliJ가 생성된 소스를 인식하도록 설정
|
||||
idea {
|
||||
module {
|
||||
// 소스 디렉토리로 인식
|
||||
sourceDirs += generatedSourcesDir
|
||||
|
||||
// Generated Sources Root로 마킹 (IntelliJ에서 특별 처리)
|
||||
generatedSourceDirs += generatedSourcesDir
|
||||
|
||||
// 소스 및 Javadoc 다운로드
|
||||
downloadJavadoc = true
|
||||
downloadSources = true
|
||||
}
|
||||
}
|
||||
|
||||
configurations.configureEach {
|
||||
exclude group: 'javax.media', module: 'jai_core'
|
||||
}
|
||||
@@ -95,6 +123,21 @@ tasks.named('test') {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
// 컴파일 전 생성된 소스 디렉토리 생성 보장
|
||||
tasks.named('compileJava') {
|
||||
doFirst {
|
||||
generatedSourcesDir.mkdirs()
|
||||
}
|
||||
}
|
||||
|
||||
// 생성된 소스 정리 태스크
|
||||
tasks.register('cleanGeneratedSources', Delete) {
|
||||
delete generatedSourcesDir
|
||||
}
|
||||
|
||||
tasks.named('clean') {
|
||||
dependsOn 'cleanGeneratedSources'
|
||||
}
|
||||
|
||||
bootJar {
|
||||
archiveFileName = 'ROOT.jar'
|
||||
|
||||
@@ -14,6 +14,7 @@ services:
|
||||
- /mnt/nfs_share/images:/app/original-images
|
||||
- /mnt/nfs_share/model_output:/app/model-outputs
|
||||
- /mnt/nfs_share/train_dataset:/app/train-dataset
|
||||
- /home/kcomu/data:/home/kcomu/data
|
||||
networks:
|
||||
- kamco-cds
|
||||
restart: unless-stopped
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.training.common.dto;
|
||||
|
||||
import com.kamco.cd.training.common.enums.ModelType;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@@ -14,6 +15,10 @@ public class HyperParam {
|
||||
// -------------------------
|
||||
// Important
|
||||
// -------------------------
|
||||
|
||||
@Schema(description = "모델", example = "large")
|
||||
private ModelType model; // backbone
|
||||
|
||||
@Schema(description = "백본 네트워크", example = "large")
|
||||
private String backbone; // backbone
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kamco.cd.training.common.enums;
|
||||
|
||||
import com.kamco.cd.training.common.utils.enums.CodeExpose;
|
||||
import com.kamco.cd.training.common.utils.enums.EnumType;
|
||||
import java.util.Arrays;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -15,6 +16,10 @@ public enum ModelType implements EnumType {
|
||||
|
||||
private String desc;
|
||||
|
||||
public static ModelType getValueData(String modelNo) {
|
||||
return Arrays.stream(ModelType.values()).filter(m -> m.getId().equals(modelNo)).findFirst().orElse(G1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return name();
|
||||
|
||||
@@ -506,11 +506,15 @@ public class FIleChecker {
|
||||
|
||||
try {
|
||||
File dir = new File(targetPath);
|
||||
log.info("targetPath={}", targetPath);
|
||||
log.info("absolute targetPath={}", dir.getAbsolutePath());
|
||||
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
File dest = new File(dir, String.valueOf(chunkIndex));
|
||||
log.info("real save path = {}", dest.getAbsolutePath());
|
||||
|
||||
log.info("chunkIndex={}, uploadSize={}", chunkIndex, mfile.getSize());
|
||||
log.info("savedSize={}", dest.length());
|
||||
@@ -522,6 +526,9 @@ public class FIleChecker {
|
||||
log.info("after delete={}", dest.length());
|
||||
mfile.transferTo(dest);
|
||||
|
||||
log.info("after transfer size={}", dest.length());
|
||||
log.info("after transfer exists={}", dest.exists());
|
||||
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
log.error("chunk save error", e);
|
||||
@@ -707,12 +714,17 @@ public class FIleChecker {
|
||||
}
|
||||
|
||||
public static void unzip(String fileName, String destDirectory) throws IOException {
|
||||
File destDir = new File(destDirectory);
|
||||
if (!destDir.exists()) {
|
||||
destDir.mkdirs(); // 대상 폴더가 없으면 생성
|
||||
}
|
||||
String zipFilePath = destDirectory + File.separator + fileName;
|
||||
|
||||
String zipFilePath = destDirectory + "/" + fileName;
|
||||
// zip 이름으로 폴더 생성 (확장자 제거)
|
||||
String folderName =
|
||||
fileName.endsWith(".zip") ? fileName.substring(0, fileName.length() - 4) : fileName;
|
||||
|
||||
File destDir = new File(destDirectory, folderName);
|
||||
|
||||
if (!destDir.exists()) {
|
||||
destDir.mkdirs();
|
||||
}
|
||||
|
||||
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFilePath))) {
|
||||
ZipEntry zipEntry = zis.getNextEntry();
|
||||
|
||||
@@ -14,15 +14,11 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -221,8 +217,7 @@ public class DatasetApiController {
|
||||
public ApiResponseDto<ApiResponseDto.ResponseObj> insertDataset(
|
||||
@RequestBody @Valid DatasetDto.AddReq addReq) {
|
||||
|
||||
return ApiResponseDto.ok(
|
||||
datasetService.insertDatasetTo86(addReq)); // TODO 서버 옮긴 이후에 다시 insertDataset 로 원복하기
|
||||
return ApiResponseDto.ok(datasetService.insertDataset(addReq));
|
||||
}
|
||||
|
||||
@Operation(summary = "객체별 파일 Path 조회", description = "파일 Path 조회")
|
||||
@@ -231,11 +226,7 @@ public class DatasetApiController {
|
||||
throws Exception {
|
||||
|
||||
String path = datasetService.getFilePathByUUIDPathType(uuid, pathType);
|
||||
Path filePath = Paths.get(path);
|
||||
|
||||
Resource resource = new UrlResource(filePath.toUri());
|
||||
|
||||
return ResponseEntity.ok().contentType(MediaType.APPLICATION_OCTET_STREAM).body(resource);
|
||||
return datasetService.getFilePathByFile(path);
|
||||
}
|
||||
|
||||
@Operation(summary = "객체별 파일 Path 조회", description = "파일 Path 조회")
|
||||
|
||||
@@ -4,9 +4,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.kamco.cd.training.common.enums.LearnDataType;
|
||||
import com.kamco.cd.training.common.exception.CustomApiException;
|
||||
import com.kamco.cd.training.common.service.FormatStorage;
|
||||
@@ -32,7 +29,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -168,6 +164,7 @@ public class DatasetService {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Transactional
|
||||
public ResponseObj insertDatasetTo86(@Valid AddReq addReq) {
|
||||
|
||||
@@ -226,6 +223,17 @@ public class DatasetService {
|
||||
idx++;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> valList =
|
||||
getUnzipDatasetFiles(
|
||||
addReq.getFilePath() + addReq.getFileName().replace(".zip", ""), "val");
|
||||
|
||||
int valIdx = 0;
|
||||
for (Map<String, Object> valid : valList) {
|
||||
datasetUid =
|
||||
this.insertTrainTestData(valid, addReq, valIdx, datasetUid, "val"); // val 데이터 insert
|
||||
valIdx++;
|
||||
}
|
||||
|
||||
List<Map<String, Object>> testList =
|
||||
getUnzipDatasetFiles(
|
||||
addReq.getFilePath() + addReq.getFileName().replace(".zip", ""), "test");
|
||||
@@ -332,6 +340,8 @@ public class DatasetService {
|
||||
|
||||
if (subDir.equals("train")) {
|
||||
datasetCoreService.insertDatasetObj(objRegDto);
|
||||
} else if (subDir.equals("val")) {
|
||||
datasetCoreService.insertDatasetValObj(objRegDto);
|
||||
} else {
|
||||
datasetCoreService.insertDatasetTestObj(objRegDto);
|
||||
}
|
||||
@@ -404,6 +414,7 @@ public class DatasetService {
|
||||
return datasetCoreService.getFilePathByUUIDPathType(uuid, pathType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private List<Map<String, Object>> getUnzipDatasetFilesTo86(String unzipRootPath, String subDir) {
|
||||
|
||||
// String root = Paths.get(unzipRootPath)
|
||||
@@ -487,29 +498,9 @@ public class DatasetService {
|
||||
|
||||
public ResponseEntity<Resource> getFilePathByFile(String remoteFilePath) {
|
||||
|
||||
String host = "192.168.2.86";
|
||||
String user = "kcomu";
|
||||
String password = "Kamco2025!";
|
||||
|
||||
Session session = null;
|
||||
ChannelSftp sftp = null;
|
||||
|
||||
try {
|
||||
JSch jsch = new JSch();
|
||||
|
||||
session = jsch.getSession(user, host, 22);
|
||||
session.setPassword(password);
|
||||
|
||||
Properties config = new Properties();
|
||||
config.put("StrictHostKeyChecking", "no");
|
||||
session.setConfig(config);
|
||||
session.connect(10_000);
|
||||
|
||||
sftp = (ChannelSftp) session.openChannel("sftp");
|
||||
sftp.connect(5_000);
|
||||
|
||||
// 86 서버 파일을 스트림으로 연다
|
||||
InputStream inputStream = sftp.get(normalizeLinuxPath(remoteFilePath));
|
||||
Path path = Paths.get(remoteFilePath);
|
||||
InputStream inputStream = Files.newInputStream(path);
|
||||
|
||||
InputStreamResource resource =
|
||||
new InputStreamResource(inputStream) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.training.hyperparam;
|
||||
|
||||
import com.kamco.cd.training.common.dto.HyperParam;
|
||||
import com.kamco.cd.training.common.enums.ModelType;
|
||||
import com.kamco.cd.training.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto.List;
|
||||
@@ -65,7 +66,7 @@ public class HyperParamApiController {
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = String.class))),
|
||||
@ApiResponse(responseCode = "400", description = "잘못된 요청", content = @Content),
|
||||
@ApiResponse(responseCode = "422", description = "HPs_0001 수정 불가", content = @Content),
|
||||
@ApiResponse(responseCode = "422", description = "default는 삭제불가", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PutMapping("/{uuid}")
|
||||
@@ -87,8 +88,9 @@ public class HyperParamApiController {
|
||||
@ApiResponse(responseCode = "404", description = "하이퍼파라미터를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/list")
|
||||
@GetMapping("{model}/list")
|
||||
public ApiResponseDto<Page<List>> getHyperParam(
|
||||
@PathVariable ModelType model,
|
||||
@Parameter(
|
||||
description = "구분 CREATE_DATE(생성일), LAST_USED_DATE(최근사용일)",
|
||||
example = "CREATE_DATE")
|
||||
@@ -98,7 +100,7 @@ public class HyperParamApiController {
|
||||
LocalDate startDate,
|
||||
@Parameter(description = "종료일", example = "2026-02-28") @RequestParam(required = false)
|
||||
LocalDate endDate,
|
||||
@Parameter(description = "버전명", example = "HPs_0001") @RequestParam(required = false)
|
||||
@Parameter(description = "버전명", example = "G_000001") @RequestParam(required = false)
|
||||
String hyperVer,
|
||||
@Parameter(
|
||||
description = "정렬",
|
||||
@@ -124,7 +126,7 @@ public class HyperParamApiController {
|
||||
searchReq.setSort(sort);
|
||||
searchReq.setPage(page);
|
||||
searchReq.setSize(size);
|
||||
Page<List> list = hyperParamService.getHyperParamList(searchReq);
|
||||
Page<List> list = hyperParamService.getHyperParamList(model, searchReq);
|
||||
|
||||
return ApiResponseDto.ok(list);
|
||||
}
|
||||
@@ -133,7 +135,7 @@ public class HyperParamApiController {
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(responseCode = "200", description = "삭제 성공", content = @Content),
|
||||
@ApiResponse(responseCode = "422", description = "HPs_0001 삭제 불가", content = @Content),
|
||||
@ApiResponse(responseCode = "422", description = "default 삭제 불가", content = @Content),
|
||||
@ApiResponse(responseCode = "404", description = "하이퍼파라미터를 찾을 수 없음", content = @Content),
|
||||
})
|
||||
@DeleteMapping("/{uuid}")
|
||||
@@ -179,8 +181,11 @@ public class HyperParamApiController {
|
||||
@ApiResponse(responseCode = "404", description = "하이퍼파라미터를 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/init")
|
||||
public ApiResponseDto<HyperParamDto.Basic> getInitHyperParam() {
|
||||
return ApiResponseDto.ok(hyperParamService.getInitHyperParam());
|
||||
@GetMapping("/init/{model}")
|
||||
public ApiResponseDto<HyperParamDto.Basic> getInitHyperParam(
|
||||
@PathVariable ModelType model
|
||||
|
||||
) {
|
||||
return ApiResponseDto.ok(hyperParamService.getInitHyperParam(model));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.training.hyperparam.dto;
|
||||
|
||||
import com.kamco.cd.training.common.enums.ModelType;
|
||||
import com.kamco.cd.training.common.utils.enums.CodeExpose;
|
||||
import com.kamco.cd.training.common.utils.enums.EnumType;
|
||||
import com.kamco.cd.training.common.utils.interfaces.JsonFormatDttm;
|
||||
@@ -24,6 +25,7 @@ public class HyperParamDto {
|
||||
@AllArgsConstructor
|
||||
public static class Basic {
|
||||
|
||||
private ModelType model; // 20250212 modeltype추가
|
||||
private UUID uuid;
|
||||
private String hyperVer;
|
||||
@JsonFormatDttm private ZonedDateTime createdDttm;
|
||||
@@ -98,6 +100,8 @@ public class HyperParamDto {
|
||||
private Integer gpuCnt;
|
||||
private String gpuIds;
|
||||
private Integer masterPort;
|
||||
|
||||
private Boolean isDefault;
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.kamco.cd.training.hyperparam.service;
|
||||
|
||||
import com.kamco.cd.training.common.dto.HyperParam;
|
||||
import com.kamco.cd.training.common.enums.ModelType;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto.List;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto.SearchReq;
|
||||
import com.kamco.cd.training.postgres.core.HyperParamCoreService;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -20,11 +22,12 @@ public class HyperParamService {
|
||||
/**
|
||||
* 하이퍼 파라미터 목록 조회
|
||||
*
|
||||
* @param model
|
||||
* @param req
|
||||
* @return 목록
|
||||
*/
|
||||
public Page<List> getHyperParamList(HyperParamDto.SearchReq req) {
|
||||
return hyperParamCoreService.findByHyperVerList(req);
|
||||
public Page<List> getHyperParamList(ModelType model, SearchReq req) {
|
||||
return hyperParamCoreService.findByHyperVerList(model, req);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,8 +62,8 @@ public class HyperParamService {
|
||||
}
|
||||
|
||||
/** 하이퍼파라미터 최적화 설정값 조회 */
|
||||
public HyperParamDto.Basic getInitHyperParam() {
|
||||
return hyperParamCoreService.getInitHyperParam();
|
||||
public HyperParamDto.Basic getInitHyperParam(ModelType model) {
|
||||
return hyperParamCoreService.getInitHyperParam(model);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.kamco.cd.training.model;
|
||||
import com.kamco.cd.training.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.MappingDataset;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelBestEpoch;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelTestMetrics;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelTrainMetrics;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelValidationMetrics;
|
||||
@@ -200,4 +201,25 @@ public class ModelTrainDetailApiController {
|
||||
UUID uuid) {
|
||||
return ApiResponseDto.ok(modelTrainDetailService.getModelTestMetricResult(uuid));
|
||||
}
|
||||
|
||||
@Operation(summary = "모델관리 > 모델 상세 > 성능 정보 (Test)", description = "모델 상세 > 성능 정보 (Test) API")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "조회 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = TransferDetailDto.class))),
|
||||
@ApiResponse(responseCode = "404", description = "데이터셋을 찾을 수 없음", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/best-epoch/{uuid}")
|
||||
public ApiResponseDto<ModelBestEpoch> getModelTrainBestEpoch(
|
||||
@Parameter(description = "모델 uuid", example = "95cb116c-380a-41c0-98d8-4d1142f15bbf")
|
||||
@PathVariable
|
||||
UUID uuid) {
|
||||
return ApiResponseDto.ok(modelTrainDetailService.getModelTrainBestEpoch(uuid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,13 +74,12 @@ public class ModelTrainMngApiController {
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(responseCode = "200", description = "삭제 성공", content = @Content),
|
||||
@ApiResponse(responseCode = "409", description = "HPs_0001 삭제 불가", content = @Content)
|
||||
@ApiResponse(responseCode = "409", description = "G1_000001 삭제 불가", content = @Content)
|
||||
})
|
||||
@DeleteMapping("/{uuid}")
|
||||
public ApiResponseDto<Void> deleteModelTrain(
|
||||
@Parameter(description = "학습 모델 uuid", example = "f2b02229-90f2-45f5-92ea-c56cf1c29f79")
|
||||
@PathVariable
|
||||
UUID uuid) {
|
||||
@PathVariable UUID uuid) {
|
||||
modelTrainMngService.deleteModelTrain(uuid);
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
@@ -92,9 +91,8 @@ public class ModelTrainMngApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PostMapping
|
||||
public ApiResponseDto<String> createModelTrain(@Valid @RequestBody ModelTrainMngDto.AddReq req) {
|
||||
modelTrainMngService.createModelTrain(req);
|
||||
return ApiResponseDto.ok("ok");
|
||||
public ApiResponseDto<UUID> createModelTrain(@Valid @RequestBody ModelTrainMngDto.AddReq req) {
|
||||
return ApiResponseDto.ok(modelTrainMngService.createModelTrain(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "모델학습 config 정보 조회", description = "모델학습 config 정보 조회 API")
|
||||
@@ -150,4 +148,22 @@ public class ModelTrainMngApiController {
|
||||
req.setDataType(selectType);
|
||||
return ApiResponseDto.ok(modelTrainMngService.getDatasetSelectList(req));
|
||||
}
|
||||
|
||||
@Operation(summary = "모델학습 1단계 실행중인 것이 있는지 count", description = "모델학습 1단계 실행중인 것이 있는지 count")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "검색 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = Long.class))),
|
||||
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping("/ing-training-cnt")
|
||||
public ApiResponseDto<Long> findModelStep1InProgressCnt() {
|
||||
return ApiResponseDto.ok(modelTrainMngService.findModelStep1InProgressCnt());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,4 +231,18 @@ public class ModelTrainDetailDto {
|
||||
private Long detectionCount;
|
||||
private Long gtCount;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ModelBestEpoch {
|
||||
private Integer epoch;
|
||||
private Double loss;
|
||||
private Float f1Score;
|
||||
private Float precision;
|
||||
private Float recall;
|
||||
private Float iou;
|
||||
private Float accuracy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,6 +155,17 @@ public class ModelTrainMngDto {
|
||||
ModelConfig modelConfig;
|
||||
}
|
||||
|
||||
@Schema(name = "addReq", description = "모델학습 관리 등록 파라미터")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class UpdateReq {
|
||||
|
||||
private String requestPath;
|
||||
private String responsePath;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class TrainingDataset {
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.kamco.cd.training.model.dto.ModelConfigDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.DetailSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.HyperSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.MappingDataset;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelBestEpoch;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelTestMetrics;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelTrainMetrics;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelValidationMetrics;
|
||||
@@ -111,4 +112,8 @@ public class ModelTrainDetailService {
|
||||
public List<ModelTestMetrics> getModelTestMetricResult(UUID uuid) {
|
||||
return modelTrainDetailCoreService.getModelTestMetricResult(uuid);
|
||||
}
|
||||
|
||||
public ModelBestEpoch getModelTrainBestEpoch(UUID uuid) {
|
||||
return modelTrainDetailCoreService.getModelTrainBestEpoch(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ import com.kamco.cd.training.model.dto.ModelTrainMngDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.SearchReq;
|
||||
import com.kamco.cd.training.postgres.core.HyperParamCoreService;
|
||||
import com.kamco.cd.training.postgres.core.ModelTrainMngCoreService;
|
||||
import com.kamco.cd.training.train.service.TrainJobService;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -28,9 +29,9 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Slf4j
|
||||
public class ModelTrainMngService {
|
||||
|
||||
private final TrainJobService trainJobService;
|
||||
private final ModelTrainMngCoreService modelTrainMngCoreService;
|
||||
private final HyperParamCoreService hyperParamCoreService;
|
||||
private final TmpDatasetService tmpDatasetService;
|
||||
|
||||
/**
|
||||
* 모델학습 조회
|
||||
@@ -59,7 +60,7 @@ public class ModelTrainMngService {
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
public void createModelTrain(ModelTrainMngDto.AddReq req) {
|
||||
public UUID createModelTrain(ModelTrainMngDto.AddReq req) {
|
||||
HyperParam hyperParam = req.getHyperParam();
|
||||
HyperParamDto.Basic hyper = new HyperParamDto.Basic();
|
||||
|
||||
@@ -78,7 +79,10 @@ public class ModelTrainMngService {
|
||||
}
|
||||
|
||||
// 모델학습 테이블 저장
|
||||
Long modelId = modelTrainMngCoreService.saveModel(req);
|
||||
ModelTrainMngDto.Basic modelDto = modelTrainMngCoreService.saveModel(req);
|
||||
|
||||
Long modelId = modelDto.getId();
|
||||
UUID modelUuid = modelDto.getUuid();
|
||||
|
||||
// 모델학습 데이터셋 저장
|
||||
modelTrainMngCoreService.saveModelDataset(modelId, req);
|
||||
@@ -90,10 +94,23 @@ public class ModelTrainMngService {
|
||||
// 모델 config 저장
|
||||
modelTrainMngCoreService.saveModelConfig(modelId, req.getModelConfig());
|
||||
|
||||
// 저장 다 끝난 뒤에 job enqueue
|
||||
if (Boolean.TRUE.equals(req.getIsStart())) {
|
||||
trainJobService.enqueue(modelId); // job 저장 + 이벤트 발행(실행은 AFTER_COMMIT)
|
||||
UUID tmpUuid = UUID.randomUUID();
|
||||
String raw = tmpUuid.toString().toUpperCase().replace("-", "");
|
||||
|
||||
List<String> uids =
|
||||
modelTrainMngCoreService.findDatasetUid(req.getTrainingDataset().getDatasetList());
|
||||
|
||||
try {
|
||||
// 데이터셋 심볼링크 생성
|
||||
Path path = tmpDatasetService.buildTmpDatasetSymlink(raw, uids);
|
||||
ModelTrainMngDto.UpdateReq updateReq = new ModelTrainMngDto.UpdateReq();
|
||||
updateReq.setRequestPath(path.toString());
|
||||
modelTrainMngCoreService.updateModelMaster(modelId, updateReq);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return modelUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,4 +136,8 @@ public class ModelTrainMngService {
|
||||
return modelTrainMngCoreService.getDatasetSelectG2G3List(req);
|
||||
}
|
||||
}
|
||||
|
||||
public Long findModelStep1InProgressCnt() {
|
||||
return modelTrainMngCoreService.findModelStep1InProgressCnt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.kamco.cd.training.model.service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class TmpDatasetService {
|
||||
|
||||
@Value("${train.docker.requestDir}")
|
||||
private String requestDir;
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public Path buildTmpDatasetSymlink(String uid, List<String> datasetUids) throws IOException {
|
||||
|
||||
// 환경에 맞게 yml로 빼는 걸 추천
|
||||
Path BASE = Paths.get(requestDir);
|
||||
Path tmp = BASE.resolve("tmp").resolve(uid);
|
||||
|
||||
// mkdir -p "$TMP"/train/{input1,input2,label} ...
|
||||
for (String type : List.of("train", "val")) {
|
||||
for (String part : List.of("input1", "input2", "label")) {
|
||||
Files.createDirectories(tmp.resolve(type).resolve(part));
|
||||
}
|
||||
}
|
||||
|
||||
for (String id : datasetUids) {
|
||||
Path srcRoot = BASE.resolve(id);
|
||||
|
||||
for (String type : List.of("train", "val")) {
|
||||
for (String part : List.of("input1", "input2", "label")) {
|
||||
|
||||
Path srcDir = srcRoot.resolve(type).resolve(part);
|
||||
|
||||
// zsh NULL_GLOB: 폴더가 없으면 그냥 continue
|
||||
if (!Files.isDirectory(srcDir)) continue;
|
||||
|
||||
try (DirectoryStream<Path> stream = Files.newDirectoryStream(srcDir)) {
|
||||
for (Path f : stream) {
|
||||
if (!Files.isRegularFile(f)) continue;
|
||||
|
||||
String dstName = id + "__" + f.getFileName();
|
||||
Path dst = tmp.resolve(type).resolve(part).resolve(dstName);
|
||||
|
||||
// 이미 있으면 스킵(원하면 덮어쓰기 로직으로 바꿀 수 있음)
|
||||
if (Files.exists(dst)) continue;
|
||||
|
||||
// ln -s "$f" "$dst" 와 동일
|
||||
Files.createSymbolicLink(dst, f.toAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info("tmp dataset created: {}", tmp);
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
@@ -242,4 +242,8 @@ public class DatasetCoreService
|
||||
|
||||
entity.setStatus(LearnDataRegister.COMPLETED.getId());
|
||||
}
|
||||
|
||||
public void insertDatasetValObj(DatasetObjRegDto objRegDto) {
|
||||
datasetObjRepository.insertDatasetValObj(objRegDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.kamco.cd.training.postgres.core;
|
||||
|
||||
import com.kamco.cd.training.common.dto.HyperParam;
|
||||
import com.kamco.cd.training.common.enums.ModelType;
|
||||
import com.kamco.cd.training.common.exception.CustomApiException;
|
||||
import com.kamco.cd.training.common.utils.UserUtil;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto.Basic;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto.SearchReq;
|
||||
import com.kamco.cd.training.postgres.entity.ModelHyperParamEntity;
|
||||
import com.kamco.cd.training.postgres.repository.hyperparam.HyperParamRepository;
|
||||
import java.time.ZonedDateTime;
|
||||
@@ -17,6 +19,7 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class HyperParamCoreService {
|
||||
|
||||
private final HyperParamRepository hyperParamRepository;
|
||||
private final UserUtil userUtil;
|
||||
|
||||
@@ -27,7 +30,7 @@ public class HyperParamCoreService {
|
||||
* @return 등록된 버전명
|
||||
*/
|
||||
public Basic createHyperParam(HyperParam createReq) {
|
||||
String firstVersion = getFirstHyperParamVersion();
|
||||
String firstVersion = getFirstHyperParamVersion(createReq.getModel());
|
||||
|
||||
ModelHyperParamEntity entity = new ModelHyperParamEntity();
|
||||
entity.setHyperVer(firstVersion);
|
||||
@@ -47,17 +50,17 @@ public class HyperParamCoreService {
|
||||
/**
|
||||
* 하이퍼파라미터 수정
|
||||
*
|
||||
* @param uuid uuid
|
||||
* @param uuid uuid
|
||||
* @param createReq 등록 요청
|
||||
* @return ver
|
||||
*/
|
||||
public String updateHyperParam(UUID uuid, HyperParam createReq) {
|
||||
ModelHyperParamEntity entity =
|
||||
hyperParamRepository
|
||||
.findHyperParamByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
hyperParamRepository
|
||||
.findHyperParamByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
|
||||
if (entity.getHyperVer().equals("HPs_0001")) {
|
||||
if (entity.getIsDefault()) {
|
||||
throw new CustomApiException("UNPROCESSABLE_ENTITY_UPDATE", HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
applyHyperParam(entity, createReq);
|
||||
@@ -69,11 +72,112 @@ public class HyperParamCoreService {
|
||||
return entity.getHyperVer();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 하이퍼파라미터 삭제
|
||||
*
|
||||
* @param uuid
|
||||
*/
|
||||
public void deleteHyperParam(UUID uuid) {
|
||||
ModelHyperParamEntity entity =
|
||||
hyperParamRepository
|
||||
.findHyperParamByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
|
||||
// if (entity.getHyperVer().equals("HPs_0001")) {
|
||||
// throw new CustomApiException("UNPROCESSABLE_ENTITY", HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
// }
|
||||
|
||||
//디폴트면 삭제불가
|
||||
if (entity.getIsDefault()) {
|
||||
throw new CustomApiException("UNPROCESSABLE_ENTITY", HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
entity.setDelYn(true);
|
||||
entity.setUpdatedUid(userUtil.getId());
|
||||
entity.setUpdatedDttm(ZonedDateTime.now());
|
||||
}
|
||||
|
||||
/**
|
||||
* 하이퍼파라미터 최적화 설정값 조회
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public HyperParamDto.Basic getInitHyperParam(ModelType model) {
|
||||
ModelHyperParamEntity entity =
|
||||
hyperParamRepository
|
||||
.getHyperparamByType(model)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
return entity.toDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 하이퍼파라미터 상세 조회
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public HyperParamDto.Basic getHyperParam(UUID uuid) {
|
||||
ModelHyperParamEntity entity =
|
||||
hyperParamRepository
|
||||
.findHyperParamByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
return entity.toDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 하이퍼파라미터 목록 조회
|
||||
*
|
||||
* @param model
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public Page<HyperParamDto.List> findByHyperVerList(ModelType model, SearchReq req) {
|
||||
return hyperParamRepository.findByHyperVerList(model, req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 하이퍼파라미터 버전 조회
|
||||
*
|
||||
* @param model 모델 타입
|
||||
* @return ver
|
||||
*/
|
||||
public String getFirstHyperParamVersion(ModelType model) {
|
||||
return hyperParamRepository
|
||||
.findHyperParamVerByModelType(model)
|
||||
.map(ModelHyperParamEntity::getHyperVer)
|
||||
.map(ver -> increase(ver, model))
|
||||
.orElse(model.name() + "_000001");
|
||||
}
|
||||
|
||||
/**
|
||||
* 하이퍼 파라미터의 버전을 증가시킨다.
|
||||
*
|
||||
* @param hyperVer 현재 버전
|
||||
* @param modelType 모델 타입
|
||||
* @return 증가된 버전
|
||||
*/
|
||||
private String increase(String hyperVer, ModelType modelType) {
|
||||
String prefix = modelType.name() + "_";
|
||||
int num = Integer.parseInt(hyperVer.substring(prefix.length()));
|
||||
return prefix + String.format("%06d", num + 1);
|
||||
}
|
||||
|
||||
private void applyHyperParam(ModelHyperParamEntity entity, HyperParam src) {
|
||||
|
||||
ModelType model = src.getModel();
|
||||
|
||||
// 하드코딩 모델별로 다른경우 250212 bbn 하드코딩
|
||||
if (model == ModelType.G3) {
|
||||
entity.setCropSize("512,512");
|
||||
} else {
|
||||
entity.setCropSize("256,256");
|
||||
}
|
||||
// entity.setCropSize(src.getCropSize());
|
||||
|
||||
// Important
|
||||
entity.setModelType(model); // 20250212 modeltype추가
|
||||
entity.setBackbone(src.getBackbone());
|
||||
entity.setInputSize(src.getInputSize());
|
||||
entity.setCropSize(src.getCropSize());
|
||||
entity.setBatchSize(src.getBatchSize());
|
||||
|
||||
// Data
|
||||
@@ -111,78 +215,4 @@ public class HyperParamCoreService {
|
||||
entity.setMemo(src.getMemo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 하이퍼파라미터 삭제
|
||||
*
|
||||
* @param uuid
|
||||
*/
|
||||
public void deleteHyperParam(UUID uuid) {
|
||||
ModelHyperParamEntity entity =
|
||||
hyperParamRepository
|
||||
.findHyperParamByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
|
||||
if (entity.getHyperVer().equals("HPs_0001")) {
|
||||
throw new CustomApiException("UNPROCESSABLE_ENTITY", HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
entity.setDelYn(true);
|
||||
entity.setUpdatedUid(userUtil.getId());
|
||||
entity.setUpdatedDttm(ZonedDateTime.now());
|
||||
}
|
||||
|
||||
/**
|
||||
* 하이퍼파라미터 최적화 설정값 조회
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public HyperParamDto.Basic getInitHyperParam() {
|
||||
ModelHyperParamEntity entity =
|
||||
hyperParamRepository
|
||||
.findHyperParamByHyperVer("HPs_0001")
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
return entity.toDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 하이퍼파라미터 상세 조회
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public HyperParamDto.Basic getHyperParam(UUID uuid) {
|
||||
ModelHyperParamEntity entity =
|
||||
hyperParamRepository
|
||||
.findHyperParamByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
return entity.toDto();
|
||||
}
|
||||
|
||||
/**
|
||||
* 하이퍼파라미터 목록 조회
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public Page<HyperParamDto.List> findByHyperVerList(HyperParamDto.SearchReq req) {
|
||||
return hyperParamRepository.findByHyperVerList(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 하이퍼파라미터 버전 조회
|
||||
*
|
||||
* @return ver
|
||||
*/
|
||||
public String getFirstHyperParamVersion() {
|
||||
return hyperParamRepository
|
||||
.findHyperParamVer()
|
||||
.map(ModelHyperParamEntity::getHyperVer)
|
||||
.map(this::increase)
|
||||
.orElse("HPs_0001");
|
||||
}
|
||||
|
||||
private String increase(String hyperVer) {
|
||||
String prefix = "HPs_";
|
||||
int num = Integer.parseInt(hyperVer.substring(prefix.length()));
|
||||
return prefix + String.format("%04d", num + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.training.postgres.core;
|
||||
|
||||
import com.kamco.cd.training.postgres.repository.train.ModelTestMetricsJobRepository;
|
||||
import com.kamco.cd.training.train.dto.ModelTrainMetricsDto.ResponsePathDto;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -18,7 +19,7 @@ public class ModelTestMetricsJobCoreService {
|
||||
}
|
||||
|
||||
// Test 로직 시작
|
||||
public List<Long> getTestMetricSaveNotYetModelIds() {
|
||||
public List<ResponsePathDto> getTestMetricSaveNotYetModelIds() {
|
||||
return modelTestMetricsJobRepository.getTestMetricSaveNotYetModelIds();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.kamco.cd.training.model.dto.ModelConfigDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.DetailSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.HyperSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.MappingDataset;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelBestEpoch;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelTestMetrics;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelTrainMetrics;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelValidationMetrics;
|
||||
@@ -92,4 +93,8 @@ public class ModelTrainDetailCoreService {
|
||||
public List<ModelTestMetrics> getModelTestMetricResult(UUID uuid) {
|
||||
return modelDetailRepository.getModelTestMetricResult(uuid);
|
||||
}
|
||||
|
||||
public ModelBestEpoch getModelTrainBestEpoch(UUID uuid) {
|
||||
return modelDetailRepository.getModelTrainBestEpoch(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.training.postgres.core;
|
||||
|
||||
import com.kamco.cd.training.postgres.repository.train.ModelTrainMetricsJobRepository;
|
||||
import com.kamco.cd.training.train.dto.ModelTrainMetricsDto.ResponsePathDto;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -12,7 +13,7 @@ public class ModelTrainMetricsJobCoreService {
|
||||
|
||||
private final ModelTrainMetricsJobRepository modelTrainMetricsJobRepository;
|
||||
|
||||
public List<Long> getTrainMetricSaveNotYetModelIds() {
|
||||
public List<ResponsePathDto> getTrainMetricSaveNotYetModelIds() {
|
||||
return modelTrainMetricsJobRepository.getTrainMetricSaveNotYetModelIds();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.kamco.cd.training.postgres.repository.model.ModelDatasetRepository;
|
||||
import com.kamco.cd.training.postgres.repository.model.ModelMngRepository;
|
||||
import com.kamco.cd.training.train.dto.TrainRunRequest;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -64,9 +65,9 @@ public class ModelTrainMngCoreService {
|
||||
*/
|
||||
public void deleteModel(UUID uuid) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
modelMngRepository
|
||||
.findByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
entity.setDelYn(true);
|
||||
entity.setUpdatedDttm(ZonedDateTime.now());
|
||||
entity.setUpdatedUid(userUtil.getId());
|
||||
@@ -78,17 +79,19 @@ public class ModelTrainMngCoreService {
|
||||
* @param addReq
|
||||
* @return
|
||||
*/
|
||||
public Long saveModel(ModelTrainMngDto.AddReq addReq) {
|
||||
public ModelTrainMngDto.Basic saveModel(ModelTrainMngDto.AddReq addReq) {
|
||||
ModelMasterEntity entity = new ModelMasterEntity();
|
||||
ModelHyperParamEntity hyperParamEntity = new ModelHyperParamEntity();
|
||||
|
||||
// 최적화 파라미터는 HPs_0001 사용
|
||||
// 최적화 파라미터는 모델 type의 디폴트사용
|
||||
if (HyperParamSelectType.OPTIMIZED.getId().equals(addReq.getHyperParamType())) {
|
||||
hyperParamEntity = hyperParamRepository.findByHyperVer("HPs_0001").orElse(null);
|
||||
ModelType modelType = ModelType.getValueData(addReq.getModelNo());
|
||||
hyperParamEntity = hyperParamRepository.getHyperparamByType(modelType).orElse(null);
|
||||
// hyperParamEntity = hyperParamRepository.findByHyperVer("HPs_0001").orElse(null);
|
||||
|
||||
} else {
|
||||
hyperParamEntity =
|
||||
hyperParamRepository.findHyperParamByUuid(addReq.getHyperUuid()).orElse(null);
|
||||
hyperParamRepository.findHyperParamByUuid(addReq.getHyperUuid()).orElse(null);
|
||||
}
|
||||
|
||||
if (hyperParamEntity == null || hyperParamEntity.getHyperVer() == null) {
|
||||
@@ -96,8 +99,8 @@ public class ModelTrainMngCoreService {
|
||||
}
|
||||
|
||||
String modelVer =
|
||||
String.join(
|
||||
".", addReq.getModelNo(), hyperParamEntity.getHyperVer(), entity.getUuid().toString());
|
||||
String.join(
|
||||
".", addReq.getModelNo(), hyperParamEntity.getHyperVer(), entity.getUuid().toString());
|
||||
entity.setModelVer(modelVer);
|
||||
entity.setHyperParamId(hyperParamEntity.getId());
|
||||
entity.setModelNo(addReq.getModelNo());
|
||||
@@ -112,18 +115,24 @@ public class ModelTrainMngCoreService {
|
||||
entity.setStep1State(TrainStatusType.IN_PROGRESS.getId());
|
||||
} else {
|
||||
entity.setStatusCd(TrainStatusType.READY.getId());
|
||||
entity.setStep1State(TrainStatusType.READY.getId());
|
||||
}
|
||||
|
||||
entity.setCreatedUid(userUtil.getId());
|
||||
ModelMasterEntity resultEntity = modelMngRepository.save(entity);
|
||||
return resultEntity.getId();
|
||||
|
||||
ModelTrainMngDto.Basic result = new ModelTrainMngDto.Basic();
|
||||
result.setId(resultEntity.getId());
|
||||
result.setUuid(resultEntity.getUuid());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* data set 저장
|
||||
*
|
||||
* @param modelId 저장한 모델 학습 id
|
||||
* @param addReq 요청 파라미터
|
||||
* @param addReq 요청 파라미터
|
||||
*/
|
||||
public void saveModelDataset(Long modelId, ModelTrainMngDto.AddReq addReq) {
|
||||
TrainingDataset dataset = addReq.getTrainingDataset();
|
||||
@@ -148,10 +157,30 @@ public class ModelTrainMngCoreService {
|
||||
modelDatasetRepository.save(datasetEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 학습모델 수정
|
||||
*
|
||||
* @param modelId
|
||||
* @param req
|
||||
*/
|
||||
public void updateModelMaster(Long modelId, ModelTrainMngDto.UpdateReq req) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
if (req.getRequestPath() != null && !req.getRequestPath().isEmpty()) {
|
||||
entity.setRequestPath(req.getRequestPath());
|
||||
}
|
||||
|
||||
if (req.getResponsePath() != null && !req.getResponsePath().isEmpty()) {
|
||||
entity.setRequestPath(req.getResponsePath());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 모델 데이터셋 mapping 테이블 저장
|
||||
*
|
||||
* @param modelId 모델학습 id
|
||||
* @param modelId 모델학습 id
|
||||
* @param datasetList 선택한 data set
|
||||
*/
|
||||
public void saveModelDatasetMap(Long modelId, List<Long> datasetList) {
|
||||
@@ -168,7 +197,7 @@ public class ModelTrainMngCoreService {
|
||||
* 모델학습 config 저장
|
||||
*
|
||||
* @param modelId 모델학습 id
|
||||
* @param req 요청 파라미터
|
||||
* @param req 요청 파라미터
|
||||
* @return
|
||||
*/
|
||||
public void saveModelConfig(Long modelId, ModelTrainMngDto.ModelConfig req) {
|
||||
@@ -188,7 +217,7 @@ public class ModelTrainMngCoreService {
|
||||
/**
|
||||
* 데이터셋 매핑 생성
|
||||
*
|
||||
* @param modelUid 모델 UID
|
||||
* @param modelUid 모델 UID
|
||||
* @param datasetIds 데이터셋 ID 목록
|
||||
*/
|
||||
public void createDatasetMappings(Long modelUid, List<Long> datasetIds) {
|
||||
@@ -210,8 +239,8 @@ public class ModelTrainMngCoreService {
|
||||
public ModelMasterEntity findByUuid(UUID uuid) {
|
||||
try {
|
||||
return modelMngRepository
|
||||
.findByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
.findByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new BadRequestException("잘못된 UUID 형식입니다: " + uuid);
|
||||
}
|
||||
@@ -225,9 +254,9 @@ public class ModelTrainMngCoreService {
|
||||
*/
|
||||
public Long findModelIdByUuid(UUID uuid) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
modelMngRepository
|
||||
.findByUuid(uuid)
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
@@ -240,8 +269,8 @@ public class ModelTrainMngCoreService {
|
||||
public ModelConfigDto.Basic findModelConfigByModelId(UUID uuid) {
|
||||
ModelMasterEntity modelEntity = findByUuid(uuid);
|
||||
return modelConfigRepository
|
||||
.findModelConfigByModelId(modelEntity.getId())
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
.findModelConfigByModelId(modelEntity.getId())
|
||||
.orElseThrow(() -> new CustomApiException("NOT_FOUND_DATA", HttpStatus.NOT_FOUND));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,19 +301,21 @@ public class ModelTrainMngCoreService {
|
||||
*/
|
||||
public ModelTrainMngDto.Basic findModelById(Long id) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + id));
|
||||
modelMngRepository
|
||||
.findById(id)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + id));
|
||||
return entity.toDto();
|
||||
}
|
||||
|
||||
/** 마스터를 IN_PROGRESS로 전환하고, 현재 실행 jobId를 연결 - UI/중단/상태조회 모두 currentAttemptId를 기준으로 동작 */
|
||||
/**
|
||||
* 마스터를 IN_PROGRESS로 전환하고, 현재 실행 jobId를 연결 - UI/중단/상태조회 모두 currentAttemptId를 기준으로 동작
|
||||
*/
|
||||
@Transactional
|
||||
public void markInProgress(Long modelId, Long jobId) {
|
||||
ModelMasterEntity master =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
master.setStatusCd(TrainStatusType.IN_PROGRESS.getId());
|
||||
master.setCurrentAttemptId(jobId);
|
||||
@@ -292,46 +323,54 @@ public class ModelTrainMngCoreService {
|
||||
// 필요하면 시작시간도 여기서 찍어줌
|
||||
}
|
||||
|
||||
/** 마지막 에러 메시지 초기화 - 재시작/새 실행 때 이전 에러 흔적 제거 */
|
||||
/**
|
||||
* 마지막 에러 메시지 초기화 - 재시작/새 실행 때 이전 에러 흔적 제거
|
||||
*/
|
||||
@Transactional
|
||||
public void clearLastError(Long modelId) {
|
||||
ModelMasterEntity master =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
master.setLastError(null);
|
||||
}
|
||||
|
||||
/** 중단 처리(옵션) - cancel에서 쓰려고 하면 같이 구현 */
|
||||
/**
|
||||
* 중단 처리(옵션) - cancel에서 쓰려고 하면 같이 구현
|
||||
*/
|
||||
@Transactional
|
||||
public void markStopped(Long modelId) {
|
||||
ModelMasterEntity master =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
master.setStatusCd(TrainStatusType.STOPPED.getId());
|
||||
}
|
||||
|
||||
/** 완료 처리(옵션) - Worker가 성공 시 호출 */
|
||||
/**
|
||||
* 완료 처리(옵션) - Worker가 성공 시 호출
|
||||
*/
|
||||
@Transactional
|
||||
public void markCompleted(Long modelId) {
|
||||
ModelMasterEntity master =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
master.setStatusCd(TrainStatusType.COMPLETED.getId());
|
||||
}
|
||||
|
||||
/** step 1오류 처리(옵션) - Worker가 실패 시 호출 */
|
||||
/**
|
||||
* step 1오류 처리(옵션) - Worker가 실패 시 호출
|
||||
*/
|
||||
@Transactional
|
||||
public void markError(Long modelId, String errorMessage) {
|
||||
ModelMasterEntity master =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
master.setStatusCd(TrainStatusType.ERROR.getId());
|
||||
master.setStep1State(TrainStatusType.ERROR.getId());
|
||||
@@ -340,13 +379,15 @@ public class ModelTrainMngCoreService {
|
||||
master.setUpdatedDttm(ZonedDateTime.now());
|
||||
}
|
||||
|
||||
/** step 2오류 처리(옵션) - Worker가 실패 시 호출 */
|
||||
/**
|
||||
* step 2오류 처리(옵션) - Worker가 실패 시 호출
|
||||
*/
|
||||
@Transactional
|
||||
public void markStep2Error(Long modelId, String errorMessage) {
|
||||
ModelMasterEntity master =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
master.setStatusCd(TrainStatusType.ERROR.getId());
|
||||
master.setStep2State(TrainStatusType.ERROR.getId());
|
||||
@@ -358,9 +399,9 @@ public class ModelTrainMngCoreService {
|
||||
@Transactional
|
||||
public void markSuccess(Long modelId) {
|
||||
ModelMasterEntity master =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
// 모델 상태 완료 처리
|
||||
master.setStatusCd(TrainStatusType.COMPLETED.getId());
|
||||
@@ -388,9 +429,9 @@ public class ModelTrainMngCoreService {
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void markStep1InProgress(Long modelId, Long jobId) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
entity.setStatusCd(TrainStatusType.IN_PROGRESS.getId());
|
||||
entity.setStep1StrtDttm(ZonedDateTime.now());
|
||||
@@ -408,9 +449,9 @@ public class ModelTrainMngCoreService {
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void markStep2InProgress(Long modelId, Long jobId) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
entity.setStatusCd(TrainStatusType.IN_PROGRESS.getId());
|
||||
entity.setStep2StrtDttm(ZonedDateTime.now());
|
||||
@@ -428,9 +469,9 @@ public class ModelTrainMngCoreService {
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void markStep1Success(Long modelId) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
entity.setStatusCd(TrainStatusType.COMPLETED.getId());
|
||||
entity.setStep1State(TrainStatusType.COMPLETED.getId());
|
||||
@@ -447,9 +488,9 @@ public class ModelTrainMngCoreService {
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void markStep2Success(Long modelId) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
entity.setStatusCd(TrainStatusType.COMPLETED.getId());
|
||||
entity.setStep2State(TrainStatusType.COMPLETED.getId());
|
||||
@@ -457,4 +498,37 @@ public class ModelTrainMngCoreService {
|
||||
entity.setUpdatedDttm(ZonedDateTime.now());
|
||||
entity.setUpdatedUid(userUtil.getId());
|
||||
}
|
||||
|
||||
public void updateModelMasterBestEpoch(Long modelId, int epoch) {
|
||||
ModelMasterEntity entity =
|
||||
modelMngRepository
|
||||
.findById(modelId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Model not found: " + modelId));
|
||||
|
||||
entity.setBestEpoch(epoch);
|
||||
}
|
||||
|
||||
/**
|
||||
* 데이터셋 uid 조회
|
||||
*
|
||||
* @param datasetIds
|
||||
* @return
|
||||
*/
|
||||
public List<String> findDatasetUid(List<Long> datasetIds) {
|
||||
return datasetRepository.findDatasetUid(datasetIds);
|
||||
}
|
||||
|
||||
public List<Long> findModelDatasetMapp(Long modelId) {
|
||||
List<Long> datasetUids = new ArrayList<>();
|
||||
List<ModelDatasetMappEntity> entities = modelDatasetMapRepository.findByModelUid(modelId);
|
||||
for (ModelDatasetMappEntity entity : entities) {
|
||||
datasetUids.add(entity.getDatasetUid());
|
||||
}
|
||||
|
||||
return datasetUids;
|
||||
}
|
||||
|
||||
public Long findModelStep1InProgressCnt() {
|
||||
return modelMngRepository.findModelStep1InProgressCnt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.kamco.cd.training.postgres.entity;
|
||||
|
||||
import com.kamco.cd.training.dataset.dto.DatasetObjDto.Basic;
|
||||
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 jakarta.validation.constraints.Size;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.JdbcTypeCode;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "tb_dataset_val_obj")
|
||||
public class DatasetValObjEntity {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "obj_id", nullable = false)
|
||||
private Long objId;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "dataset_uid", nullable = false)
|
||||
private Long datasetUid;
|
||||
|
||||
@Column(name = "target_yyyy")
|
||||
private Integer targetYyyy;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "target_class_cd")
|
||||
private String targetClassCd;
|
||||
|
||||
@Column(name = "compare_yyyy")
|
||||
private Integer compareYyyy;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "compare_class_cd")
|
||||
private String compareClassCd;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "target_path")
|
||||
private String targetPath;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "compare_path")
|
||||
private String comparePath;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "label_path")
|
||||
private String labelPath;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "geojson_path")
|
||||
private String geojsonPath;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "map_sheet_num")
|
||||
private String mapSheetNum;
|
||||
|
||||
@ColumnDefault("now()")
|
||||
@Column(name = "created_dttm")
|
||||
private ZonedDateTime createdDttm;
|
||||
|
||||
@Column(name = "created_uid")
|
||||
private Long createdUid;
|
||||
|
||||
@ColumnDefault("false")
|
||||
@Column(name = "deleted")
|
||||
private Boolean deleted;
|
||||
|
||||
@Column(name = "uuid")
|
||||
private UUID uuid;
|
||||
|
||||
@Size(max = 32)
|
||||
@Column(name = "uid")
|
||||
private String uid;
|
||||
|
||||
@JdbcTypeCode(SqlTypes.JSON)
|
||||
@Column(name = "geo_jsonb", columnDefinition = "jsonb")
|
||||
private String geoJsonb;
|
||||
|
||||
@Column(name = "file_name")
|
||||
private String fileName;
|
||||
|
||||
@Column(name = "geom", columnDefinition = "geometry")
|
||||
private Geometry geom;
|
||||
|
||||
public Basic toDto() {
|
||||
return new Basic(
|
||||
this.objId,
|
||||
this.datasetUid,
|
||||
this.targetYyyy,
|
||||
this.targetClassCd,
|
||||
this.compareYyyy,
|
||||
this.compareClassCd,
|
||||
this.targetPath,
|
||||
this.comparePath,
|
||||
this.labelPath,
|
||||
this.geojsonPath,
|
||||
this.mapSheetNum,
|
||||
this.createdDttm,
|
||||
this.createdUid,
|
||||
this.deleted,
|
||||
this.uuid,
|
||||
this.geoJsonb);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.kamco.cd.training.postgres.entity;
|
||||
|
||||
import com.kamco.cd.training.common.enums.ModelType;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -311,8 +312,17 @@ public class ModelHyperParamEntity {
|
||||
@Column(name = "m3_use_cnt")
|
||||
private Long m3UseCnt = 0L;
|
||||
|
||||
@Column(name = "model_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private ModelType modelType;
|
||||
|
||||
|
||||
@Column(name = "default_param")
|
||||
private Boolean isDefault = false;
|
||||
|
||||
public HyperParamDto.Basic toDto() {
|
||||
return new HyperParamDto.Basic(
|
||||
this.modelType,
|
||||
this.uuid,
|
||||
this.hyperVer,
|
||||
this.createdDttm,
|
||||
@@ -385,6 +395,8 @@ public class ModelHyperParamEntity {
|
||||
// -------------------------
|
||||
this.gpuCnt,
|
||||
this.gpuIds,
|
||||
this.masterPort);
|
||||
this.masterPort
|
||||
, this.isDefault
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,6 +103,15 @@ public class ModelMasterEntity {
|
||||
@Column(name = "last_error")
|
||||
private String lastError;
|
||||
|
||||
@Column(name = "best_epoch")
|
||||
private Integer bestEpoch;
|
||||
|
||||
@Column(name = "request_path")
|
||||
private String requestPath;
|
||||
|
||||
@Column(name = "response_path")
|
||||
private String responsePath;
|
||||
|
||||
public ModelTrainMngDto.Basic toDto() {
|
||||
return new ModelTrainMngDto.Basic(
|
||||
this.id,
|
||||
|
||||
@@ -22,4 +22,6 @@ public interface DatasetObjRepositoryCustom {
|
||||
String getFilePathByUUIDPathType(UUID uuid, String pathType);
|
||||
|
||||
void insertDatasetTestObj(DatasetObjRegDto objRegDto);
|
||||
|
||||
void insertDatasetValObj(DatasetObjRegDto objRegDto);
|
||||
}
|
||||
|
||||
@@ -97,6 +97,49 @@ public class DatasetObjRepositoryImpl implements DatasetObjRepositoryCustom {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertDatasetValObj(DatasetObjRegDto objRegDto) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String json;
|
||||
String geometryJson;
|
||||
try {
|
||||
json = objectMapper.writeValueAsString(objRegDto.getGeojson());
|
||||
geometryJson =
|
||||
objectMapper.writeValueAsString(
|
||||
objRegDto.getGeojson().path("features").get(0).path("geometry"));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
em.createNativeQuery(
|
||||
"""
|
||||
insert into tb_dataset_val_obj
|
||||
(dataset_uid, target_yyyy, target_class_cd,
|
||||
compare_yyyy, compare_class_cd,
|
||||
target_path, compare_path, label_path, geo_jsonb, map_sheet_num, file_name, geom, geojson_path)
|
||||
values
|
||||
(?, ?, ?, ?, ?, ?, ?, ?, cast(? as jsonb), ?, ?, ST_SetSRID(ST_GeomFromGeoJSON(?), 5186), ?)
|
||||
""")
|
||||
.setParameter(1, objRegDto.getDatasetUid())
|
||||
.setParameter(2, objRegDto.getTargetYyyy())
|
||||
.setParameter(3, objRegDto.getTargetClassCd())
|
||||
.setParameter(4, objRegDto.getCompareYyyy())
|
||||
.setParameter(5, objRegDto.getCompareClassCd())
|
||||
.setParameter(6, objRegDto.getTargetPath())
|
||||
.setParameter(7, objRegDto.getComparePath())
|
||||
.setParameter(8, objRegDto.getLabelPath())
|
||||
.setParameter(9, json)
|
||||
.setParameter(10, objRegDto.getMapSheetNum())
|
||||
.setParameter(11, objRegDto.getFileName())
|
||||
.setParameter(12, geometryJson)
|
||||
.setParameter(13, objRegDto.getGeojsonPath())
|
||||
.executeUpdate();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DatasetObjEntity> searchDatasetObjectList(SearchReq searchReq) {
|
||||
Pageable pageable = searchReq.toPageable();
|
||||
|
||||
@@ -22,4 +22,6 @@ public interface DatasetRepositoryCustom {
|
||||
Long getDatasetMaxStage(int compareYyyy, int targetYyyy);
|
||||
|
||||
Long insertDatasetMngData(DatasetMngRegDto mngRegDto);
|
||||
|
||||
List<String> findDatasetUid(List<Long> datasetIds);
|
||||
}
|
||||
|
||||
@@ -242,4 +242,9 @@ public class DatasetRepositoryImpl implements DatasetRepositoryCustom {
|
||||
.where(dataset.uid.eq(mngRegDto.getUid()))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> findDatasetUid(List<Long> datasetIds) {
|
||||
return queryFactory.select(dataset.uid).from(dataset).where(dataset.id.in(datasetIds)).fetch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.kamco.cd.training.postgres.repository.hyperparam;
|
||||
|
||||
import com.kamco.cd.training.common.enums.ModelType;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto.SearchReq;
|
||||
import com.kamco.cd.training.postgres.entity.ModelHyperParamEntity;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
@@ -13,11 +15,22 @@ public interface HyperParamRepositoryCustom {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
Optional<ModelHyperParamEntity> findHyperParamVer();
|
||||
|
||||
/**
|
||||
* 모델 타입별 마지막 버전 조회
|
||||
*
|
||||
* @param modelType 모델 타입
|
||||
* @return
|
||||
*/
|
||||
Optional<ModelHyperParamEntity> findHyperParamVerByModelType(ModelType modelType);
|
||||
|
||||
Optional<ModelHyperParamEntity> findHyperParamByHyperVer(String hyperVer);
|
||||
|
||||
Optional<ModelHyperParamEntity> findHyperParamByUuid(UUID uuid);
|
||||
|
||||
Page<HyperParamDto.List> findByHyperVerList(HyperParamDto.SearchReq req);
|
||||
Page<HyperParamDto.List> findByHyperVerList(ModelType model, SearchReq req);
|
||||
|
||||
Optional<ModelHyperParamEntity> getHyperparamByType(ModelType modelType);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.kamco.cd.training.postgres.repository.hyperparam;
|
||||
|
||||
import static com.kamco.cd.training.postgres.entity.QModelHyperParamEntity.modelHyperParamEntity;
|
||||
|
||||
import com.kamco.cd.training.common.enums.ModelType;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto.HyperType;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto.SearchReq;
|
||||
import com.kamco.cd.training.postgres.entity.ModelHyperParamEntity;
|
||||
import com.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.types.Projections;
|
||||
@@ -41,6 +43,23 @@ public class HyperParamRepositoryImpl implements HyperParamRepositoryCustom {
|
||||
.fetchOne());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ModelHyperParamEntity> findHyperParamVerByModelType(ModelType modelType) {
|
||||
|
||||
return Optional.ofNullable(
|
||||
queryFactory
|
||||
.select(modelHyperParamEntity)
|
||||
.from(modelHyperParamEntity)
|
||||
.where(
|
||||
modelHyperParamEntity
|
||||
.delYn
|
||||
.isFalse()
|
||||
.and(modelHyperParamEntity.modelType.eq(modelType)))
|
||||
.orderBy(modelHyperParamEntity.hyperVer.desc())
|
||||
.limit(1)
|
||||
.fetchOne());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ModelHyperParamEntity> findHyperParamByHyperVer(String hyperVer) {
|
||||
|
||||
@@ -68,10 +87,11 @@ public class HyperParamRepositoryImpl implements HyperParamRepositoryCustom {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<HyperParamDto.List> findByHyperVerList(HyperParamDto.SearchReq req) {
|
||||
public Page<HyperParamDto.List> findByHyperVerList(ModelType model, SearchReq req) {
|
||||
Pageable pageable = req.toPageable();
|
||||
|
||||
BooleanBuilder builder = new BooleanBuilder();
|
||||
builder.and(modelHyperParamEntity.modelType.eq(model));
|
||||
builder.and(modelHyperParamEntity.delYn.isFalse());
|
||||
|
||||
if (req.getHyperVer() != null && !req.getHyperVer().isEmpty()) {
|
||||
@@ -161,4 +181,14 @@ public class HyperParamRepositoryImpl implements HyperParamRepositoryCustom {
|
||||
|
||||
return new PageImpl<>(content, pageable, totalCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ModelHyperParamEntity> getHyperparamByType(ModelType modelType) {
|
||||
return Optional.ofNullable(
|
||||
queryFactory
|
||||
.select(modelHyperParamEntity)
|
||||
.from(modelHyperParamEntity)
|
||||
.where(modelHyperParamEntity.delYn.isFalse().and(modelHyperParamEntity.modelType.eq(modelType)))
|
||||
.fetchOne());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@ import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface ModelDatasetMappRepository
|
||||
extends JpaRepository<ModelDatasetMappEntity, ModelDatasetMappEntity.ModelDatasetMappId> {}
|
||||
extends JpaRepository<ModelDatasetMappEntity, ModelDatasetMappEntity.ModelDatasetMappId>,
|
||||
ModelDatasetMappRepositoryCustom {}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.kamco.cd.training.postgres.repository.model;
|
||||
|
||||
import com.kamco.cd.training.postgres.entity.ModelDatasetMappEntity;
|
||||
import java.util.List;
|
||||
|
||||
public interface ModelDatasetMappRepositoryCustom {
|
||||
List<ModelDatasetMappEntity> findByModelUid(Long modelId);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.kamco.cd.training.postgres.repository.model;
|
||||
|
||||
import static com.kamco.cd.training.postgres.entity.QModelDatasetMappEntity.modelDatasetMappEntity;
|
||||
|
||||
import com.kamco.cd.training.postgres.entity.ModelDatasetMappEntity;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class ModelDatasetMappRepositoryImpl implements ModelDatasetMappRepositoryCustom {
|
||||
|
||||
private final JPAQueryFactory queryFactory;
|
||||
|
||||
@Override
|
||||
public List<ModelDatasetMappEntity> findByModelUid(Long modelId) {
|
||||
queryFactory
|
||||
.select(modelDatasetMappEntity)
|
||||
.from(modelDatasetMappEntity)
|
||||
.where(modelDatasetMappEntity.modelUid.eq(modelId));
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.kamco.cd.training.postgres.repository.model;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.DetailSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.HyperSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.MappingDataset;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelBestEpoch;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelTestMetrics;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelTrainMetrics;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelValidationMetrics;
|
||||
@@ -31,4 +32,6 @@ public interface ModelDetailRepositoryCustom {
|
||||
List<ModelValidationMetrics> getModelValidationMetricResult(UUID uuid);
|
||||
|
||||
List<ModelTestMetrics> getModelTestMetricResult(UUID uuid);
|
||||
|
||||
ModelBestEpoch getModelTrainBestEpoch(UUID uuid);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import static com.kamco.cd.training.postgres.entity.QModelMetricsValidationEntit
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.DetailSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.HyperSummary;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.MappingDataset;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelBestEpoch;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelTestMetrics;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelTrainMetrics;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDetailDto.ModelValidationMetrics;
|
||||
@@ -26,8 +27,10 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
public class ModelDetailRepositoryImpl implements ModelDetailRepositoryCustom {
|
||||
@@ -237,4 +240,33 @@ public class ModelDetailRepositoryImpl implements ModelDetailRepositoryCustom {
|
||||
.where(modelMetricsTestEntity.model.id.eq(modelMasterEntity.getId()))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelBestEpoch getModelTrainBestEpoch(UUID uuid) {
|
||||
ModelMasterEntity modelMasterEntity = findByModelByUUID(uuid);
|
||||
if (modelMasterEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ModelBestEpoch.class,
|
||||
modelMetricsTrainEntity.epoch,
|
||||
modelMetricsTrainEntity.loss,
|
||||
modelMetricsValidationEntity.mFscore,
|
||||
modelMetricsValidationEntity.mPrecision,
|
||||
modelMetricsValidationEntity.mRecall,
|
||||
modelMetricsValidationEntity.mIou,
|
||||
modelMetricsValidationEntity.mAcc))
|
||||
.from(modelMetricsTrainEntity)
|
||||
.leftJoin(modelMetricsValidationEntity)
|
||||
.on(
|
||||
modelMetricsTrainEntity.model.eq(modelMetricsValidationEntity.model),
|
||||
modelMetricsTrainEntity.epoch.eq(modelMetricsValidationEntity.epoch))
|
||||
.where(
|
||||
modelMetricsTrainEntity.model.id.eq(modelMasterEntity.getId()),
|
||||
modelMetricsTrainEntity.epoch.eq(modelMasterEntity.getBestEpoch()))
|
||||
.fetchOne();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,6 @@ public interface ModelMngRepositoryCustom {
|
||||
Optional<ModelMasterEntity> findFirstByStatusCdAndDelYn(String statusCd, Boolean delYn);
|
||||
|
||||
TrainRunRequest findTrainRunRequest(Long modelId);
|
||||
|
||||
Long findModelStep1InProgressCnt();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import static com.kamco.cd.training.postgres.entity.QModelConfigEntity.modelConf
|
||||
import static com.kamco.cd.training.postgres.entity.QModelHyperParamEntity.modelHyperParamEntity;
|
||||
import static com.kamco.cd.training.postgres.entity.QModelMasterEntity.modelMasterEntity;
|
||||
|
||||
import com.kamco.cd.training.common.enums.TrainStatusType;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto;
|
||||
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
|
||||
import com.kamco.cd.training.train.dto.TrainRunRequest;
|
||||
@@ -45,6 +46,8 @@ public class ModelMngRepositoryImpl implements ModelMngRepositoryCustom {
|
||||
builder.and(modelMasterEntity.modelNo.eq(req.getModelNo()));
|
||||
}
|
||||
|
||||
builder.and(modelMasterEntity.delYn.isFalse());
|
||||
|
||||
List<ModelMasterEntity> content =
|
||||
queryFactory
|
||||
.selectFrom(modelMasterEntity)
|
||||
@@ -94,7 +97,7 @@ public class ModelMngRepositoryImpl implements ModelMngRepositoryCustom {
|
||||
.select(
|
||||
Projections.constructor(
|
||||
TrainRunRequest.class,
|
||||
modelMasterEntity.uuid, // datasetFolder
|
||||
modelMasterEntity.requestPath, // datasetFolder
|
||||
modelMasterEntity.uuid, // outputFolder
|
||||
modelHyperParamEntity.inputSize,
|
||||
modelHyperParamEntity.cropSize,
|
||||
@@ -145,4 +148,13 @@ public class ModelMngRepositoryImpl implements ModelMngRepositoryCustom {
|
||||
.where(modelMasterEntity.id.eq(modelId))
|
||||
.fetchOne();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long findModelStep1InProgressCnt() {
|
||||
return queryFactory
|
||||
.select(modelMasterEntity.id.count())
|
||||
.from(modelMasterEntity)
|
||||
.where(modelMasterEntity.step1State.eq(TrainStatusType.IN_PROGRESS.getId()))
|
||||
.fetchOne();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.kamco.cd.training.postgres.repository.train;
|
||||
|
||||
import com.kamco.cd.training.train.dto.ModelTrainMetricsDto.ResponsePathDto;
|
||||
import java.util.List;
|
||||
|
||||
public interface ModelTestMetricsJobRepositoryCustom {
|
||||
|
||||
void updateModelMetricsTrainSaveYn(Long modelId, String stepNo);
|
||||
|
||||
List<Long> getTestMetricSaveNotYetModelIds();
|
||||
List<ResponsePathDto> getTestMetricSaveNotYetModelIds();
|
||||
|
||||
void insertModelMetricsTest(List<Object[]> batchArgs);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import static com.kamco.cd.training.postgres.entity.QModelMasterEntity.modelMast
|
||||
|
||||
import com.kamco.cd.training.common.enums.TrainStatusType;
|
||||
import com.kamco.cd.training.postgres.entity.ModelMetricsTestEntity;
|
||||
import com.kamco.cd.training.train.dto.ModelTrainMetricsDto.ResponsePathDto;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
@@ -36,9 +38,11 @@ public class ModelTestMetricsJobRepositoryImpl extends QuerydslRepositorySupport
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getTestMetricSaveNotYetModelIds() {
|
||||
public List<ResponsePathDto> getTestMetricSaveNotYetModelIds() {
|
||||
return queryFactory
|
||||
.select(modelMasterEntity.id)
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ResponsePathDto.class, modelMasterEntity.id, modelMasterEntity.responsePath))
|
||||
.from(modelMasterEntity)
|
||||
.where(
|
||||
modelMasterEntity.step2EndDttm.isNotNull(),
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.kamco.cd.training.postgres.repository.train;
|
||||
|
||||
import com.kamco.cd.training.train.dto.ModelTrainMetricsDto.ResponsePathDto;
|
||||
import java.util.List;
|
||||
|
||||
public interface ModelTrainMetricsJobRepositoryCustom {
|
||||
|
||||
List<Long> getTrainMetricSaveNotYetModelIds();
|
||||
List<ResponsePathDto> getTrainMetricSaveNotYetModelIds();
|
||||
|
||||
void insertModelMetricsTrain(List<Object[]> batchArgs);
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ import static com.kamco.cd.training.postgres.entity.QModelMasterEntity.modelMast
|
||||
|
||||
import com.kamco.cd.training.common.enums.TrainStatusType;
|
||||
import com.kamco.cd.training.postgres.entity.ModelMetricsTrainEntity;
|
||||
import com.kamco.cd.training.train.dto.ModelTrainMetricsDto.ResponsePathDto;
|
||||
import com.querydsl.core.types.Projections;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.support.QuerydslRepositorySupport;
|
||||
@@ -23,9 +25,11 @@ public class ModelTrainMetricsJobRepositoryImpl extends QuerydslRepositorySuppor
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getTrainMetricSaveNotYetModelIds() {
|
||||
public List<ResponsePathDto> getTrainMetricSaveNotYetModelIds() {
|
||||
return queryFactory
|
||||
.select(modelMasterEntity.id)
|
||||
.select(
|
||||
Projections.constructor(
|
||||
ResponsePathDto.class, modelMasterEntity.id, modelMasterEntity.responsePath))
|
||||
.from(modelMasterEntity)
|
||||
.where(
|
||||
modelMasterEntity.step1EndDttm.isNotNull(),
|
||||
@@ -41,7 +45,7 @@ public class ModelTrainMetricsJobRepositoryImpl extends QuerydslRepositorySuppor
|
||||
public void insertModelMetricsTrain(List<Object[]> batchArgs) {
|
||||
String sql =
|
||||
"""
|
||||
insert into tb_model_matrics_train
|
||||
insert into tb_model_metrics_train
|
||||
(model_id, epoch, iteration, loss, lr, duration_time)
|
||||
values (?, ?, ?, ?, ?, ?)
|
||||
""";
|
||||
@@ -66,7 +70,7 @@ public class ModelTrainMetricsJobRepositoryImpl extends QuerydslRepositorySuppor
|
||||
public void insertModelMetricsValidation(List<Object[]> batchArgs) {
|
||||
String sql =
|
||||
"""
|
||||
insert into tb_model_matrics_validation
|
||||
insert into tb_model_metrics_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
|
||||
)
|
||||
|
||||
@@ -164,4 +164,26 @@ public class TrainApiController {
|
||||
testJobService.cancel(modelId);
|
||||
return ApiResponseDto.ok("ok");
|
||||
}
|
||||
|
||||
@Operation(summary = "데이터셋 tmp 파일생성", description = "데이터셋 tmp 파일생성 API")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "데이터셋 tmp 파일생성 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema = @Schema(implementation = String.class))),
|
||||
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PostMapping("/create-tmp/{uuid}")
|
||||
public ApiResponseDto<UUID> createTmpFile(
|
||||
@Parameter(description = "uuid", example = "80a0e544-36ed-4999-b705-97427f23337d")
|
||||
@PathVariable
|
||||
UUID uuid) {
|
||||
|
||||
return ApiResponseDto.ok(trainJobService.createTmpFile(uuid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.kamco.cd.training.train.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
public class ModelTrainMetricsDto {
|
||||
|
||||
@Schema(name = "ResponsePathDto", description = "AI 결과 저장된 path 경로 정보")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class ResponsePathDto {
|
||||
|
||||
private Long modelId;
|
||||
private String responsePath;
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ public class TrainRunRequest {
|
||||
// ========================
|
||||
// 기본
|
||||
// ========================
|
||||
private UUID datasetFolder;
|
||||
private String datasetFolder;
|
||||
private UUID outputFolder;
|
||||
private String inputSize;
|
||||
private String cropSize;
|
||||
@@ -84,10 +84,6 @@ public class TrainRunRequest {
|
||||
|
||||
private UUID uuid;
|
||||
|
||||
public String getDatasetFolder() {
|
||||
return String.valueOf(this.datasetFolder);
|
||||
}
|
||||
|
||||
public String getOutputFolder() {
|
||||
return String.valueOf(this.outputFolder);
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class DockerTrainService {
|
||||
c.add("/workspace/change-detection-code/train_wrapper.py");
|
||||
|
||||
// ===== 기본 파라미터 =====
|
||||
addArg(c, "--dataset-folder", "4BDBBDF99D04477A927CC9EBA760B845" /*req.getDatasetFolder()*/);
|
||||
addArg(c, "--dataset-folder", req.getDatasetFolder());
|
||||
addArg(c, "--output-folder", req.getOutputFolder());
|
||||
addArg(c, "--input-size", req.getInputSize());
|
||||
addArg(c, "--crop-size", req.getCropSize());
|
||||
@@ -281,8 +281,8 @@ public class DockerTrainService {
|
||||
if (value == null) return;
|
||||
String s = String.valueOf(value).trim();
|
||||
if (s.isEmpty()) return;
|
||||
c.add(key);
|
||||
c.add(s);
|
||||
|
||||
c.add(key + "=" + s);
|
||||
}
|
||||
|
||||
/** 컨테이너 강제 종료 및 제거 */
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.training.train.service;
|
||||
|
||||
import com.kamco.cd.training.postgres.core.ModelTestMetricsJobCoreService;
|
||||
import com.kamco.cd.training.train.dto.ModelTrainMetricsDto.ResponsePathDto;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -35,66 +36,67 @@ public class ModelTestMetricsJobService {
|
||||
return "local".equalsIgnoreCase(profile);
|
||||
}
|
||||
|
||||
// @Scheduled(cron = "0 0/10 * * * *")
|
||||
// @Scheduled(cron = "0 * * * * *")
|
||||
public void findTestValidMetricCsvFiles() {
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
}
|
||||
// if (isLocalProfile()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
List<Long> modelIds =
|
||||
modelTestMetricsJobCoreService
|
||||
.getTestMetricSaveNotYetModelIds(); // TODO: uid, uuid ? 가져오기로 해야함
|
||||
List<ResponsePathDto> modelIds =
|
||||
modelTestMetricsJobCoreService.getTestMetricSaveNotYetModelIds();
|
||||
|
||||
if (modelIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String localPath = "C:\\data\\upload\\test.csv";
|
||||
try (BufferedReader reader =
|
||||
Files.newBufferedReader(Paths.get(localPath), StandardCharsets.UTF_8); ) {
|
||||
for (ResponsePathDto modelInfo : modelIds) {
|
||||
|
||||
log.info("### localPath={}", localPath);
|
||||
CSVParser parser = CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(reader);
|
||||
String testPath = modelInfo.getResponsePath() + "/metrics/test.csv";
|
||||
try (BufferedReader reader =
|
||||
Files.newBufferedReader(Paths.get(testPath), StandardCharsets.UTF_8); ) {
|
||||
|
||||
List<Object[]> batchArgs = new ArrayList<>();
|
||||
CSVParser parser = CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(reader);
|
||||
|
||||
for (CSVRecord record : parser) {
|
||||
List<Object[]> batchArgs = new ArrayList<>();
|
||||
|
||||
String model = record.get("model");
|
||||
long TP = Long.parseLong(record.get("TP"));
|
||||
long FP = Long.parseLong(record.get("FP"));
|
||||
long FN = Long.parseLong(record.get("FN"));
|
||||
float precision = Float.parseFloat(record.get("precision"));
|
||||
float recall = Float.parseFloat(record.get("recall"));
|
||||
float f1_score = Float.parseFloat(record.get("f1_score"));
|
||||
float accuracy = Float.parseFloat(record.get("accuracy"));
|
||||
float iou = Float.parseFloat(record.get("iou"));
|
||||
long detection_count = Long.parseLong(record.get("detection_count"));
|
||||
long gt_count = Long.parseLong(record.get("gt_count"));
|
||||
for (CSVRecord record : parser) {
|
||||
|
||||
batchArgs.add(
|
||||
new Object[] {
|
||||
modelIds.getFirst(),
|
||||
model,
|
||||
TP,
|
||||
FP,
|
||||
FN,
|
||||
precision,
|
||||
recall,
|
||||
f1_score,
|
||||
accuracy,
|
||||
iou,
|
||||
detection_count,
|
||||
gt_count
|
||||
});
|
||||
String model = record.get("model");
|
||||
long TP = Long.parseLong(record.get("TP"));
|
||||
long FP = Long.parseLong(record.get("FP"));
|
||||
long FN = Long.parseLong(record.get("FN"));
|
||||
float precision = Float.parseFloat(record.get("precision"));
|
||||
float recall = Float.parseFloat(record.get("recall"));
|
||||
float f1_score = Float.parseFloat(record.get("f1_score"));
|
||||
float accuracy = Float.parseFloat(record.get("accuracy"));
|
||||
float iou = Float.parseFloat(record.get("iou"));
|
||||
long detection_count = Long.parseLong(record.get("detection_count"));
|
||||
long gt_count = Long.parseLong(record.get("gt_count"));
|
||||
|
||||
batchArgs.add(
|
||||
new Object[] {
|
||||
modelInfo.getModelId(),
|
||||
model,
|
||||
TP,
|
||||
FP,
|
||||
FN,
|
||||
precision,
|
||||
recall,
|
||||
f1_score,
|
||||
accuracy,
|
||||
iou,
|
||||
detection_count,
|
||||
gt_count
|
||||
});
|
||||
}
|
||||
|
||||
modelTestMetricsJobCoreService.insertModelMetricsTest(batchArgs);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
modelTestMetricsJobCoreService.insertModelMetricsTest(batchArgs);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
modelTestMetricsJobCoreService.updateModelMetricsTrainSaveYn(modelInfo.getModelId(), "step2");
|
||||
}
|
||||
|
||||
modelTestMetricsJobCoreService.updateModelMetricsTrainSaveYn(modelIds.getFirst(), "step2");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.kamco.cd.training.train.service;
|
||||
|
||||
import com.kamco.cd.training.postgres.core.ModelTrainMetricsJobCoreService;
|
||||
import com.kamco.cd.training.train.dto.ModelTrainMetricsDto.ResponsePathDto;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -26,6 +27,10 @@ public class ModelTrainMetricsJobService {
|
||||
@Value("${spring.profiles.active}")
|
||||
private String profile;
|
||||
|
||||
// 학습 결과가 저장될 호스트 디렉토리
|
||||
@Value("${train.docker.responseDir}")
|
||||
private String responseDir;
|
||||
|
||||
/**
|
||||
* 실행중인 profile
|
||||
*
|
||||
@@ -35,96 +40,97 @@ public class ModelTrainMetricsJobService {
|
||||
return "local".equalsIgnoreCase(profile);
|
||||
}
|
||||
|
||||
// @Scheduled(cron = "0 0/10 * * * *")
|
||||
// @Scheduled(cron = "0 * * * * *")
|
||||
public void findTrainValidMetricCsvFiles() {
|
||||
if (isLocalProfile()) {
|
||||
return;
|
||||
}
|
||||
// if (isLocalProfile()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
List<Long> modelIds =
|
||||
modelTrainMetricsJobCoreService
|
||||
.getTrainMetricSaveNotYetModelIds(); // TODO: uid, uuid ? 가져오기로 해야함
|
||||
List<ResponsePathDto> modelIds =
|
||||
modelTrainMetricsJobCoreService.getTrainMetricSaveNotYetModelIds();
|
||||
|
||||
if (modelIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String localPath = "C:\\data\\upload\\train.csv";
|
||||
try (BufferedReader reader =
|
||||
Files.newBufferedReader(Paths.get(localPath), StandardCharsets.UTF_8); ) {
|
||||
for (ResponsePathDto modelInfo : modelIds) {
|
||||
|
||||
log.info("### localPath={}", localPath);
|
||||
CSVParser parser = CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(reader);
|
||||
String trainPath = responseDir + "{uuid}/metrics/train.csv"; // TODO
|
||||
try (BufferedReader reader =
|
||||
Files.newBufferedReader(Paths.get(trainPath), StandardCharsets.UTF_8); ) {
|
||||
|
||||
List<Object[]> batchArgs = new ArrayList<>();
|
||||
CSVParser parser = CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(reader);
|
||||
|
||||
for (CSVRecord record : parser) {
|
||||
List<Object[]> batchArgs = new ArrayList<>();
|
||||
|
||||
int epoch = Integer.parseInt(record.get("Epoch"));
|
||||
long iteration = Long.parseLong(record.get("Iteration"));
|
||||
double Loss = Double.parseDouble(record.get("Loss"));
|
||||
double LR = Double.parseDouble(record.get("LR"));
|
||||
float time = Float.parseFloat(record.get("Time"));
|
||||
for (CSVRecord record : parser) {
|
||||
|
||||
batchArgs.add(new Object[] {modelIds.getFirst(), epoch, iteration, Loss, LR, time});
|
||||
int epoch = Integer.parseInt(record.get("Epoch")) + 1; // TODO : 나중에 AI 개발 완료되면 -1 하기
|
||||
long iteration = Long.parseLong(record.get("Iteration"));
|
||||
double Loss = Double.parseDouble(record.get("Loss"));
|
||||
double LR = Double.parseDouble(record.get("LR"));
|
||||
float time = Float.parseFloat(record.get("Time"));
|
||||
|
||||
batchArgs.add(new Object[] {modelInfo.getModelId(), epoch, iteration, Loss, LR, time});
|
||||
}
|
||||
|
||||
modelTrainMetricsJobCoreService.insertModelMetricsTrain(batchArgs);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
modelTrainMetricsJobCoreService.insertModelMetricsTrain(batchArgs);
|
||||
String validationPath = modelInfo.getResponsePath() + "/metrics/val.csv";
|
||||
try (BufferedReader reader =
|
||||
Files.newBufferedReader(Paths.get(validationPath), StandardCharsets.UTF_8); ) {
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
CSVParser parser = CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(reader);
|
||||
|
||||
String validationPath = "C:\\data\\upload\\val.csv";
|
||||
try (BufferedReader reader =
|
||||
Files.newBufferedReader(Paths.get(validationPath), StandardCharsets.UTF_8); ) {
|
||||
List<Object[]> batchArgs = new ArrayList<>();
|
||||
|
||||
log.info("### validationPath={}", validationPath);
|
||||
CSVParser parser = CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(reader);
|
||||
for (CSVRecord record : parser) {
|
||||
|
||||
List<Object[]> batchArgs = new ArrayList<>();
|
||||
int epoch = Integer.parseInt(record.get("Epoch"));
|
||||
float aAcc = Float.parseFloat(record.get("aAcc"));
|
||||
float mFscore = Float.parseFloat(record.get("mFscore"));
|
||||
float mPrecision = Float.parseFloat(record.get("mPrecision"));
|
||||
float mRecall = Float.parseFloat(record.get("mRecall"));
|
||||
float mIoU = Float.parseFloat(record.get("mIoU"));
|
||||
float mAcc = Float.parseFloat(record.get("mAcc"));
|
||||
float changed_fscore = Float.parseFloat(record.get("changed_fscore"));
|
||||
float changed_precision = Float.parseFloat(record.get("changed_precision"));
|
||||
float changed_recall = Float.parseFloat(record.get("changed_recall"));
|
||||
float unchanged_fscore = Float.parseFloat(record.get("unchanged_fscore"));
|
||||
float unchanged_precision = Float.parseFloat(record.get("unchanged_precision"));
|
||||
float unchanged_recall = Float.parseFloat(record.get("unchanged_recall"));
|
||||
|
||||
for (CSVRecord record : parser) {
|
||||
batchArgs.add(
|
||||
new Object[] {
|
||||
modelInfo.getModelId(),
|
||||
epoch,
|
||||
aAcc,
|
||||
mFscore,
|
||||
mPrecision,
|
||||
mRecall,
|
||||
mIoU,
|
||||
mAcc,
|
||||
changed_fscore,
|
||||
changed_precision,
|
||||
changed_recall,
|
||||
unchanged_fscore,
|
||||
unchanged_precision,
|
||||
unchanged_recall
|
||||
});
|
||||
}
|
||||
|
||||
int epoch = Integer.parseInt(record.get("Epoch"));
|
||||
float aAcc = Float.parseFloat(record.get("aAcc"));
|
||||
float mFscore = Float.parseFloat(record.get("mFscore"));
|
||||
float mPrecision = Float.parseFloat(record.get("mPrecision"));
|
||||
float mRecall = Float.parseFloat(record.get("mRecall"));
|
||||
float mIoU = Float.parseFloat(record.get("mIoU"));
|
||||
float mAcc = Float.parseFloat(record.get("mAcc"));
|
||||
float changed_fscore = Float.parseFloat(record.get("changed_fscore"));
|
||||
float changed_precision = Float.parseFloat(record.get("changed_precision"));
|
||||
float changed_recall = Float.parseFloat(record.get("changed_recall"));
|
||||
float unchanged_fscore = Float.parseFloat(record.get("unchanged_fscore"));
|
||||
float unchanged_precision = Float.parseFloat(record.get("unchanged_precision"));
|
||||
float unchanged_recall = Float.parseFloat(record.get("unchanged_recall"));
|
||||
modelTrainMetricsJobCoreService.insertModelMetricsValidation(batchArgs);
|
||||
|
||||
batchArgs.add(
|
||||
new Object[] {
|
||||
modelIds.getFirst(),
|
||||
epoch,
|
||||
aAcc,
|
||||
mFscore,
|
||||
mPrecision,
|
||||
mRecall,
|
||||
mIoU,
|
||||
mAcc,
|
||||
changed_fscore,
|
||||
changed_precision,
|
||||
changed_recall,
|
||||
unchanged_fscore,
|
||||
unchanged_precision,
|
||||
unchanged_recall
|
||||
});
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
modelTrainMetricsJobCoreService.insertModelMetricsValidation(batchArgs);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
modelTrainMetricsJobCoreService.updateModelMetricsTrainSaveYn(
|
||||
modelInfo.getModelId(), "step1");
|
||||
}
|
||||
|
||||
modelTrainMetricsJobCoreService.updateModelMetricsTrainSaveYn(modelIds.getFirst(), "step1");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ public class TestJobService {
|
||||
// 마스터 확인
|
||||
modelTrainMngCoreService.findModelById(modelId);
|
||||
|
||||
// best epoch 업데이트
|
||||
modelTrainMngCoreService.updateModelMasterBestEpoch(modelId, epoch);
|
||||
|
||||
Map<String, Object> params = new java.util.LinkedHashMap<>();
|
||||
params.put("jobType", "EVAL");
|
||||
params.put("uuid", String.valueOf(uuid));
|
||||
|
||||
@@ -3,14 +3,17 @@ package com.kamco.cd.training.train.service;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.kamco.cd.training.common.enums.TrainStatusType;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto;
|
||||
import com.kamco.cd.training.model.service.TmpDatasetService;
|
||||
import com.kamco.cd.training.postgres.core.ModelTrainJobCoreService;
|
||||
import com.kamco.cd.training.postgres.core.ModelTrainMngCoreService;
|
||||
import com.kamco.cd.training.train.dto.ModelTrainJobQueuedEvent;
|
||||
import com.kamco.cd.training.train.dto.TrainRunRequest;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -29,6 +32,7 @@ public class TrainJobService {
|
||||
private final DockerTrainService dockerTrainService;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
private final TmpDatasetService tmpDatasetService;
|
||||
|
||||
// 학습 결과가 저장될 호스트 디렉토리
|
||||
@Value("${train.docker.responseDir}")
|
||||
@@ -210,4 +214,26 @@ public class TrainJobService {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public UUID createTmpFile(UUID modelUuid) {
|
||||
UUID tmpUuid = UUID.randomUUID();
|
||||
String raw = tmpUuid.toString().toUpperCase().replace("-", "");
|
||||
|
||||
Long modelId = modelTrainMngCoreService.findModelIdByUuid(modelUuid);
|
||||
List<Long> datasetIds = modelTrainMngCoreService.findModelDatasetMapp(modelId);
|
||||
|
||||
List<String> uids = modelTrainMngCoreService.findDatasetUid(datasetIds);
|
||||
|
||||
try {
|
||||
// 데이터셋 심볼링크 생성
|
||||
Path path = tmpDatasetService.buildTmpDatasetSymlink(raw, uids);
|
||||
ModelTrainMngDto.UpdateReq updateReq = new ModelTrainMngDto.UpdateReq();
|
||||
updateReq.setRequestPath(path.toString());
|
||||
modelTrainMngCoreService.updateModelMaster(modelId, updateReq);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return modelUuid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,8 +234,8 @@ public class UploadService {
|
||||
try {
|
||||
FIleChecker.deleteFolder(tmpDir);
|
||||
// 108 에서 86 서버로 이동
|
||||
log.info("################# server move 108 -> 86");
|
||||
FIleChecker.uploadTo86(outputPath);
|
||||
// log.info("################# server move 108 -> 86");
|
||||
// FIleChecker.uploadTo86(outputPath);
|
||||
} catch (Exception e) {
|
||||
log.warn("tmpDir delete failed (merge already succeeded): tmpDir={}", tmpDir, e);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ spring:
|
||||
on-profile: prod
|
||||
|
||||
jpa:
|
||||
show-sql: false
|
||||
show-sql: true
|
||||
hibernate:
|
||||
ddl-auto: validate
|
||||
properties:
|
||||
@@ -12,41 +12,43 @@ spring:
|
||||
default_batch_fetch_size: 100 # ✅ 성능 - N+1 쿼리 방지
|
||||
order_updates: true # ✅ 성능 - 업데이트 순서 정렬로 데드락 방지
|
||||
use_sql_comments: true # ⚠️ 선택 - SQL에 주석 추가 (디버깅용)
|
||||
format_sql: true # ⚠️ 선택 - SQL 포맷팅 (가독성)
|
||||
|
||||
datasource:
|
||||
url: jdbc:postgresql://10.100.0.10:25432/temp
|
||||
username: temp
|
||||
password: temp123!
|
||||
url: jdbc:postgresql://127.0.01:15432/kamco_training_db
|
||||
# url: jdbc:postgresql://localhost:15432/kamco_training_db
|
||||
username: kamco_training_user
|
||||
password: kamco_training_user_2025_!@#
|
||||
hikari:
|
||||
minimum-idle: 10
|
||||
maximum-pool-size: 20
|
||||
connection-timeout: 60000 # 60초 연결 타임아웃
|
||||
idle-timeout: 300000 # 5분 유휴 타임아웃
|
||||
max-lifetime: 1800000 # 30분 최대 수명
|
||||
leak-detection-threshold: 60000 # 연결 누수 감지
|
||||
|
||||
transaction:
|
||||
default-timeout: 300 # 5분 트랜잭션 타임아웃
|
||||
|
||||
jwt:
|
||||
secret: "kamco_token_prod_dfc6446d-68fc-4eba-a2ff-c80a14a0bf3a"
|
||||
secret: "kamco_token_dev_dfc6446d-68fc-4eba-a2ff-c80a14a0bf3a"
|
||||
access-token-validity-in-ms: 86400000 # 1일
|
||||
refresh-token-validity-in-ms: 604800000 # 7일
|
||||
|
||||
token:
|
||||
refresh-cookie-name: kamco # 개발용 쿠키 이름
|
||||
refresh-cookie-secure: true # 로컬 http 테스트면 false
|
||||
refresh-cookie-secure: false # 로컬 http 테스트면 false
|
||||
|
||||
springdoc:
|
||||
swagger-ui:
|
||||
persist-authorization: true # 스웨거 새로고침해도 토큰 유지, 로컬스토리지에 저장
|
||||
|
||||
member:
|
||||
init_password: kamco1234!
|
||||
|
||||
swagger:
|
||||
local-port: 9080
|
||||
|
||||
file:
|
||||
sync-root-dir: /app/original-images/
|
||||
sync-tmp-dir: ${file.sync-root-dir}tmp/
|
||||
sync-file-extention: tfw,tif
|
||||
|
||||
dataset-dir: /home/kcomu/data/request/
|
||||
dataset-tmp-dir: ${file.dataset-dir}tmp/
|
||||
|
||||
train:
|
||||
docker:
|
||||
image: "kamco-cd-train:love_latest"
|
||||
image: "kamco-cd-train:latest"
|
||||
requestDir: "/home/kcomu/data/request"
|
||||
responseDir: "/home/kcomu/data/response"
|
||||
containerPrefix: "kamco-cd-train"
|
||||
|
||||
@@ -9667,7 +9667,7 @@ INSERT INTO public.tb_audit_log VALUES (1813, 3, 'CREATE', 'SUCCESS', 'SYSTEM',
|
||||
INSERT INTO public.tb_audit_log VALUES (1814, 3, 'READ', 'SUCCESS', 'SYSTEM', '127.0.0.1', NULL, '2025-12-26 00:44:49.832926+00', NULL, '', '/api/models/train');
|
||||
INSERT INTO public.tb_audit_log VALUES (1815, NULL, 'CREATE', 'FAILED', 'SYSTEM', '127.0.0.1', NULL, '2025-12-26 00:53:40.899603+00', 467, '{
|
||||
"username": "1234567",
|
||||
"password":"****"
|
||||
"password":"****"
|
||||
}', '/api/auth/signin');
|
||||
INSERT INTO public.tb_audit_log VALUES (1816, NULL, 'CREATE', 'SUCCESS', 'SYSTEM', '127.0.0.1', NULL, '2025-12-26 00:55:27.731595+00', NULL, '{
|
||||
"username": "1234567",
|
||||
@@ -30396,6 +30396,8 @@ ALTER TABLE ONLY public.tb_menu
|
||||
ADD CONSTRAINT fksw914diut87r7lfykekc7xm2a FOREIGN KEY (parent_menu_uid) REFERENCES public.tb_menu(menu_uid);
|
||||
|
||||
|
||||
|
||||
|
||||
-- Completed on 2025-12-26 16:11:11 KST
|
||||
|
||||
--
|
||||
@@ -30404,3 +30406,5 @@ ALTER TABLE ONLY public.tb_menu
|
||||
|
||||
\unrestrict IYrUYfSgA4Fo2gubHcb84jDXfbBZEIiOZnyLtZgnMi641GaRQa5QDogarpTr7IG
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user