/** * Get an ordered version of the configuration that matches the actual pipeline order * * @return Ordered config */ @SuppressWarnings("squid:RedundantThrowsDeclarationCheck" /* thrown from extending class */) public String orderedConfig() throws IOException { // Replace annotators and consumers with ordered versions List<Object> ann = new ArrayList<>(); for (AnalysisEngine a : annotators) { ann.add(a.getConfigParameterValue(PipelineBuilder.ORIGINAL_CONFIG)); } List<Object> con = new ArrayList<>(); for (AnalysisEngine c : consumers) { con.add(c.getConfigParameterValue(PipelineBuilder.ORIGINAL_CONFIG)); } return config.dumpOrdered(ann, con); }
/** * Get an ordered version of the configuration that matches the actual pipeline order * * @return Ordered config */ @SuppressWarnings("squid:RedundantThrowsDeclarationCheck" /* thrown from extending class */) public String orderedConfig() throws IOException { // Replace annotators and consumers with ordered versions List<Object> ann = new ArrayList<>(); for (AnalysisEngine a : annotators) { ann.add(a.getConfigParameterValue(PipelineBuilder.ORIGINAL_CONFIG)); } List<Object> con = new ArrayList<>(); for (AnalysisEngine c : consumers) { con.add(c.getConfigParameterValue(PipelineBuilder.ORIGINAL_CONFIG)); } return config.dumpOrdered(ann, con); }
private AnalysisEngineAction getAction(AnalysisEngine ae) { String uuid = (String) ae.getConfigParameterValue(PipelineBuilder.ANNOTATOR_UUID); return AnalysisEngineActionStore.getInstance().get(uuid); } }
private AnalysisEngineAction getAction(AnalysisEngine ae) { String uuid = (String) ae.getConfigParameterValue(PipelineBuilder.ANNOTATOR_UUID); return AnalysisEngineActionStore.getInstance().get(uuid); } }
@Override public List<AnalysisEngine> orderPipeline(List<AnalysisEngine> analysisEngines) { Graph<AnalysisEngine, Integer> graph = createDependencyGraph(analysisEngines); removeLoops(graph); List<AnalysisEngine> ordered = new ArrayList<>(analysisEngines.size()); while (true) { Set<AnalysisEngine> toRemove = removeLayer(graph); ordered.addAll(toRemove); if (toRemove.isEmpty() && graph.getVertexCount() == 0) { break; } else if (toRemove.isEmpty()) { LOGGER.error("Unsolvable dependency graph. Original order will be used."); debugUnresolvedGraph( analysisEngines .get(0) .getConfigParameterValue(PipelineBuilder.PIPELINE_NAME) .toString(), graph, ordered); return analysisEngines; } } return ordered; }
@Override public List<AnalysisEngine> orderPipeline(List<AnalysisEngine> analysisEngines) { Graph<AnalysisEngine, Integer> graph = createDependencyGraph(analysisEngines); removeLoops(graph); List<AnalysisEngine> ordered = new ArrayList<>(analysisEngines.size()); while (true) { Set<AnalysisEngine> toRemove = removeLayer(graph); ordered.addAll(toRemove); if (toRemove.isEmpty() && graph.getVertexCount() == 0) { break; } else if (toRemove.isEmpty()) { LOGGER.error("Unsolvable dependency graph. Original order will be used."); debugUnresolvedGraph( analysisEngines .get(0) .getConfigParameterValue(PipelineBuilder.PIPELINE_NAME) .toString(), graph, ordered); return analysisEngines; } } return ordered; }
private void destroyAnalysisEngines() { for (AnalysisEngine ae : annotators) { AnalysisEngineActionStore.getInstance() .remove((String) ae.getConfigParameterValue(PipelineBuilder.ANNOTATOR_UUID)); ae.destroy(); } for (AnalysisEngine ae : consumers) { AnalysisEngineActionStore.getInstance() .remove((String) ae.getConfigParameterValue(PipelineBuilder.ANNOTATOR_UUID)); ae.destroy(); } }
private void destroyAnalysisEngines() { for (AnalysisEngine ae : annotators) { AnalysisEngineActionStore.getInstance() .remove((String) ae.getConfigParameterValue(PipelineBuilder.ANNOTATOR_UUID)); ae.destroy(); } for (AnalysisEngine ae : consumers) { AnalysisEngineActionStore.getInstance() .remove((String) ae.getConfigParameterValue(PipelineBuilder.ANNOTATOR_UUID)); ae.destroy(); } }
assertEquals("red", ann0.getConfigParameterValue("example.color")); assertEquals(7, ann0.getConfigParameterValue("example.count")); assertEquals(null, ann0.getConfigParameterValue("shape")); assertEquals("green", ann1.getConfigParameterValue("example.color")); assertEquals(7, ann1.getConfigParameterValue("example.count")); assertEquals(null, ann1.getConfigParameterValue("shape")); assertEquals("red", ann2.getConfigParameterValue("example.color")); assertEquals(7, ann2.getConfigParameterValue("example.count")); assertEquals(null, ann2.getConfigParameterValue("shape")); assertEquals("red", ann3.getConfigParameterValue("example.color")); assertEquals(6, ann3.getConfigParameterValue("example.count")); assertEquals("square", ann3.getConfigParameterValue("shape")); assertEquals("red", con0.getConfigParameterValue("example.color")); assertEquals(7, con0.getConfigParameterValue("example.count")); assertEquals("blue", con1.getConfigParameterValue("example.color")); assertEquals(7, con1.getConfigParameterValue("example.count")); assertEquals("circle", con1.getConfigParameterValue("shape"));
@Test public void testValid1() throws Exception { String yaml = Files.asCharSource(getFile("jobConfig.yaml"), Charset.defaultCharset()).read(); JobBuilder jb = new JobBuilder("Test Job", new YamlPipelineConfiguration(yaml)); BaleenJob job = (BaleenJob) jb.createNewPipeline(); assertEquals("Test Job", job.getName()); assertEquals(yaml, job.originalConfig()); assertEquals(yaml, job.orderedConfig()); CollectionReader cr = job.collectionReader(); assertEquals("uk.gov.dstl.baleen.schedules.Other", cr.getMetaData().getName()); assertEquals("Foo", cr.getConfigParameterValue("key")); List<AnalysisEngine> annotators = job.annotators(); assertEquals(2, annotators.size()); AnalysisEngine ann0 = annotators.get(0); assertEquals("uk.gov.dstl.baleen.testing.DummyTask", ann0.getMetaData().getName()); assertEquals("Foo", ann0.getConfigParameterValue("key")); AnalysisEngine ann1 = annotators.get(1); assertEquals("uk.gov.dstl.baleen.testing.DummyTaskParams", ann1.getMetaData().getName()); assertEquals("Bar", ann1.getConfigParameterValue("key")); List<AnalysisEngine> consumers = job.consumers(); assertEquals(0, consumers.size()); }
@Test public void testValid2() throws Exception { String yaml = Files.asCharSource(getFile("jobConfig2.yaml"), Charset.defaultCharset()).read(); JobBuilder jb = new JobBuilder("Test Job", new YamlPipelineConfiguration(yaml)); BaleenJob job = (BaleenJob) jb.createNewPipeline(); assertEquals("Test Job", job.getName()); assertEquals(yaml, job.originalConfig()); assertEquals(yaml, job.orderedConfig()); CollectionReader cr = job.collectionReader(); assertEquals(BaleenDefaults.DEFAULT_SCHEDULER, cr.getMetaData().getName()); assertEquals("Foo", cr.getConfigParameterValue("key")); List<AnalysisEngine> annotators = job.annotators(); assertEquals(2, annotators.size()); AnalysisEngine ann0 = annotators.get(0); assertEquals("uk.gov.dstl.baleen.testing.DummyTask", ann0.getMetaData().getName()); assertEquals("Foo", ann0.getConfigParameterValue("key")); AnalysisEngine ann1 = annotators.get(1); assertEquals("uk.gov.dstl.baleen.testing.DummyTaskParams", ann1.getMetaData().getName()); assertEquals("Bar", ann1.getConfigParameterValue("key")); List<AnalysisEngine> consumers = job.consumers(); assertEquals(0, consumers.size()); }
@Test public void testValid3() throws Exception { String yaml = Files.asCharSource(getFile("jobConfig3.yaml"), Charset.defaultCharset()).read(); JobBuilder jb = new JobBuilder("Test Job", new YamlPipelineConfiguration(yaml)); BaleenJob job = (BaleenJob) jb.createNewPipeline(); assertEquals("Test Job", job.getName()); assertEquals(yaml, job.originalConfig()); assertEquals(yaml, job.orderedConfig()); CollectionReader cr = job.collectionReader(); assertEquals("uk.gov.dstl.baleen.schedules.Other", cr.getMetaData().getName()); assertEquals("Foo", cr.getConfigParameterValue("key")); List<AnalysisEngine> annotators = job.annotators(); assertEquals(2, annotators.size()); AnalysisEngine ann0 = annotators.get(0); assertEquals("uk.gov.dstl.baleen.testing.DummyTask", ann0.getMetaData().getName()); assertEquals("Foo", ann0.getConfigParameterValue("key")); AnalysisEngine ann1 = annotators.get(1); assertEquals("uk.gov.dstl.baleen.testing.DummyTaskParams", ann1.getMetaData().getName()); assertEquals("Bar", ann1.getConfigParameterValue("key")); List<AnalysisEngine> consumers = job.consumers(); assertEquals(0, consumers.size()); }