Skip to content

Commit 99dadd1

Browse files
committed
Fixes #2629 Option to subclass QualificationRunOptions for app specific arguments
1 parent f5c8b78 commit 99dadd1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/OSPSuite.CLI.Core/Services/QualificationRunner.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020

2121
namespace OSPSuite.CLI.Core.Services
2222
{
23-
public abstract class QualificationRunner<TSnapshotProject, TModelProject> : IBatchRunner<QualificationRunOptions> where TSnapshotProject : SnapshotBase, IWithName where TModelProject : Project
23+
public abstract class QualificationRunner<TSnapshotProject, TModelProject, TRunOptions> : IBatchRunner<TRunOptions>
24+
where TSnapshotProject : SnapshotBase, IWithName
25+
where TModelProject : Project
26+
where TRunOptions : QualificationRunOptions
2427
{
2528
protected readonly Cache<string, TSnapshotProject> _snapshotProjectCache = new Cache<string, TSnapshotProject>();
2629
protected readonly IDataRepositoryExportTask _dataRepositoryExportTask;
@@ -47,7 +50,7 @@ protected async Task<TSnapshotProject> SnapshotProjectFromFile(string snapshotPa
4750
return _snapshotProjectCache[snapshotPath];
4851
}
4952

50-
private Task<QualificationConfiguration> readConfigurationFrom(QualificationRunOptions runOptions)
53+
private Task<QualificationConfiguration> readConfigurationFrom(TRunOptions runOptions)
5154
{
5255
if (!FileHelper.FileExists(runOptions.ConfigurationFile))
5356
throw new QualificationRunException(FileDoesNotExist(runOptions.ConfigurationFile));
@@ -70,7 +73,7 @@ private string createProjectOutputFolder(string outputPath, string projectName)
7073

7174
private string relativePath(string path, string relativeTo) => FileHelper.CreateRelativePath(path, relativeTo, useUnixPathSeparator: true);
7275

73-
public async Task RunBatchAsync(QualificationRunOptions runOptions)
76+
public virtual async Task RunBatchAsync(TRunOptions runOptions)
7477
{
7578
_snapshotProjectCache.Clear();
7679
var (snapshot, config) = await readSnapshot(runOptions);
@@ -174,7 +177,7 @@ private async Task<ObservedDataMapping> exportObservedData(ModelDataRepository o
174177
};
175178
}
176179

177-
private async Task<(TSnapshotProject, QualificationConfiguration)> readSnapshot(QualificationRunOptions runOptions)
180+
private async Task<(TSnapshotProject, QualificationConfiguration)> readSnapshot(TRunOptions runOptions)
178181
{
179182
_logger.AddInfo(runOptions.Validate ? "Starting validation run..." : "Starting qualification run...");
180183

@@ -227,9 +230,9 @@ private PlotMapping[] retrievePlotDefinitionsFrom(TSnapshotProject snapshotProje
227230
throw new QualificationRunException(SimulationUsedInPlotsAreNotExported(unmappedSimulations, snapshotProject.Name));
228231
}
229232

230-
protected abstract Task<(TModelProject, InputMapping[])> LoadProjectAndExportInputs(QualificationRunOptions runOptions, TSnapshotProject snapshot, QualificationConfiguration config);
233+
protected abstract Task<(TModelProject, InputMapping[])> LoadProjectAndExportInputs(TRunOptions runOptions, TSnapshotProject snapshot, QualificationConfiguration config);
231234

232-
protected abstract SimulationExportMode ExportMode(QualificationRunOptions runOptions);
235+
protected abstract SimulationExportMode ExportMode(TRunOptions runOptions);
233236

234237
protected abstract Task<SimulationMapping[]> ExportSimulationsIn(TModelProject project, ExportRunOptions exportRunOptions);
235238

0 commit comments

Comments
 (0)