Пример #1
0
        /// <summary>
        /// 前処理なし実験の学習を開始する
        /// </summary>
        private async Task <IActionResult> RunExperimentTrainingWithoutPreprocess(CreateInputModel model,
                                                                                  TemplateVersion templateVersion, DataSetVersion dataSetVersion)
        {
            var registryTokenKey = await RegistRegistryToTenantAsync(templateVersion.TrainingContainerRegistry, templateVersion.TrainingContainerToken);

            if (registryTokenKey == null)
            {
                return(JsonBadRequest("Cannot register registry token"));
            }

            var gitToken = templateVersion.TrainingRepositoryToken ?? UserGitToken(templateVersion.TrainingRepositoryGitId);

            // 実験IDを発行するため、Experimentをここで作成
            var experiment = new Experiment
            {
                Name              = model.Name,
                DataSetId         = model.DataSetId,
                DataSetVersionId  = model.DataSetVersionId,
                TemplateId        = model.TemplateId,
                TemplateVersionId = model.TemplateVersionId,
            };

            experimentRepository.Add(experiment);
            unitOfWork.Commit();

            // kamonohashi学習に必要な情報を設定
            var trainingCreateInputModel = new ApiModels.TrainingApiModels.CreateInputModel
            {
                Name           = model.Name,
                ContainerImage = new ContainerImageInputModel
                {
                    RegistryId = templateVersion.TrainingContainerRegistryId,
                    Image      = templateVersion.TrainingContainerImage,
                    Tag        = templateVersion.TrainingContainerTag,
                },
                DataSetId = dataSetVersion.DataSetId,
                ParentIds = null,
                GitModel  = new GitCommitInputModel
                {
                    GitId      = templateVersion.TrainingRepositoryGitId,
                    Repository = templateVersion.TrainingRepositoryName,
                    Owner      = templateVersion.TrainingRepositoryOwner,
                    Branch     = templateVersion.TrainingRepositoryBranch,
                    CommitId   = templateVersion.TrainingRepositoryCommitId,
                },
                EntryPoint   = templateVersion.TrainingEntryPoint,
                Options      = null,
                Cpu          = templateVersion.TrainingCpu,
                Memory       = templateVersion.TrainingMemory,
                Gpu          = templateVersion.TrainingGpu,
                Partition    = null,
                Ports        = null,
                Memo         = $"Training of aquarium. experimentId:{ experiment.Id}",
                Tags         = null,
                Zip          = false,
                LocalDataSet = false,
            };

            // kamonohashi学習を開始
            (var trainingHistory, var result) = await TrainingController.DoCreate(trainingCreateInputModel,
                                                                                  dataSetRepository, nodeRepository, tenantRepository, trainingHistoryRepository,
                                                                                  clusterManagementLogic, dataSetLogic, gitLogic, tagLogic, unitOfWork,
                                                                                  CurrentUserInfo, ModelState, RequestUrl, "training", registryTokenKey, gitToken);

            // 実験の学習とkamonohashi学習を結び付ける
            if (trainingHistory != null)
            {
                experiment.TrainingHistoryId = trainingHistory.Id;
                experimentRepository.Update(experiment);
                unitOfWork.Commit();

                ((JsonResult)result).Value = new SimpleOutputModel(experiment);
            }
            else
            {
                experimentRepository.Delete(experiment);
                unitOfWork.Commit();
            }

            return(result);
        }