Exemple #1
0
        public void Explore <TBuilderArgs>(
            ExplorerContextBuilder <TBuilderArgs> contextBuilder,
            TBuilderArgs builderArgs)
        {
            MainTask = Task.Run(
                async() =>
            {
                // Validation
                await RunStage(
                    ExplorationStatus.Validating,
                    async() =>
                {
                    var contexts = await contextBuilder.Build(builderArgs, cancellationTokenSource.Token);

                    var mergedContext = contexts.Aggregate((ctx1, ctx2) => ctx1.Merge(ctx2));
                    SamplesToPublish  = mergedContext.SamplesToPublish;

                    var singleColumnScopes = contexts
                                             .Select(context => scopeBuilder.Build(explorationRootContainer.GetNestedContainer(), context))
                                             .ToList();

                    ColumnExplorations = singleColumnScopes
                                         .Select(scope => new ColumnExploration(scope))
                                         .ToImmutableArray();

                    if (MultiColumnEnabled)
                    {
                        var multiColumnScopeBuilder = new MultiColumnScopeBuilder(
                            singleColumnScopes.Select(_ => _.MetricsPublisher));

                        MultiColumnExploration = new MultiColumnExploration(
                            multiColumnScopeBuilder.Build(
                                explorationRootContainer.GetNestedContainer(),
                                mergedContext));
                    }
                });

                // Analyses
                await RunStage(
                    ExplorationStatus.Processing,
                    async() =>
                {
                    await Task.WhenAll(ColumnExplorations.Select(ce => ce.Completion));
                    cancellationTokenSource.Token.ThrowIfCancellationRequested();
                    await(MultiColumnExploration?.Completion ?? Task.CompletedTask);
                });

                // Completed successfully
                Status = ExplorationStatus.Complete;
            },
                cancellationTokenSource.Token);
        }
Exemple #2
0
        private List <List <object?> > UncorrelatedSampleRows(int rowCount)
        {
            var uncorrelatedSampleRows = new List <List <object?> >(
                Enumerable.Range(0, rowCount).Select(_ => new List <object?>()));

            foreach (var uncorrelatedSampleColumn in ColumnExplorations
                     .Select(ce => (IEnumerable?)ce.PublishedMetrics
                             .SingleOrDefault(m => m.Name == "sample_values")?.Metric)
                     .Select(metric => metric?.Cast <object?>() ?? Array.Empty <object?>()))
            {
                for (var i = 0; i < rowCount; i++)
                {
                    uncorrelatedSampleRows[i].Add(uncorrelatedSampleColumn.ElementAtOrDefault(i));
                }
            }

            return(uncorrelatedSampleRows);
        }