public static PipelineIR compileSources(List<SourceWithMetadata> sourcesWithMetadata, boolean supportEscapes, ConfigVariableExpander cve) throws InvalidIRException {
        Map<PluginDefinition.Type, List<Graph>> groupedPipelineSections = sourcesWithMetadata.stream()
                .map(swm -> compileGraph(swm, supportEscapes, cve))
                .flatMap(m -> m.entrySet().stream())
                .filter(e -> e.getValue() != null)
                .collect(groupingBy(Map.Entry::getKey,
                            mapping(Map.Entry::getValue, toList())));

        Graph inputGraph = Graph.combine(groupedPipelineSections.get(PluginDefinition.Type.INPUT).toArray(new Graph[0])).graph;
        Graph outputGraph = Graph.combine(groupedPipelineSections.get(PluginDefinition.Type.OUTPUT).toArray(new Graph[0])).graph;
        Graph filterGraph = groupedPipelineSections.get(PluginDefinition.Type.FILTER).stream()
                .reduce(ConfigCompiler::chainWithUntypedException).orElse(null);

        String originalSource = sourcesWithMetadata.stream().map(SourceWithMetadata::getText).collect(Collectors.joining("\n"));
        return new PipelineIR(inputGraph, filterGraph, outputGraph, originalSource);
    }
@Test
    public void testCompilingPipelineWithMultipleSources() throws InvalidIRException {
        String sourceId = "fake_sourcefile";
        String sourceProtocol = "test_proto";
        SourceWithMetadata sourceWithMetadata = new SourceWithMetadata(sourceProtocol, sourceId, 0, 0, "booo");

        String[] sources = new String[] {
                "input { input_0 {} } filter { filter_0 {} } output { output_0 {} }",
                "input { input_1 {} } filter { filter_1 {} } output { output_1 {} }"};

        List<SourceWithMetadata> sourcesWithMetadata = Arrays.asList(
                new SourceWithMetadata(sourceProtocol + "_" + 0, sourceId + "_" + 0, 0, 0, sources[0]),
                new SourceWithMetadata(sourceProtocol + "_" + 1, sourceId + "_" + 1, 0, 0, sources[1]));

        PipelineIR pipeline = ConfigCompiler.compileSources(sourcesWithMetadata, false, null);

        assertFalse("should generate a hash", pipeline.uniqueHash().isEmpty());
        assertEquals("should provide the original source", String.join("\n", sources),
                pipeline.getOriginalSource());
        verifyApplyingProtocolAndIdMetadata(pipeline);
    }