private async Task <QualificationRunResult> execute(QualifcationConfiguration qualifcationConfiguration, QualificationRunOptions runOptions, CancellationToken cancellationToken, bool validate) { _logger.AddDebug(Logs.StartingQualificationRunForProject(qualifcationConfiguration.Project)); var logFile = Path.Combine(qualifcationConfiguration.TempFolder, "log.txt"); var configFile = Path.Combine(qualifcationConfiguration.TempFolder, "config.json"); var project = qualifcationConfiguration.Project; var qualificationRunResult = new QualificationRunResult { ConfigFile = configFile, LogFile = logFile, Project = project, MappingFile = qualifcationConfiguration.MappingFile }; await _jsonSerializer.Serialize(qualifcationConfiguration, configFile); _logger.AddDebug(Logs.QualificationConfigurationForProjectExportedTo(project, configFile)); var pksimCLIPath = _applicationConfiguration.PKSimCLIPathFor(runOptions.PKSimInstallationFolder); if (!FileHelper.FileExists(pksimCLIPath)) { throw new QualificationRunException(Errors.PKSimCLIFileNotFound(pksimCLIPath)); } return(await Task.Run(() => { var code = startBatchProcess(configFile, logFile, runOptions.LogLevel, validate, project, pksimCLIPath, cancellationToken); qualificationRunResult.Success = (code == ExitCodes.Success); return qualificationRunResult; }, cancellationToken)); }
private Task <QualificationRunResult> runQualification(QualifcationConfiguration qualificationConfiguration) { using (var qualificationEngine = _qualificationEngineFactory.Create()) { return(qualificationEngine.Run(qualificationConfiguration, _runOptions, CancellationToken.None)); } }
private void validateInputs(Project snapshotProject, QualifcationConfiguration configuration) { configuration.Inputs?.Each(x => { var buildingBlock = snapshotProject.BuildingBlockByTypeAndName(x.Type, x.Name); if (buildingBlock == null) { throw new QualificationRunException(CannotFindBuildingBlockInSnapshot(x.Type.ToString(), x.Name, snapshotProject.Name)); } }); }
private InputMapping[] exportInputs(PKSimProject project, QualifcationConfiguration configuration) { if (configuration.Inputs == null) { return(Array.Empty <InputMapping>()); } // return Task.FromResult(Array.Empty<InputMapping>()); //TODO Enable parallel runs once https://github.com/Open-Systems-Pharmacology/OSPSuite.Utility/issues/26 is fixed // return Task.WhenAll(configuration.Inputs.Select(x => exportInput(project, configuration, x))); return(configuration.Inputs.Select(x => exportInput(project, configuration, x)).ToArray()); }
private PlotMapping[] retrievePlotDefinitionsFrom(Project snapshotProject, QualifcationConfiguration configuration) { var plotMappings = configuration.SimulationPlots?.SelectMany(x => retrievePlotDefinitionsForSimulation(x, snapshotProject)); var plotMappingsArray = plotMappings?.ToArray() ?? Array.Empty <PlotMapping>(); var exportedSimulations = configuration.Simulations?.ToArray() ?? Array.Empty <string>(); var unmappedSimulations = plotMappingsArray.Select(x => x.Simulation).Distinct().Where(x => !exportedSimulations.Contains(x)).ToList(); //All simulations referenced in the the plot mapping are also exported. We are good if (!unmappedSimulations.Any()) { return(plotMappingsArray); } throw new QualificationRunException(SimulationUsedInPlotsAreNotExported(unmappedSimulations, snapshotProject.Name)); }
protected override Task Context() { _snapshotTask = A.Fake <ISnapshotTask>(); _jsonSerializer = A.Fake <IJsonSerializer>(); _workspace = A.Fake <ICoreWorkspace>(); _workspacePersistor = A.Fake <IWorkspacePersistor>(); _exportSimulationRunner = A.Fake <IExportSimulationRunner>(); _logger = A.Fake <ILogger>(); _dataRepositoryTask = A.Fake <IDataRepositoryTask>(); _markdownReporterTask = A.Fake <IMarkdownReporterTask>(); sut = new QualificationRunner(_snapshotTask, _jsonSerializer, _workspace, _workspacePersistor, _exportSimulationRunner, _dataRepositoryTask, _markdownReporterTask, _logger); _runOptions = new QualificationRunOptions(); _qualificationConfiguration = new QualifcationConfiguration(); return(_completed); }
private InputMapping exportInput(PKSimProject project, QualifcationConfiguration configuration, Input input) { var buildingBlock = project.BuildingBlockByName(input.Name, input.Type); var inputsFolder = configuration.InputsFolder; var projectName = FileHelper.RemoveIllegalCharactersFrom(project.Name); var buildingBlockName = FileHelper.RemoveIllegalCharactersFrom(input.Name); var targetFolder = Path.Combine(inputsFolder, projectName, input.Type.ToString()); DirectoryHelper.CreateDirectory(targetFolder); var fileFullPath = Path.Combine(targetFolder, $"{buildingBlockName}{CoreConstants.Filter.MARKDOWN_EXTENSION}"); // Use wait for now until we can support // run of input _markdownReporterTask.ExportToMarkdown(buildingBlock, fileFullPath, input.SectionLevel).Wait(); _logger.AddDebug($"Input data for {input.Type} '{input.Name}' exported to '{fileFullPath}'", project.Name); return(new InputMapping { SectionId = input.SectionId, Path = relativePath(fileFullPath, configuration.OutputFolder) }); }
private async Task <ObservedDataMapping> exportObservedData(DataRepository observedData, QualifcationConfiguration configuration, PKSimProject project) { var observedDataOutputFolder = configuration.ObservedDataFolder; var removeIllegalCharactersFrom = FileHelper.RemoveIllegalCharactersFrom(observedData.Name); var csvFullPath = Path.Combine(observedDataOutputFolder, $"{removeIllegalCharactersFrom}{Constants.Filter.CSV_EXTENSION}"); var xlsFullPath = Path.Combine(observedDataOutputFolder, $"{removeIllegalCharactersFrom}{Constants.Filter.XLSX_EXTENSION}"); _logger.AddDebug($"Observed data '{observedData.Name}' exported to '{csvFullPath}'", project.Name); await _dataRepositoryExportTask.ExportToCsvAsync(observedData, csvFullPath); _logger.AddDebug($"Observed data '{observedData.Name}' exported to '{xlsFullPath}'", project.Name); await _dataRepositoryExportTask.ExportToExcelAsync(observedData, xlsFullPath, launchExcel : false); return(new ObservedDataMapping { Id = observedData.Name, Path = relativePath(csvFullPath, configuration.OutputFolder) }); }
private Task <ObservedDataMapping[]> exportAllObservedData(PKSimProject project, QualifcationConfiguration configuration) { if (!project.AllObservedData.Any()) { return(Task.FromResult(Array.Empty <ObservedDataMapping>())); } var observedDataOutputFolder = configuration.ObservedDataFolder; DirectoryHelper.CreateDirectory(observedDataOutputFolder); return(Task.WhenAll(project.AllObservedData.Select(x => exportObservedData(x, configuration, project)))); }
private SimulationMapping simulationMappingFrom(SimulationExport simulationExport, QualifcationConfiguration configuration) => new SimulationMapping { Path = relativePath(simulationExport.SimulationFolder, configuration.OutputFolder), Project = simulationExport.Project, Simulation = simulationExport.Simulation };
private PlotMapping[] retrievePlotDefinitionsFrom(Project snapshotProject, QualifcationConfiguration configuration) { var plotMappings = configuration.SimulationPlots?.SelectMany(x => retrievePlotDefinitionsForSimulation(x, snapshotProject)); return(plotMappings?.ToArray() ?? Array.Empty <PlotMapping>()); }
public Task <QualificationRunResult> Run(QualifcationConfiguration qualifcationConfiguration, QualificationRunOptions runOptions, CancellationToken cancellationToken) => execute(qualifcationConfiguration, runOptions, cancellationToken, validate: false);