Feat: 메모리 상태 API

This commit is contained in:
김용수 2024-10-04 13:05:11 +09:00
parent 9cd41b76eb
commit 62f6616806
5 changed files with 45 additions and 7 deletions

View File

@ -60,7 +60,6 @@ public class ImageController {
@RequestBody final List<ImageMetaRequest> imageMetaList,
@PathVariable("project_id") final Integer projectId,
@PathVariable("folder_id") final Integer folderId) {
log.debug("requestImageList {}", imageMetaList);
return imageService.uploadFolderByPresignedImage(memberId, imageMetaList, projectId, folderId);
}

View File

@ -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;
}
// 이미지 가져오면서 프로젝트 소속 여부를 확인

View File

@ -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();
}
}

View File

@ -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;
}

View File

@ -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);
}
}