Skip to content

Commit

Permalink
updated to call finishasync in CD
Browse files Browse the repository at this point in the history
  • Loading branch information
Amitla Vannikumar committed Aug 15, 2023
1 parent 4339619 commit dac8ea0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,18 @@ private void FilterExperiments(IComponentDetector detector, int count)
}

/// <inheritdoc />
public async Task FinishAsync()
public async Task FinishAsync(bool shouldCheckAutomaticProcessFlag = false)
{
if (!DetectorExperiments.AreExperimentsEnabled)
{
return;
}

if (!shouldCheckAutomaticProcessFlag && !Orchestrator.AutomaticallyProcessExperiments)
{
return;
}

foreach (var (config, experiment) in this.experiments)
{
var controlComponents = experiment.ControlGroupComponents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ public interface IExperimentService
/// Called when all detectors have finished executing. Processes the experiments and reports the results.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
Task FinishAsync();
Task FinishAsync(bool shouldCheckAutomaticProcessFlag = false);
}
2 changes: 2 additions & 0 deletions src/Microsoft.ComponentDetection.Orchestrator/Orchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ namespace Microsoft.ComponentDetection.Orchestrator;

public class Orchestrator
{
public const bool AutomaticallyProcessExperiments = false;

private static readonly bool IsLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);

private readonly IServiceProvider serviceProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ public async Task<DetectorProcessingResult> ProcessDetectorsAsync(IDetectionArgu
record.DetectedComponentCount = detectedComponents.Count();
var dependencyGraphs = componentRecorder.GetDependencyGraphsByLocation().Values;
record.ExplicitlyReferencedComponentCount = dependencyGraphs.Select(dependencyGraph =>
{
return dependencyGraph.GetAllExplicitlyReferencedComponents();
})
{
return dependencyGraph.GetAllExplicitlyReferencedComponents();
})
.SelectMany(x => x)
.Distinct()
.Count();
Expand Down Expand Up @@ -122,6 +122,7 @@ public async Task<DetectorProcessingResult> ProcessDetectorsAsync(IDetectionArgu
}).ToList();

var results = await Task.WhenAll(scanTasks);
await this.experimentService.FinishAsync();

var detectorProcessingResult = this.ConvertDetectorResultsIntoResult(results, exitCode);

Expand Down

0 comments on commit dac8ea0

Please sign in to comment.