You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
autoflow-web-console/src/components/service/mlflow/MlflowService.ts

67 lines
2.0 KiB

import { request } from "@/components/service/index";
import { saveBlob, filenameFromContentDisposition } from "@/utils/download";
export const MlflowService = {
getRuns: (experimentId: string) => {
return request.get("/api/mlflow/runs", {
experimentId,
});
},
/** Kubeflow run id 태그로 MLflow run 검색 (전체 experiment 대상, experiment name 무관) */
getRunsByKubeflowRunId: (kubeflowRunId: string) => {
return request.get("/api/mlflow/runs/by-kubeflow-run-id", {
kubeflowRunId,
});
},
/** 전체 Experiment 목록 조회 (이름 등록 없이 동적 검색용) */
getExperiments: () => {
return request.get("/api/mlflow/experiments");
},
getExperimentByName: (experimentName: string) => {
return request.get("/api/mlflow/experiment", {
experimentName,
});
},
getExperimentRun: (runId: string) => {
return request.get("/api/mlflow/run", {
runId,
});
},
artifact: (runId: string, path?: string) => {
const params: Record<string, any> = {
runId,
run_id: runId,
};
if (path !== undefined) params.path = path;
// 1차: /list 시도 → 404면 구(舊) 경로로 폴백
return request
.get("/api/mlflow/artifacts/list", params)
.catch((err: any) => {
if (err?.response?.status === 404) {
return request.get("/api/mlflow/artifacts", params);
}
throw err;
});
},
/**
* MLflow get-artifact API artifact (MinIO NoSuchKey ).
*/
async downloadArtifact(runId: string, path: string): Promise<void> {
const res = await request.getFile("/api/mlflow/artifacts/download", {
run_id: runId,
path,
});
const blob: Blob = res.data;
const cd = res.headers?.["content-disposition"];
const fallback = path.split("/").pop() || "download.bin";
const filename = filenameFromContentDisposition(cd, fallback);
saveBlob(blob, filename);
},
};