Exemple #1
0
        public ActionResult Add(ExperimentViewModel viewModel, int hidNumVariables)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    viewModel.Experiment.CreatedBy = HttpContext.User.Identity.Name;
                    viewModel.Experiment.Variables = new List <string>();

                    for (int i = 0; i < hidNumVariables; i++)
                    {
                        var variable = Request["variable-" + i];
                        if (!string.IsNullOrEmpty(variable))
                        {
                            viewModel.Experiment.Variables.Add(variable);
                        }
                    }

                    viewModel.Experiment = experimentRepository.Add(viewModel.Experiment);
                    return(Redirect("/Experiments/"));
                }
                else
                {
                    ViewBag.ErrorMessage = "There is a problem with one of your responses.";
                }
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "An Error Occurred while attempting to save that experiment.";
            }

            viewModel.Cohorts = cohortRepository.GetAll().ToList();
            return(View(viewModel));
        }
Exemple #2
0
        public ActionResult Create(Experiment newExperiment)
        {
            string pageAction = "Create";

            try
            {
                if (ModelState.IsValid)
                {
                    _eRepository.Add(newExperiment);
                    return(RedirectToAction("Edit", new { id = newExperiment.Id, fromSave = "Saved" }));
                }
                returnModelToEdit(pageAction, ref newExperiment);
                return(View("Edit", newExperiment));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                returnModelToEdit(pageAction, ref newExperiment);
                return(View("Edit", newExperiment));
            }
        }
        /// <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);
        }