From df452c9c1441580f82e269a2bb1a63a2a820fb94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Thu, 3 Oct 2024 00:39:14 +0900 Subject: [PATCH 1/6] =?UTF-8?q?Refactor:=20SAVE=20=EC=99=B8=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=202=EA=B0=80=EC=A7=80=20=EB=8D=AE=EC=96=B4=EC=93=B0?= =?UTF-8?q?=EA=B8=B0=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/worlabel/domain/project/service/ProjectService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java b/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java index 5d0eeb4..1875c3b 100644 --- a/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java +++ b/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java @@ -207,7 +207,7 @@ public class ProjectService { public void saveAutoLabelList(final List resultList) { for (AutoLabelingResult result : resultList) { Image image = getImage(result.getImageId()); - if (image.getStatus() == LabelStatus.SAVE || image.getStatus() == LabelStatus.IN_PROGRESS) continue; + if (image.getStatus() == LabelStatus.SAVE || image.getStatus() == LabelStatus.REVIEW_REQUEST || image.getStatus() == LabelStatus.REVIEW_REJECT) continue; String dataPath = image.getDataPath(); s3UploadService.uploadJson(result.getData(), dataPath); image.updateStatus(LabelStatus.IN_PROGRESS); From 28df0a65dbe90169073af10946cf4c2b0e2c314f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Thu, 3 Oct 2024 01:13:43 +0900 Subject: [PATCH 2/6] =?UTF-8?q?Feat:=20=EC=9D=91=EB=8B=B5=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=ED=99=95=EC=9D=B8=EC=9D=84=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20=EB=A1=9C=EA=B9=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/worlabel/domain/project/service/ProjectService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java b/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java index 1875c3b..5ec7d85 100644 --- a/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java +++ b/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java @@ -191,10 +191,12 @@ public class ProjectService { AiModel aiModel = getAiModel(request); AutoLabelingRequest autoLabelingRequest = AutoLabelingRequest.of(projectId, aiModel.getModelKey(), labelMap, imageRequestList); - log.debug("요청 {}", autoLabelingRequest); + log.debug("요청 이미지 개수 :{}", imageRequestList.size()); List list = aiService.postRequest(endPoint, autoLabelingRequest, List.class, this::converter); + saveAutoLabelList(list); + log.debug("응답 이미지 개수 :{}", list.size()); alarmService.save(memberId, Alarm.AlarmType.PREDICT); } finally { From 9cd41b76ebd1260c1722c1d58191b00efa319695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Fri, 4 Oct 2024 09:33:18 +0900 Subject: [PATCH 3/6] =?UTF-8?q?Refactor:=20=EB=A7=A4=EB=8B=88=EC=A0=80=20?= =?UTF-8?q?=EA=B6=8C=ED=95=9C=20=EB=B3=80=EA=B2=BD=20=ED=97=88=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/worlabel/domain/project/service/ProjectService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java b/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java index 5ec7d85..8258b58 100644 --- a/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java +++ b/backend/src/main/java/com/worlabel/domain/project/service/ProjectService.java @@ -144,7 +144,7 @@ public class ProjectService { participantRepository.save(participant); } - @CheckPrivilege(PrivilegeType.ADMIN) + @CheckPrivilege(PrivilegeType.MANAGER) public void changeProjectMember(final Integer projectId, final ParticipantRequest participantRequest) { checkNotAdminParticipant(participantRequest.getMemberId(), projectId); From 62f66168068474d8d2697d1f92405f8679ec0db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Fri, 4 Oct 2024 13:05:11 +0900 Subject: [PATCH 4/6] =?UTF-8?q?Feat:=20=EB=A9=94=EB=AA=A8=EB=A6=AC=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../image/controller/ImageController.java | 1 - .../domain/image/service/ImageService.java | 8 +++--- .../model/controller/AiModelController.java | 11 ++++++-- .../model/entity/dto/MemoryResponse.java | 27 +++++++++++++++++++ .../domain/model/service/AiModelService.java | 5 ++++ 5 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 backend/src/main/java/com/worlabel/domain/model/entity/dto/MemoryResponse.java diff --git a/backend/src/main/java/com/worlabel/domain/image/controller/ImageController.java b/backend/src/main/java/com/worlabel/domain/image/controller/ImageController.java index 1886234..aa2295e 100644 --- a/backend/src/main/java/com/worlabel/domain/image/controller/ImageController.java +++ b/backend/src/main/java/com/worlabel/domain/image/controller/ImageController.java @@ -60,7 +60,6 @@ public class ImageController { @RequestBody final List imageMetaList, @PathVariable("project_id") final Integer projectId, @PathVariable("folder_id") final Integer folderId) { - log.debug("requestImageList {}", imageMetaList); return imageService.uploadFolderByPresignedImage(memberId, imageMetaList, projectId, folderId); } diff --git a/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java b/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java index 9276c3f..10a97a4 100644 --- a/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java +++ b/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java @@ -336,17 +336,17 @@ public class ImageService { // Presigned URL 생성 String presignedUrl = s3UploadService.generatePresignedUrl(key, extension); - log.debug("presignedUrl {}", presignedUrl); - // DB에 이미지 메타데이터 저장 - Image image = Image.of(fileName, s3UploadService.addBucketPrefix(key), extension, folder); - imageRepository.save(image); +// // DB에 이미지 메타데이터 저장 +// Image image = Image.of(fileName, s3UploadService.addBucketPrefix(key), extension, folder); +// imageRepository.save(image); // Presigned URL과 함께 응답 데이터 생성 ImagePresignedUrlResponse response = ImagePresignedUrlResponse.of(meta.getId(), presignedUrl); presignedUrls.add(response); } + log.debug("이미지 개수 {}",presignedUrls.size()); return presignedUrls; } // 이미지 가져오면서 프로젝트 소속 여부를 확인 diff --git a/backend/src/main/java/com/worlabel/domain/model/controller/AiModelController.java b/backend/src/main/java/com/worlabel/domain/model/controller/AiModelController.java index 634a2ff..17e79d5 100644 --- a/backend/src/main/java/com/worlabel/domain/model/controller/AiModelController.java +++ b/backend/src/main/java/com/worlabel/domain/model/controller/AiModelController.java @@ -2,10 +2,9 @@ package com.worlabel.domain.model.controller; import com.worlabel.domain.model.entity.dto.AiModelRequest; import com.worlabel.domain.model.entity.dto.AiModelResponse; +import com.worlabel.domain.model.entity.dto.MemoryResponse; import com.worlabel.domain.model.entity.dto.ModelTrainRequest; import com.worlabel.domain.model.service.AiModelService; -import com.worlabel.domain.progress.service.ProgressService; -import com.worlabel.domain.project.entity.dto.ProjectRequest; import com.worlabel.global.annotation.CurrentUser; import com.worlabel.global.config.swagger.SwaggerApiError; import com.worlabel.global.config.swagger.SwaggerApiSuccess; @@ -82,4 +81,12 @@ public class AiModelController { log.debug("다운로드 요청 projectId : {} modelId : {}", projectId, modelId); return aiModelService.modelDownload(projectId, modelId); } + + @Operation(summary = "GPU 서버 메모리 상태", description = "GPU 서버의 메모리 상태를 반환") + @SwaggerApiSuccess(description = "프로젝트 모델이 성공적으로 다운로드됩니다.") + @SwaggerApiError({ErrorCode.EMPTY_REQUEST_PARAMETER, ErrorCode.SERVER_ERROR}) + @GetMapping("/gpu/memory") + public MemoryResponse getMemory() { + return aiModelService.getMemory(); + } } diff --git a/backend/src/main/java/com/worlabel/domain/model/entity/dto/MemoryResponse.java b/backend/src/main/java/com/worlabel/domain/model/entity/dto/MemoryResponse.java new file mode 100644 index 0000000..44f1805 --- /dev/null +++ b/backend/src/main/java/com/worlabel/domain/model/entity/dto/MemoryResponse.java @@ -0,0 +1,27 @@ +package com.worlabel.domain.model.entity.dto; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +@Getter +@ToString +@AllArgsConstructor(access = AccessLevel.PRIVATE) +public class MemoryResponse { + + @JsonProperty("current_device") + @Schema(description = "사용중인 디바이스 ID", example = "1") + private int deviceId; + + @Schema(description = "전체 GPU 메모리(GB)", example = "1") + private double total; + + @Schema(description = "현재 사용중인 GPU 메모리(GB)", example = "1") + private double allocated; + + @Schema(description = "예약된 GPU 메모리(GB)", example = "1") + private double reserved; + + @Schema(description = "사용 가능한 GPU 메모리(GB)", example = "1") + private double free; +} \ No newline at end of file diff --git a/backend/src/main/java/com/worlabel/domain/model/service/AiModelService.java b/backend/src/main/java/com/worlabel/domain/model/service/AiModelService.java index 9270625..9540f54 100644 --- a/backend/src/main/java/com/worlabel/domain/model/service/AiModelService.java +++ b/backend/src/main/java/com/worlabel/domain/model/service/AiModelService.java @@ -191,4 +191,9 @@ public class AiModelService { } } + public MemoryResponse getMemory() { + String memoryResponse = aiRequestService.getRequest("/detection/memory", data -> data); + log.debug("memoryData {}", memoryResponse); + return gson.fromJson(memoryResponse, MemoryResponse.class); + } } From 5128c892d011fa0bec093c40ba02d9ae7b39281d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Fri, 4 Oct 2024 13:39:04 +0900 Subject: [PATCH 5/6] =?UTF-8?q?Refactor:=20AI=20=EC=9A=94=EC=B2=AD=20?= =?UTF-8?q?=EC=84=9C=EB=B2=84=20=EC=8B=9C=EA=B0=84=EC=A0=9C=ED=95=9C=20?= =?UTF-8?q?=ED=95=B4=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/config/RestTemplateConfig.java | 20 +++++++++++++++++++ .../com/worlabel/global/config/WebConfig.java | 8 +------- 2 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 backend/src/main/java/com/worlabel/global/config/RestTemplateConfig.java diff --git a/backend/src/main/java/com/worlabel/global/config/RestTemplateConfig.java b/backend/src/main/java/com/worlabel/global/config/RestTemplateConfig.java new file mode 100644 index 0000000..20a9e6d --- /dev/null +++ b/backend/src/main/java/com/worlabel/global/config/RestTemplateConfig.java @@ -0,0 +1,20 @@ +package com.worlabel.global.config; + +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +import java.time.Duration; + +@Configuration +public class RestTemplateConfig { + + @Bean + public RestTemplate restTemplate(RestTemplateBuilder builder) { + return builder + .setConnectTimeout(Duration.ZERO) + .setReadTimeout(Duration.ZERO) + .build(); + } +} diff --git a/backend/src/main/java/com/worlabel/global/config/WebConfig.java b/backend/src/main/java/com/worlabel/global/config/WebConfig.java index 7116fc6..ced073e 100644 --- a/backend/src/main/java/com/worlabel/global/config/WebConfig.java +++ b/backend/src/main/java/com/worlabel/global/config/WebConfig.java @@ -2,9 +2,8 @@ package com.worlabel.global.config; import com.worlabel.global.resolver.CurrentUserArgumentResolver; import lombok.RequiredArgsConstructor; -import org.springframework.context.annotation.Bean; + import org.springframework.context.annotation.Configuration; -import org.springframework.web.client.RestTemplate; import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -20,9 +19,4 @@ public class WebConfig implements WebMvcConfigurer { public void addArgumentResolvers(List resolvers) { resolvers.add(currentUserArgumentResolver); } - - @Bean - public RestTemplate restTemplate() { - return new RestTemplate(); - } } From 15350af51669adb83246f3fe613478e89287e7d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EC=88=98?= Date: Mon, 7 Oct 2024 11:41:42 +0900 Subject: [PATCH 6/6] =?UTF-8?q?Fix:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/worlabel/domain/image/service/ImageService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java b/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java index 10a97a4..76bafd5 100644 --- a/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java +++ b/backend/src/main/java/com/worlabel/domain/image/service/ImageService.java @@ -337,9 +337,9 @@ public class ImageService { // Presigned URL 생성 String presignedUrl = s3UploadService.generatePresignedUrl(key, extension); -// // DB에 이미지 메타데이터 저장 -// Image image = Image.of(fileName, s3UploadService.addBucketPrefix(key), extension, folder); -// imageRepository.save(image); + // DB에 이미지 메타데이터 저장 + Image image = Image.of(fileName, s3UploadService.addBucketPrefix(key), extension, folder); + imageRepository.save(image); // Presigned URL과 함께 응답 데이터 생성 ImagePresignedUrlResponse response = ImagePresignedUrlResponse.of(meta.getId(), presignedUrl);