|
|
|
|
@ -64,6 +64,56 @@ public class ExperimentsController {
|
|
|
|
|
return ResponseEntity.ok(page);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Operation(summary = "Experiment 등록")
|
|
|
|
|
// @PostMapping
|
|
|
|
|
// public Mono<ResponseEntity<ExperimentsEntity>> createExperiment(@RequestBody ExperimentsEntity experiment) {
|
|
|
|
|
//
|
|
|
|
|
// // 1️⃣ DB 저장
|
|
|
|
|
// ExperimentsEntity saved = experimentsService.save(experiment);
|
|
|
|
|
//
|
|
|
|
|
// // 2️⃣ Kubeflow POST 요청 payload
|
|
|
|
|
// Map<String, Object> payload = new HashMap<>();
|
|
|
|
|
// payload.put("display_name", saved.getDisplayName());
|
|
|
|
|
// payload.put("description", saved.getDescription());
|
|
|
|
|
// payload.put("namespace", "default"); // 필요에 따라 변경
|
|
|
|
|
//
|
|
|
|
|
// // 3️⃣ WebClient POST
|
|
|
|
|
// return webClientBuilder.build()
|
|
|
|
|
// .post()
|
|
|
|
|
// .uri(kubeflowBaseUrl + "/apis/v2beta1/experiments")
|
|
|
|
|
// .contentType(MediaType.APPLICATION_JSON)
|
|
|
|
|
// .bodyValue(payload)
|
|
|
|
|
// .retrieve()
|
|
|
|
|
// .bodyToMono(Map.class) // Kubeflow 응답
|
|
|
|
|
// .map(resp -> {
|
|
|
|
|
// // resp에서 필요한 값 추출 후 entity에 반영
|
|
|
|
|
// if(resp.get("id") != null) {
|
|
|
|
|
// saved.setKubeFlowId(resp.get("id").toString());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (resp.get("storage_state") != null) {
|
|
|
|
|
// saved.setKubeflowStorageState(resp.get("storage_state").toString());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (resp.get("created_at") != null) {
|
|
|
|
|
// String lastRunStr = resp.get("created_at").toString();
|
|
|
|
|
// OffsetDateTime odt = OffsetDateTime.parse(lastRunStr);
|
|
|
|
|
// saved.setKubeflowCreatedAt(odt.withOffsetSameInstant(ZoneId.of("Asia/Seoul").getRules().getOffset(odt.toInstant()))
|
|
|
|
|
// .toLocalDateTime());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (resp.get("last_run_created_at") != null) {
|
|
|
|
|
// String lastRunStr = resp.get("last_run_created_at").toString();
|
|
|
|
|
// OffsetDateTime odt = OffsetDateTime.parse(lastRunStr);
|
|
|
|
|
// saved.setKubeflowLastRunCreatedAt(odt.withOffsetSameInstant(ZoneId.of("Asia/Seoul").getRules().getOffset(odt.toInstant()))
|
|
|
|
|
// .toLocalDateTime());
|
|
|
|
|
// }
|
|
|
|
|
// return saved;
|
|
|
|
|
// })
|
|
|
|
|
// .map(ResponseEntity::ok)
|
|
|
|
|
// .doOnError(e -> log.error("Kubeflow experiment 등록 실패", e));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "Experiment 등록")
|
|
|
|
|
@PostMapping
|
|
|
|
|
public Mono<ResponseEntity<ExperimentsEntity>> createExperiment(@RequestBody ExperimentsEntity experiment) {
|
|
|
|
|
@ -77,6 +127,16 @@ public class ExperimentsController {
|
|
|
|
|
payload.put("description", saved.getDescription());
|
|
|
|
|
payload.put("namespace", "default"); // 필요에 따라 변경
|
|
|
|
|
|
|
|
|
|
// 날짜를 ISO 8601 UTC 포맷으로
|
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ISO_INSTANT;
|
|
|
|
|
|
|
|
|
|
payload.computeIfPresent("created_at", (k, v) ->
|
|
|
|
|
saved.getKubeflowCreatedAt() != null
|
|
|
|
|
? saved.getKubeflowCreatedAt().atZone(ZoneId.of("Asia/Seoul")).format(formatter)
|
|
|
|
|
: null
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3️⃣ WebClient POST
|
|
|
|
|
return webClientBuilder.build()
|
|
|
|
|
.post()
|
|
|
|
|
@ -84,21 +144,9 @@ public class ExperimentsController {
|
|
|
|
|
.contentType(MediaType.APPLICATION_JSON)
|
|
|
|
|
.bodyValue(payload)
|
|
|
|
|
.retrieve()
|
|
|
|
|
.bodyToMono(Map.class) // Kubeflow 응답
|
|
|
|
|
.map(resp -> {
|
|
|
|
|
// resp에서 필요한 값 추출 후 entity에 반영
|
|
|
|
|
if (resp.get("last_run_created_at") != null) {
|
|
|
|
|
String lastRunStr = resp.get("last_run_created_at").toString();
|
|
|
|
|
OffsetDateTime odt = OffsetDateTime.parse(lastRunStr);
|
|
|
|
|
saved.setKubeflowLastRunCreatedAt(odt.withOffsetSameInstant(ZoneId.of("Asia/Seoul").getRules().getOffset(odt.toInstant()))
|
|
|
|
|
.toLocalDateTime());
|
|
|
|
|
}
|
|
|
|
|
if(resp.get("id") != null) {
|
|
|
|
|
saved.setKubeFlowId(resp.get("id").toString());
|
|
|
|
|
}
|
|
|
|
|
return saved;
|
|
|
|
|
})
|
|
|
|
|
.map(entity -> ResponseEntity.ok(entity))
|
|
|
|
|
.bodyToMono(Map.class) // 응답 필요 없으면 Void.class
|
|
|
|
|
.doOnNext(resp -> log.info("Kubeflow experiment 등록 완료: {}", resp))
|
|
|
|
|
.then(Mono.just(ResponseEntity.ok(saved))) // DB 저장된 엔티티 반환
|
|
|
|
|
.doOnError(e -> log.error("Kubeflow experiment 등록 실패", e));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|