/// <summary> /// 推論履歴コンテナを削除し、ステータスを変更する。 /// </summary> /// <param name="inferenceHistory">対象学習履歴</param> /// <param name="status">変更後のステータス</param> /// <param name="force">他テナントに対する変更を許可するか</param> public async Task ExitAsync(InferenceHistory inferenceHistory, ContainerStatus status, bool force) { // コンテナの生存確認 if (inferenceHistory.GetStatus().Exist()) { var info = await clusterManagementLogic.GetContainerDetailsInfoAsync(inferenceHistory.Key, CurrentUserInfo.SelectedTenant.Name, force); // コンテナ削除の前に、DBの更新を先に実行 await inferenceHistoryRepository.UpdateStatusAsync(inferenceHistory.Id, status, info.CreatedAt, DateTime.Now, force); // 実コンテナ削除の結果は確認せず、DBの更新を先に確定する(コンテナがいないなら、そのまま消しても問題ない想定) unitOfWork.Commit(); if (info.Status.Exist()) { // 再確認してもまだ存在していたら、コンテナ削除 await clusterManagementLogic.DeleteContainerAsync( ContainerType.Training, inferenceHistory.Key, CurrentUserInfo.SelectedTenant.Name, force); } } else { await inferenceHistoryRepository.UpdateStatusAsync(inferenceHistory.Id, status, force); // DBの更新を確定する unitOfWork.Commit(); } }
/// <summary> /// ステータスを更新して、出力モデルに変換する /// </summary> private async Task <InferenceIndexOutputModel> GetUpdatedIndexOutputModelAsync(InferenceHistory history) { var model = new InferenceIndexOutputModel(history); var status = history.GetStatus(); if (status.Exist()) { //推論がまだ進行中の場合、情報を更新する var newStatus = await clusterManagementLogic.GetContainerStatusAsync(history.Key, CurrentUserInfo.SelectedTenant.Name, false); if (status.Key != newStatus.Key) { //更新があったので、変更処理 await inferenceHistoryRepository.UpdateStatusAsync(history.Id, newStatus, false); unitOfWork.Commit(); model.Status = newStatus.Name; } } // storageへの出力値があれば取得し、modelに格納 var outputFileName = "value.txt"; //値を読み込むファイル名 var outputPath = history.Id + "/" + outputFileName; var content = await storageLogic.GetFileContentAsync(ResourceType.InferenceContainerOutputFiles, outputPath, outputFileName, true); if (content != null) { model.OutputValue = content; } return(model); }