|
|
|
|
@ -14,7 +14,10 @@ import org.springframework.util.LinkedMultiValueMap;
|
|
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.springframework.web.reactive.function.BodyInserters;
|
|
|
|
|
import org.springframework.web.reactive.function.client.WebClient;
|
|
|
|
|
import org.springframework.web.util.UriComponentsBuilder;
|
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
@ -29,6 +32,9 @@ public class PipelineUploadService {
|
|
|
|
|
@Value("${kubeflow.url}")
|
|
|
|
|
private String kubeflowBaseUrl; // 예: http://192.168.10.135:32473/
|
|
|
|
|
|
|
|
|
|
private final WebClient webClient;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pipeline 업로드
|
|
|
|
|
*/
|
|
|
|
|
@ -65,26 +71,21 @@ public class PipelineUploadService {
|
|
|
|
|
* Run 생성
|
|
|
|
|
* runRequest에는 display_name, pipeline_version_reference, runtime_config 등이 포함되어야 함
|
|
|
|
|
*/
|
|
|
|
|
// PipelineUploadService.java
|
|
|
|
|
public Map<String, Object> createRun(CreateRunRequest runRequest) {
|
|
|
|
|
try {
|
|
|
|
|
// URL 조립
|
|
|
|
|
String url = kubeflowBaseUrl + "apis/v2beta1/runs";
|
|
|
|
|
|
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
|
|
|
|
|
|
// DTO를 Map으로 변환해서 전송
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
Map body = objectMapper.convertValue(runRequest, Map.class);
|
|
|
|
|
|
|
|
|
|
HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(body, headers);
|
|
|
|
|
|
|
|
|
|
ResponseEntity<Map> response = restTemplate.postForEntity(url, requestEntity, Map.class);
|
|
|
|
|
if (runRequest.getDisplay_name() == null || runRequest.getDisplay_name().isBlank()) {
|
|
|
|
|
throw new IllegalArgumentException("Run display_name cannot be empty");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return response.getBody();
|
|
|
|
|
try {
|
|
|
|
|
Mono<Map> responseMono = webClient.post()
|
|
|
|
|
.uri(kubeflowBaseUrl + "/apis/v2beta1/runs")
|
|
|
|
|
.contentType(MediaType.APPLICATION_JSON)
|
|
|
|
|
.body(BodyInserters.fromValue(runRequest))
|
|
|
|
|
.retrieve()
|
|
|
|
|
.bodyToMono(Map.class);
|
|
|
|
|
|
|
|
|
|
return responseMono.block(); // 동기 호출
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
if (e instanceof IllegalArgumentException) throw e;
|
|
|
|
|
throw new RuntimeException("Kubeflow Run creation failed", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|