Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #2081 PKSim CLI filter simulation #2082

Merged
merged 4 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/PKSim.Assets.Images/PKSim.Assets.Images.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Assets" Version="11.0.62" />
<PackageReference Include="OSPSuite.Assets.Images" Version="11.0.62" />
<PackageReference Include="OSPSuite.Assets" Version="11.0.60" />
<PackageReference Include="OSPSuite.Assets.Images" Version="11.0.60" />
<PackageReference Include="OSPSuite.Assets" Version="11.0.72" />
<PackageReference Include="OSPSuite.Assets.Images" Version="11.0.72" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 2 additions & 4 deletions src/PKSim.Assets/PKSim.Assets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Assets" Version="11.0.62" />
<PackageReference Include="OSPSuite.Assets.Images" Version="11.0.62" />
<PackageReference Include="OSPSuite.Assets" Version="11.0.60" />
<PackageReference Include="OSPSuite.Assets.Images" Version="11.0.60" />
<PackageReference Include="OSPSuite.Assets" Version="11.0.72" />
<PackageReference Include="OSPSuite.Assets.Images" Version="11.0.72" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/PKSim.Assets/PKSimConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,9 @@ public static string MapToSnapshotNotSupportedWithoutContext(string snapshotType

public static string CannotFindSimulationInSnapshot(string simulationName, string project) => CannotFindBuildingBlockInSnapshot(ObjectTypes.Simulation, simulationName, project);

public static string SimulationUsedInPlotsAreNotExported(IReadOnlyList<string> simulationNames, string project)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making sure that simulation used in plots are also referenced here. This is just a simple validation step.

=> $"{ObjectTypes.Simulation.PluralizeIf(simulationNames)} {simulationNames.ToString(", ", "'")} used in plots {"is".PluralizeIf(simulationNames)} not found in the list of exported simulations for {ObjectTypes.Project} {project}";

public static string CannotFindSimulationParameterInSnapshot(string parameterPath, string simulationName, string project) =>
$"Could not find {ObjectTypes.Parameter} with path '{parameterPath}' in {ObjectTypes.Simulation} '{simulationName}' defined in snapshot {project}.";

Expand Down
3 changes: 1 addition & 2 deletions src/PKSim.BatchTool/PKSim.BatchTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
<PackageReference Include="OSPSuite.DevExpress" Version="21.2.3" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.51" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.45" GeneratePathProperty="true" />
Expand Down
3 changes: 1 addition & 2 deletions src/PKSim.CLI.Core/PKSim.CLI.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@

<ItemGroup>
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/PKSim.CLI.Core/RunOptions/QualificationRunOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@ public class QualificationRunOptions
/// Should simulation be performed as part of the run?
/// </summary>
public bool Run { get; set; }

/// <summary>
/// Specifies if project files (snapshot and PK-Sim project file should be exported)
/// </summary>
public bool ExportProjectFiles { get; set; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we export the project files or not. Default will be not because I don't think we need to export those for the qualification

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, let's keep it like this.
If this option can be passed to the QualificationRunner later I'm perfectly fine with that :)

}
}
29 changes: 21 additions & 8 deletions src/PKSim.CLI.Core/Services/QualificationRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ public async Task RunBatchAsync(QualificationRunOptions runOptions)
{
OutputFolder = projectOutputFolder,
//We run the output, this is for the old matlab implementation where we need xml. Otherwise, we only need pkml export
ExportMode = runOptions.Run ? SimulationExportMode.Xml | SimulationExportMode.Csv : SimulationExportMode.Pkml
ExportMode = runOptions.Run ? SimulationExportMode.Xml | SimulationExportMode.Csv : SimulationExportMode.Pkml,

Simulations = config.Simulations
};

//Using absolute path for simulation folder. We need them to be relative
Expand All @@ -124,13 +126,16 @@ public async Task RunBatchAsync(QualificationRunOptions runOptions)
await _jsonSerializer.Serialize(mapping, config.MappingFile);
_logger.AddDebug($"Project mapping for '{project.Name}' exported to '{config.MappingFile}'", project.Name);

var projectFile = Path.Combine(config.TempFolder, $"{project.Name}{CoreConstants.Filter.PROJECT_EXTENSION}");
_workspacePersistor.SaveSession(_workspace, projectFile);
_logger.AddDebug($"Project saved to '{projectFile}'", project.Name);
if (runOptions.ExportProjectFiles)
{
var projectFile = Path.Combine(config.TempFolder, $"{project.Name}{CoreConstants.Filter.PROJECT_EXTENSION}");
_workspacePersistor.SaveSession(_workspace, projectFile);
_logger.AddDebug($"Project saved to '{projectFile}'", project.Name);

var snapshotFile = Path.Combine(config.TempFolder, $"{project.Name}{Constants.Filter.JSON_EXTENSION}");
await _snapshotTask.ExportModelToSnapshotAsync(project, snapshotFile);
_logger.AddDebug($"Project snapshot saved to '{snapshotFile}'", project.Name);
var snapshotFile = Path.Combine(config.TempFolder, $"{project.Name}{Constants.Filter.JSON_EXTENSION}");
await _snapshotTask.ExportModelToSnapshotAsync(project, snapshotFile);
_logger.AddDebug($"Project snapshot saved to '{snapshotFile}'", project.Name);
}

var end = DateTime.UtcNow;
var timeSpent = end - begin;
Expand All @@ -140,7 +145,15 @@ public async Task RunBatchAsync(QualificationRunOptions runOptions)
private PlotMapping[] retrievePlotDefinitionsFrom(Project snapshotProject, QualifcationConfiguration configuration)
{
var plotMappings = configuration.SimulationPlots?.SelectMany(x => retrievePlotDefinitionsForSimulation(x, snapshotProject));
return plotMappings?.ToArray() ?? Array.Empty<PlotMapping>();
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));
}

private void validateInputs(Project snapshotProject, QualifcationConfiguration configuration)
Expand Down
9 changes: 7 additions & 2 deletions src/PKSim.CLI/Commands/QualificationRunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ public class QualificationRunCommand : CLICommand<QualificationRunOptions>
[Option('r', "run", Required = false, HelpText = "Should the qualification runner also run the simulation or simply export the qualification report for further processing. Default is false")]
public bool Run { get; set; } = false;

[Option('e', "exp", Required = false, HelpText = "Should the qualification runner also export the project files (snapshot and PK-Sim project file). Default is false")]
public bool ExportProjectFiles { get; set; } = false;

public override QualificationRunOptions ToRunOptions()
{
return new QualificationRunOptions
{
ConfigurationFile = ConfigurationFile,
Validate = Validate,
Run = Run
Run = Run,
ExportProjectFiles = ExportProjectFiles
};
}

Expand All @@ -35,7 +39,8 @@ public override string ToString()
LogDefaultOptions(sb);
sb.AppendLine($"Validate: {Validate}");
sb.AppendLine($"Configuration file: {ConfigurationFile}");
sb.AppendLine($"Run Simulations: {Run}");
sb.AppendLine($"Run simulations: {Run}");
sb.AppendLine($"Export project files: {ExportProjectFiles}");
return sb.ToString();
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/PKSim.CLI/PKSim.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.8.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.0" />
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.72" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.51" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.45" GeneratePathProperty="true" />
Expand Down
12 changes: 4 additions & 8 deletions src/PKSim.Core/PKSim.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Assets" Version="11.0.62" />
<PackageReference Include="OSPSuite.Assets.Images" Version="11.0.62" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Assets" Version="11.0.60" />
<PackageReference Include="OSPSuite.Assets.Images" Version="11.0.60" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
<PackageReference Include="OSPSuite.Assets" Version="11.0.72" />
<PackageReference Include="OSPSuite.Assets.Images" Version="11.0.72" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="11.0.72" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
</ItemGroup>

Expand Down
24 changes: 8 additions & 16 deletions src/PKSim.Infrastructure/PKSim.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,14 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.0" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.13" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Infrastructure" Version="11.0.62" />
<PackageReference Include="OSPSuite.Infrastructure.Castle" Version="11.0.62" />
<PackageReference Include="OSPSuite.Infrastructure.Export" Version="11.0.62" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="11.0.62" />
<PackageReference Include="OSPSuite.Infrastructure.Reporting" Version="11.0.62" />
<PackageReference Include="OSPSuite.Infrastructure.Serialization" Version="11.0.62" />
<PackageReference Include="OSPSuite.Presentation.Serialization" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Infrastructure" Version="11.0.60" />
<PackageReference Include="OSPSuite.Infrastructure.Castle" Version="11.0.60" />
<PackageReference Include="OSPSuite.Infrastructure.Export" Version="11.0.60" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="11.0.60" />
<PackageReference Include="OSPSuite.Infrastructure.Reporting" Version="11.0.60" />
<PackageReference Include="OSPSuite.Infrastructure.Serialization" Version="11.0.60" />
<PackageReference Include="OSPSuite.Presentation.Serialization" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
<PackageReference Include="OSPSuite.Infrastructure" Version="11.0.72" />
<PackageReference Include="OSPSuite.Infrastructure.Castle" Version="11.0.72" />
<PackageReference Include="OSPSuite.Infrastructure.Export" Version="11.0.72" />
<PackageReference Include="OSPSuite.Infrastructure.Import" Version="11.0.72" />
<PackageReference Include="OSPSuite.Infrastructure.Reporting" Version="11.0.72" />
<PackageReference Include="OSPSuite.Infrastructure.Serialization" Version="11.0.72" />
<PackageReference Include="OSPSuite.Presentation.Serialization" Version="11.0.72" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
</ItemGroup>

Expand Down
10 changes: 5 additions & 5 deletions src/PKSim.Infrastructure/Services/ImportObservedDataTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,13 @@ public IEnumerable<string> PredefinedValuesFor(string name)
return Enumerable.Empty<string>();
}

public IReadOnlyList<string> DefaultMetaDataCategories => CoreConstants.ObservedData.DefaultProperties;
public IReadOnlyList<string> DefaultMetaDataCategories { get; } = CoreConstants.ObservedData.DefaultProperties;

public IReadOnlyList<string> ReadOnlyMetaDataCategories => new List<string> { };
public IReadOnlyList<string> ReadOnlyMetaDataCategories { get; } = new List<string> { };

public bool MolWeightAlwaysEditable { get; } = false;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@georgeDaskalakis I changed this stuff here. Also when you always return a constant, use {get;} instead 0f => false. A bit faster...


public bool MolWeightEditable => false;

public bool MolWeightVisible => true;
public bool MolWeightVisible { get; }= true;

private IEnumerable<string> predefinedGenders => predefinedValuesFor(addPredefinedGenderValues);

Expand Down
3 changes: 1 addition & 2 deletions src/PKSim.Matlab/PKSim.Matlab.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@

<ItemGroup>
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 2 additions & 4 deletions src/PKSim.Presentation/PKSim.Presentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@
<ItemGroup>
<PackageReference Include="OSPSuite.TeXReporting" Version="3.0.0.4" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.72" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions src/PKSim.R/PKSim.R.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@

<ItemGroup>
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.51" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.45" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModelSolver_CVODES" Version="4.1.0.8" GeneratePathProperty="true" />
Expand Down
9 changes: 3 additions & 6 deletions src/PKSim.UI/PKSim.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,9 @@
<PackageReference Include="OSPSuite.DataBinding.DevExpress" Version="6.0.0.2" />
<PackageReference Include="OSPSuite.DevExpress" Version="21.2.3" />
<PackageReference Include="OSPSuite.Utility" Version="4.0.0.4" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.62" />
<PackageReference Include="OSPSuite.UI" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.60" />
<PackageReference Include="OSPSuite.UI" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.72" />
<PackageReference Include="OSPSuite.UI" Version="11.0.72" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 2 additions & 4 deletions src/PKSim/PKSim.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
<PackageReference Include="OSPSuite.DevExpress" Version="21.2.3" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.51" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.45" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModelSolver_CVODES" Version="4.1.0.8" GeneratePathProperty="true" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.112" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.62" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.60" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.Presentation" Version="11.0.72" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.TeXReporting" Version="3.0.0.4" GeneratePathProperty="true" />

</ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions tests/PKSim.Matlab.Tests/PKSim.Matlab.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="OSPSuite.BDDHelper" Version="4.0.0.1" />
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.51" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.45" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModelSolver_CVODES" Version="4.1.0.8" GeneratePathProperty="true" />
Expand Down
3 changes: 1 addition & 2 deletions tests/PKSim.R.Tests/PKSim.R.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="OSPSuite.BDDHelper" Version="4.0.0.1" />
<PackageReference Include="OSPSuite.Core" Version="11.0.62" />
<PackageReference Include="OSPSuite.Core" Version="11.0.60" />
<PackageReference Include="OSPSuite.Core" Version="11.0.72" />
<PackageReference Include="OSPSuite.FuncParser" Version="4.0.0.51" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModel" Version="4.0.0.45" GeneratePathProperty="true" />
<PackageReference Include="OSPSuite.SimModelSolver_CVODES" Version="4.1.0.8" GeneratePathProperty="true" />
Expand Down
Loading