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 11 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 @@
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.

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / build

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / build

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / verify (ubuntu-latest)

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / CocoaPods

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / build

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / build

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / verify (windows-latest)

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / Gradle

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / verify (macos-latest)

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / Go

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / Maven

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / NPM

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / NuGet

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / Pip

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / Pnpm

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / Poetry

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / Ruby

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / Rust

Code should not contain trailing whitespace

Check failure on line 23 in src/Microsoft.ComponentDetection.Orchestrator/Experiments/IExperimentService.cs

View workflow job for this annotation

GitHub Actions / Yarn

Code should not contain trailing whitespace
/// </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 @@ -510,19 +510,6 @@ public async Task ProcessDetectorsAsync_HandlesDetectorArgsAsync()
.And.Contain("arg3", "val3");
}

[TestMethod]
amitla1 marked this conversation as resolved.
Show resolved Hide resolved
public async Task ProcessDetectorsAsync_FinishesExperimentsAsync()
{
this.detectorsToUse = new[]
{
this.firstFileComponentDetectorMock.Object, this.secondFileComponentDetectorMock.Object,
};

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

this.experimentServiceMock.Verify(x => x.FinishAsync(), Times.Once());
}

[TestMethod]
public async Task ProcessDetectorsAsync_RecordsDetectorRunsAsync()
{
Expand Down
Loading