모델등록 수정
This commit is contained in:
@@ -12,7 +12,8 @@ public enum FileUploadStatus implements EnumType {
|
||||
INIT("초기화"),
|
||||
UPLOADING("업로드중"),
|
||||
DONE("업로드완료"),
|
||||
MERGED("병합완료");
|
||||
MERGED("병합완료"),
|
||||
MERGE_FAIL("병합 실패");
|
||||
|
||||
private final String desc;
|
||||
|
||||
|
||||
@@ -19,12 +19,14 @@ import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
@RequiredArgsConstructor
|
||||
public class ModelMngService {
|
||||
|
||||
@@ -71,11 +73,18 @@ public class ModelMngService {
|
||||
}
|
||||
|
||||
public ApiResponseDto.ResponseObj insertModel(ModelMngDto.AddReq addReq) {
|
||||
|
||||
UUID uuid = UUID.randomUUID();
|
||||
addReq.setUuid(uuid);
|
||||
addReq.setClsModelVersion(addReq.getModelVer());
|
||||
addReq.setPriority(0d);
|
||||
|
||||
log.info(
|
||||
"insertModel start: uuid={}, fileName={}, filePath={}",
|
||||
uuid,
|
||||
addReq.getFileName(),
|
||||
addReq.getFilePath());
|
||||
|
||||
ModelUploadResDto modelUploadResDto = new ModelUploadResDto();
|
||||
try {
|
||||
FIleChecker.unzip(addReq.getFileName(), addReq.getFilePath());
|
||||
@@ -88,6 +97,14 @@ public class ModelMngService {
|
||||
|| modelUploadResDto.getClsModelFileName() == null
|
||||
|| modelUploadResDto.getClsModelFileName().isEmpty()) {
|
||||
|
||||
log.warn(
|
||||
"model file missing: uuid={}, path={}, cdModel={}, cdConfig={}, clsModel={}",
|
||||
uuid,
|
||||
addReq.getFilePath(),
|
||||
modelUploadResDto.getCdModelFileName(),
|
||||
modelUploadResDto.getCdModelConfigFileName(),
|
||||
modelUploadResDto.getClsModelFileName());
|
||||
|
||||
return new ApiResponseDto.ResponseObj(
|
||||
ApiResponseCode.NOT_FOUND, "pth,json,py파일이 모두 존재하지 않습니다");
|
||||
}
|
||||
@@ -101,12 +118,20 @@ public class ModelMngService {
|
||||
|
||||
} catch (IOException e) {
|
||||
// throw new RuntimeException(e);
|
||||
|
||||
log.error(
|
||||
"unzip or scan failed: uuid={}, fileName={}, filePath={}",
|
||||
uuid,
|
||||
addReq.getFileName(),
|
||||
addReq.getFilePath(),
|
||||
e);
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseCode.NOT_FOUND, "파일이 존재하지 않습니다");
|
||||
}
|
||||
|
||||
Long modelUid = modelMngCoreService.insertModel(addReq);
|
||||
|
||||
log.info(
|
||||
"model inserted: uuid={}, modelUid={}, modelVer={}", uuid, modelUid, addReq.getModelVer());
|
||||
|
||||
ModelMetricAddReq modelMetricAddReq = new ModelMetricAddReq();
|
||||
modelMetricAddReq.setModelUid(modelUid);
|
||||
modelMetricAddReq.setModelVerUid(modelUid);
|
||||
@@ -136,14 +161,28 @@ public class ModelMngService {
|
||||
modelMetricAddReq.setIou(iou);
|
||||
|
||||
} catch (IOException e) {
|
||||
log.error("metric json parse failed: uuid={}, jsonPath={}", uuid, filePath, e);
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseCode.NOT_FOUND, "JSON파일 오류");
|
||||
}
|
||||
|
||||
modelMngCoreService.insertModelResultMetric(modelMetricAddReq);
|
||||
|
||||
log.info(
|
||||
"model metric inserted: modelUid={}, f1={}, precision={}, recall={}, iou={}",
|
||||
modelUid,
|
||||
modelMetricAddReq.getF1Score(),
|
||||
modelMetricAddReq.getPrecision(),
|
||||
modelMetricAddReq.getRecall(),
|
||||
modelMetricAddReq.getIou());
|
||||
|
||||
String zipFilePath = addReq.getFilePath() + "/" + addReq.getFileName();
|
||||
boolean isDeleted = FIleChecker.deleteFile(zipFilePath);
|
||||
|
||||
if (!isDeleted) {
|
||||
log.warn("zip file delete failed: uuid={}, path={}", uuid, zipFilePath);
|
||||
}
|
||||
|
||||
log.info("insertModel success: uuid={}, modelUid={}", uuid, modelUid);
|
||||
return new ApiResponseDto.ResponseObj(ApiResponseDto.ApiResponseCode.OK, "등록되었습니다.");
|
||||
}
|
||||
|
||||
@@ -174,6 +213,14 @@ public class ModelMngService {
|
||||
}
|
||||
*/
|
||||
|
||||
log.info(
|
||||
"end uploadChunkModelFile: res={}, resMsg={}, uuid={}, filePath={}, fileName={}",
|
||||
modelUploadResDto.getRes(),
|
||||
modelUploadResDto.getResMsg(),
|
||||
modelUploadResDto.getUuid(),
|
||||
modelUploadResDto.getFilePath(),
|
||||
modelUploadResDto.getFileName());
|
||||
|
||||
return modelUploadResDto;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ public class UploadService {
|
||||
try {
|
||||
this.mergeChunks(tmpDataSetDir, fianlDir, fileName, chunkTotalIndex);
|
||||
|
||||
upAddReqDto.setStatus("MERGED");
|
||||
upAddReqDto.setStatus(FileUploadStatus.MERGED.name());
|
||||
uploadSessionCoreService.updateUploadSessionStatus(upAddReqDto);
|
||||
|
||||
log.info(
|
||||
@@ -135,7 +135,7 @@ public class UploadService {
|
||||
} catch (IOException e) {
|
||||
|
||||
// 실패 상태도 남기는 걸 강추
|
||||
upAddReqDto.setStatus("MERGE_FAIL");
|
||||
upAddReqDto.setStatus(FileUploadStatus.MERGE_FAIL.name());
|
||||
uploadSessionCoreService.updateUploadSessionStatus(upAddReqDto);
|
||||
|
||||
log.error(
|
||||
|
||||
Reference in New Issue
Block a user