Beispiel #1
0
 protected SpeakerDataAnalyzer()
 {
     PipelinePhases.Add(nameof(AnalyzeContent), Phase.Process);
 }
Beispiel #2
0
 protected DataAnalyzer(string dataPipeline)
 {
     PipelinePhases.Add(dataPipeline, Phase.Process);
 }
Beispiel #3
0
        // The result array is sorted based on dependencies
        private static PipelinePhase[] GetPipelinePhases(PipelineCollection pipelines, ILogger logger)
        {
            // Perform a topological sort to create phases down the dependency tree
            Dictionary <string, PipelinePhases> phases = new Dictionary <string, PipelinePhases>(StringComparer.OrdinalIgnoreCase);
            List <PipelinePhases> sortedPhases         = new List <PipelinePhases>();
            HashSet <string>      visited = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (KeyValuePair <string, IPipeline> pipelineEntry in pipelines)
            {
                Visit(pipelineEntry.Key, pipelineEntry.Value);
            }

            // Make a pass through non-isolated transform phases to set dependencies to all non-isolated process phases
            foreach (PipelinePhases pipelinePhases in phases.Values.Where(x => !x.Isolated))
            {
                pipelinePhases.Transform.Dependencies =
                    pipelinePhases.Transform.Dependencies
                    .Concat(phases.Values.Where(x => x != pipelinePhases && !x.Isolated).Select(x => x.Process))
                    .ToArray();
            }

            return(sortedPhases
                   .Select(x => x.Input)
                   .Concat(sortedPhases.Select(x => x.Process))
                   .Concat(sortedPhases.Select(x => x.Transform))
                   .Concat(sortedPhases.Select(x => x.Output))
                   .ToArray());

            // Returns the process phases (if not isolated)
            PipelinePhases Visit(string name, IPipeline pipeline)
            {
                PipelinePhases pipelinePhases;

                if (pipeline.Isolated)
                {
                    // This is an isolated pipeline so just add the phases in a chain
                    pipelinePhases           = new PipelinePhases(true);
                    pipelinePhases.Input     = new PipelinePhase(pipeline, name, Phase.Input, pipeline.InputModules, logger);
                    pipelinePhases.Process   = new PipelinePhase(pipeline, name, Phase.Process, pipeline.ProcessModules, logger, pipelinePhases.Input);
                    pipelinePhases.Transform = new PipelinePhase(pipeline, name, Phase.Transform, pipeline.TransformModules, logger, pipelinePhases.Process);
                    pipelinePhases.Output    = new PipelinePhase(pipeline, name, Phase.Output, pipeline.OutputModules, logger, pipelinePhases.Transform);
                    phases.Add(name, pipelinePhases);
                    sortedPhases.Add(pipelinePhases);
                    return(pipelinePhases);
                }

                if (visited.Add(name))
                {
                    // Visit dependencies if this isn't an isolated pipeline
                    List <PipelinePhase> processDependencies = new List <PipelinePhase>();
                    foreach (string dependencyName in pipeline.Dependencies)
                    {
                        if (!pipelines.TryGetValue(dependencyName, out IPipeline dependency))
                        {
                            throw new Exception($"Could not find pipeline dependency {dependencyName} of {name}");
                        }
                        if (dependency.Isolated)
                        {
                            throw new Exception($"Pipeline {name} has dependency on isolated pipeline {dependencyName}");
                        }
                        processDependencies.Add(Visit(dependencyName, dependency).Process);
                    }

                    // Add the phases (by this time all dependencies should have been added)
                    pipelinePhases       = new PipelinePhases(false);
                    pipelinePhases.Input = new PipelinePhase(pipeline, name, Phase.Input, pipeline.InputModules, logger);
                    processDependencies.Insert(0, pipelinePhases.Input);                                                                                      // Makes sure the process phase is also dependent on it's input phase
                    pipelinePhases.Process   = new PipelinePhase(pipeline, name, Phase.Process, pipeline.ProcessModules, logger, processDependencies.ToArray());
                    pipelinePhases.Transform = new PipelinePhase(pipeline, name, Phase.Transform, pipeline.TransformModules, logger, pipelinePhases.Process); // Transform dependencies will be added after all pipelines have been processed
                    pipelinePhases.Output    = new PipelinePhase(pipeline, name, Phase.Output, pipeline.OutputModules, logger, pipelinePhases.Transform);
                    phases.Add(name, pipelinePhases);
                    sortedPhases.Add(pipelinePhases);
                }
                else if (!phases.TryGetValue(name, out pipelinePhases))
                {
                    throw new Exception($"Pipeline cyclical dependency detected involving {name}");
                }

                return(pipelinePhases);
            }
        }
Beispiel #4
0
 public ValidateDataFiles()
 {
     PipelinePhases.Add(nameof(Pipelines.SiteResources), Phase.Input);
 }