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

Move Location of Experiments Call to CD Internal #720

Merged
merged 28 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 15 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace Microsoft.ComponentDetection.Orchestrator.Experiments;
/// </summary>
public static class DetectorExperiments
{
public const bool AutomaticallyProcessExperiments = false;
amitla1 marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Manually enables detector experiments.
/// </summary>
Expand Down
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 && !DetectorExperiments.AutomaticallyProcessExperiments)
amitla1 marked this conversation as resolved.
Show resolved Hide resolved
{
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 @@ -19,8 +19,9 @@ public interface IExperimentService
void RecordDetectorRun(IComponentDetector detector, ComponentRecorder componentRecorder, IDetectionArguments detectionArguments);

/// <summary>
/// Called when all detectors have finished executing. Processes the experiments and reports the results.
/// Determines whether the the automatic processing flag should be checked.
/// The AutomaticallyProcessDetectors flag determins if experiments should be auotmatically processed.
/// </summary>
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
amitla1 marked this conversation as resolved.
Show resolved Hide resolved
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;
amitla1 marked this conversation as resolved.
Show resolved Hide resolved
amitla1 marked this conversation as resolved.
Show resolved Hide resolved

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
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ public async Task ProcessDetectorsAsync_FinishesExperimentsAsync()

await this.serviceUnderTest.ProcessDetectorsAsync(DefaultArgs, this.detectorsToUse, new DetectorRestrictions());

this.experimentServiceMock.Verify(x => x.FinishAsync(), Times.Once());
this.experimentServiceMock.Verify(x => x.FinishAsync(false), Times.Once());
amitla1 marked this conversation as resolved.
Show resolved Hide resolved
}

[TestMethod]
Expand Down
Loading