public IActionResult GetDataSetList([FromQuery] SearchInputModel filter, [FromQuery] int?perPage, [FromQuery] int page = 1, bool withTotal = false) { var dataSet = aquariumDataSetRepository.GetAll() .SearchLong(d => d.Id, filter.Id) .SearchString(d => d.Name, filter.Name) .SearchString(d => d.CreatedBy, filter.CreatedBy) .SearchTime(d => d.CreatedAt, filter.CreatedAt) .SearchString(d => d.ModifiedBy, filter.ModifiedBy) .SearchTime(d => d.ModifiedAt, filter.ModifiedAt); dataSet = dataSet.OrderByDescending(d => d.Id); if (withTotal) { SetTotalCountToHeader(dataSet.Count()); } // 未指定、あるいは1000件以上であれば、1000件に指定 var pageCount = (perPage.HasValue && perPage.Value < 1000) ? perPage.Value : 1000; dataSet = dataSet.Paging(page, pageCount); return(JsonOK(dataSet.Select(x => new IndexOutputModel(x)))); }
public async Task <IActionResult> Run([FromBody] CreateInputModel model) { if (!ModelState.IsValid) { return(JsonBadRequest("Invalid inputs.")); } var dataSet = await aquariumDataSetRepository .GetAll() .Include(x => x.DataSetVersions) .SingleOrDefaultAsync(x => x.Id == model.DataSetId); if (dataSet == null) { return(JsonNotFound($"DataSet ID {model.DataSetId} is not found.")); } var dataSetVersion = dataSet.DataSetVersions.SingleOrDefault(x => x.Id == model.DataSetVersionId); if (dataSetVersion == null) { return(JsonNotFound($"DataSetVersion (DataSetId {model.DataSetId} and VersionId {model.DataSetVersionId}) is not found.")); } var template = await templateRepository.GetByIdAsync(model.TemplateId); if (template == null) { return(JsonNotFound($"Template ID {model.TemplateId} is not found.")); } if (!templateLogic.Accessible(template, CurrentUserInfo.SelectedTenant)) { return(JsonBadRequest($"Template ID {model.TemplateId} is not accesible.")); } var templateVersion = await templateVersionRepository .GetAll() .Include(x => x.PreprocessContainerRegistry) .Include(x => x.TrainingContainerRegistry) .Include(x => x.EvaluationContainerRegistry) .SingleOrDefaultAsync(x => x.TemplateId == model.TemplateId && x.Id == model.TemplateVersionId); if (templateVersion == null) { return(JsonNotFound($"TemplateVersion (TemplateID {model.TemplateId} and VersionId {model.TemplateVersionId} is not found.")); } var registryMaps = registryRepository.GetUserTenantRegistryMapAll(CurrentUserInfo.SelectedTenant.Id, CurrentUserInfo.Id); if (templateVersion.PreprocessContainerRegistryId.HasValue && !registryMaps.Any(x => x.TenantRegistryMap.RegistryId == templateVersion.PreprocessContainerRegistryId.Value)) { return(JsonBadRequest($"Prprocess Container Registry ID {templateVersion.PreprocessContainerRegistryId.Value} is not accesible.")); } if (!registryMaps.Any(x => x.TenantRegistryMap.RegistryId == templateVersion.TrainingContainerRegistryId)) { return(JsonBadRequest($"Training Container Registry ID {templateVersion.TrainingContainerRegistryId} is not accesible.")); } if (templateVersion.EvaluationContainerRegistryId.HasValue && !registryMaps.Any(x => x.TenantRegistryMap.RegistryId == templateVersion.EvaluationContainerRegistryId.Value)) { return(JsonBadRequest($"Evaluation Container Registry ID {templateVersion.EvaluationContainerRegistryId.Value} is not accesible.")); } var gitMaps = gitRepository.GetUserTenantGitMapAll(CurrentUserInfo.SelectedTenant.Id, CurrentUserInfo.Id); if (templateVersion.PreprocessRepositoryGitId.HasValue && !gitMaps.Any(x => x.TenantGitMap.GitId == templateVersion.PreprocessRepositoryGitId.Value)) { return(JsonBadRequest($"Prprocess Repository Git ID {templateVersion.PreprocessRepositoryGitId.Value} is not accesible.")); } if (!gitMaps.Any(x => x.TenantGitMap.GitId == templateVersion.TrainingRepositoryGitId)) { return(JsonBadRequest($"Training Repository Git ID {templateVersion.TrainingRepositoryGitId} is not accesible.")); } if (templateVersion.EvaluationRepositoryGitId.HasValue && !gitMaps.Any(x => x.TenantGitMap.GitId == templateVersion.EvaluationRepositoryGitId.Value)) { return(JsonBadRequest($"Evaluation Repository Git ID {templateVersion.EvaluationRepositoryGitId.Value} is not accesible.")); } if (templateVersion.PreprocessContainerRegistryId == null) { // テンプレートに前処理がない return(await RunExperimentTrainingWithoutPreprocess(model, templateVersion, dataSetVersion)); } var experimentPreprocess = experimentPreprocessRepository .GetAll() .Include(x => x.TrainingHistory) .Where(x => x.TemplateId == model.TemplateId && x.TemplateVersionId == model.TemplateVersionId && x.DataSetId == model.DataSetId && x.DataSetVersionId == model.DataSetVersionId) .AsEnumerable() .FirstOrDefault(x => x.TrainingHistory.GetStatus() == ContainerStatus.Completed); if (experimentPreprocess == null) { // テンプレートに前処理があり、前処理が実行されていない return(await RunExperimentPreprocess(model, templateVersion, dataSetVersion)); } // テンプレートに前処理があり、前処理が別実験で実行ずみ return(await RunExperimentTrainingWithPreprocess(model, templateVersion, dataSetVersion, experimentPreprocess)); }