Search in sources :

Example 1 with GraphKeyValueStore

use of com.graphaware.common.kv.GraphKeyValueStore in project neo4j-nlp by graphaware.

the class AbstractEmbeddedTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    clearDb();
    this.keyValueStore = new GraphKeyValueStore(getDatabase());
}
Also used : GraphKeyValueStore(com.graphaware.common.kv.GraphKeyValueStore) Before(org.junit.Before)

Example 2 with GraphKeyValueStore

use of com.graphaware.common.kv.GraphKeyValueStore in project neo4j-nlp by graphaware.

the class DynamicConfigurationTest method testWorfklowItemsInfosShouldBeLoadedFromPreviousState.

@Test
public void testWorfklowItemsInfosShouldBeLoadedFromPreviousState() throws Exception {
    resetSingleton();
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
    keyValueStore = new GraphKeyValueStore(getDatabase());
    QueryBasedWorkflowInput workflowInput = new QueryBasedWorkflowInput("test", getDatabase());
    DynamicConfiguration configuration = new DynamicConfiguration(getDatabase());
    workflowInput.setConfiguration(new WorkflowInputQueryConfiguration(new HashMap<>()));
    try (Transaction tx = getDatabase().beginTx()) {
        configuration.storeWorkflowInstanceItem(workflowInput);
        tx.success();
    }
    GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
    runtime.registerModule(new NLPModule("NLP", NLPConfiguration.defaultConfiguration(), getDatabase()));
    runtime.start();
    runtime.waitUntilStarted();
}
Also used : WorkflowInputQueryConfiguration(com.graphaware.nlp.workflow.input.WorkflowInputQueryConfiguration) Transaction(org.neo4j.graphdb.Transaction) HashMap(java.util.HashMap) GraphAwareRuntime(com.graphaware.runtime.GraphAwareRuntime) NLPModule(com.graphaware.nlp.module.NLPModule) GraphKeyValueStore(com.graphaware.common.kv.GraphKeyValueStore) QueryBasedWorkflowInput(com.graphaware.nlp.workflow.input.QueryBasedWorkflowInput) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test) AbstractEmbeddedTest(com.graphaware.nlp.AbstractEmbeddedTest)

Example 3 with GraphKeyValueStore

use of com.graphaware.common.kv.GraphKeyValueStore in project neo4j-nlp by graphaware.

the class DynamicConfigurationTest method testConfigurationValuesShouldBeLoadedFromPreviousState.

@Test
public void testConfigurationValuesShouldBeLoadedFromPreviousState() throws Exception {
    resetSingleton();
    ObjectMapper mapper = new ObjectMapper();
    mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
    keyValueStore = new GraphKeyValueStore(getDatabase());
    PipelineSpecification specification = new PipelineSpecification("custom", StubTextProcessor.class.getName());
    specification.setStopWords("hello,hihi");
    specification.setThreadNumber(4);
    try (Transaction tx = getDatabase().beginTx()) {
        String writeValueAsString = mapper.writeValueAsString(specification);
        keyValueStore.set("GA__NLP__PIPELINE_custom", writeValueAsString);
        keyValueStore.set("GA__NLP__SETTING_fallbackLanguage", "en");
        tx.success();
    }
    GraphAwareRuntime runtime = GraphAwareRuntimeFactory.createRuntime(getDatabase());
    runtime.registerModule(new NLPModule("NLP", NLPConfiguration.defaultConfiguration(), getDatabase()));
    runtime.start();
    runtime.waitUntilStarted();
    assertTrue(getStartedRuntime(getDatabase()).getModule(NLPModule.class).getNlpManager().getTextProcessorsManager().getTextProcessor(StubTextProcessor.class.getName()).getPipelines().contains("custom"));
    assertTrue(getStartedRuntime(getDatabase()).getModule(NLPModule.class).getNlpManager().getConfiguration().hasSettingValue(SettingsConstants.FALLBACK_LANGUAGE));
}
Also used : PipelineSpecification(com.graphaware.nlp.dsl.request.PipelineSpecification) Transaction(org.neo4j.graphdb.Transaction) GraphAwareRuntime(com.graphaware.runtime.GraphAwareRuntime) NLPModule(com.graphaware.nlp.module.NLPModule) GraphKeyValueStore(com.graphaware.common.kv.GraphKeyValueStore) StubTextProcessor(com.graphaware.nlp.stub.StubTextProcessor) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test) AbstractEmbeddedTest(com.graphaware.nlp.AbstractEmbeddedTest)

Example 4 with GraphKeyValueStore

use of com.graphaware.common.kv.GraphKeyValueStore in project neo4j-nlp by graphaware.

the class DynamicConfigurationTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    clearDb();
    this.keyValueStore = new GraphKeyValueStore(getDatabase());
}
Also used : GraphKeyValueStore(com.graphaware.common.kv.GraphKeyValueStore) Before(org.junit.Before)

Example 5 with GraphKeyValueStore

use of com.graphaware.common.kv.GraphKeyValueStore in project neo4j-nlp by graphaware.

the class DynamicConfigurationTest method testLoadingInstances.

@Test
public void testLoadingInstances() throws Exception {
    resetSingleton();
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
    keyValueStore = new GraphKeyValueStore(getDatabase());
    WorkflowTask workflowInput = new WorkflowTask("test", getDatabase());
    DynamicConfiguration configuration = new DynamicConfiguration(getDatabase());
    HashMap<String, Object> properties = new HashMap<>();
    properties.put(WorkflowTaskConfiguration.WORFKLOW_INPUT_NAME, "");
    properties.put(WorkflowTaskConfiguration.WORFKLOW_OUTPUT_NAME, "");
    properties.put(WorkflowTaskConfiguration.WORFKLOW_PROCESSOR_NAME, "");
    workflowInput.setConfiguration(new WorkflowTaskConfiguration(properties));
    try (Transaction tx = getDatabase().beginTx()) {
        configuration.storeWorkflowInstanceItem(workflowInput);
        tx.success();
    }
    List<WorkflowInstanceItemInfo> pipelineInstanceItems = configuration.loadWorkflowInstanceItems(WorkflowTask.WORFKLOW_TASK_KEY_PREFIX);
    assertTrue(pipelineInstanceItems.size() == 1);
    WorkflowInstanceItemInfo info = pipelineInstanceItems.get(0);
    assertTrue(info instanceof WorkflowTaskInstanceItemInfo);
    assertEquals("test", info.getName());
    assertEquals("com.graphaware.nlp.workflow.task.WorkflowTask", info.getClassName());
}
Also used : WorkflowTaskInstanceItemInfo(com.graphaware.nlp.workflow.task.WorkflowTaskInstanceItemInfo) WorkflowTaskConfiguration(com.graphaware.nlp.workflow.task.WorkflowTaskConfiguration) HashMap(java.util.HashMap) WorkflowTask(com.graphaware.nlp.workflow.task.WorkflowTask) WorkflowInstanceItemInfo(com.graphaware.nlp.dsl.result.WorkflowInstanceItemInfo) Transaction(org.neo4j.graphdb.Transaction) GraphKeyValueStore(com.graphaware.common.kv.GraphKeyValueStore) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.junit.Test) AbstractEmbeddedTest(com.graphaware.nlp.AbstractEmbeddedTest)

Aggregations

GraphKeyValueStore (com.graphaware.common.kv.GraphKeyValueStore)6 AbstractEmbeddedTest (com.graphaware.nlp.AbstractEmbeddedTest)3 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)3 Before (org.junit.Before)3 Test (org.junit.Test)3 Transaction (org.neo4j.graphdb.Transaction)3 NLPModule (com.graphaware.nlp.module.NLPModule)2 GraphAwareRuntime (com.graphaware.runtime.GraphAwareRuntime)2 HashMap (java.util.HashMap)2 PipelineSpecification (com.graphaware.nlp.dsl.request.PipelineSpecification)1 WorkflowInstanceItemInfo (com.graphaware.nlp.dsl.result.WorkflowInstanceItemInfo)1 StubTextProcessor (com.graphaware.nlp.stub.StubTextProcessor)1 QueryBasedWorkflowInput (com.graphaware.nlp.workflow.input.QueryBasedWorkflowInput)1 WorkflowInputQueryConfiguration (com.graphaware.nlp.workflow.input.WorkflowInputQueryConfiguration)1 WorkflowTask (com.graphaware.nlp.workflow.task.WorkflowTask)1 WorkflowTaskConfiguration (com.graphaware.nlp.workflow.task.WorkflowTaskConfiguration)1 WorkflowTaskInstanceItemInfo (com.graphaware.nlp.workflow.task.WorkflowTaskInstanceItemInfo)1