Search in sources :

Example 6 with DefaultNodeProgressMonitor

use of org.knime.core.node.DefaultNodeProgressMonitor in project knime-core by knime.

the class LearnerTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    NodeFactory nodeFactory = new LogRegLearnerNodeFactory();
    Node node = new Node(nodeFactory);
    m_exec = new ExecutionContext(new DefaultNodeProgressMonitor(), node, SingleNodeContainer.MemoryPolicy.CacheOnDisc, new HashMap<Integer, ContainerTable>());
}
Also used : ExecutionContext(org.knime.core.node.ExecutionContext) NodeFactory(org.knime.core.node.NodeFactory) HashMap(java.util.HashMap) Node(org.knime.core.node.Node) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) Before(org.junit.Before)

Example 7 with DefaultNodeProgressMonitor

use of org.knime.core.node.DefaultNodeProgressMonitor in project knime-core by knime.

the class JoinerTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    NodeFactory<NodeModel> dummyFactory = (NodeFactory) new VirtualParallelizedChunkPortObjectInNodeFactory(new PortType[0]);
    m_exec = new ExecutionContext(new DefaultNodeProgressMonitor(), new Node(dummyFactory), SingleNodeContainer.MemoryPolicy.CacheOnDisc, new HashMap<Integer, ContainerTable>());
}
Also used : NodeModel(org.knime.core.node.NodeModel) ExecutionContext(org.knime.core.node.ExecutionContext) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) NodeFactory(org.knime.core.node.NodeFactory) HashMap(java.util.HashMap) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) Node(org.knime.core.node.Node) PortType(org.knime.core.node.port.PortType) Before(org.junit.Before)

Example 8 with DefaultNodeProgressMonitor

use of org.knime.core.node.DefaultNodeProgressMonitor in project knime-core by knime.

the class TableSorterWorker method doInBackground.

/**
 * {@inheritDoc}
 */
@Override
protected DataTable doInBackground() throws Exception {
    // passed to table sorter for progress
    long rowCount;
    if (m_inputTable instanceof BufferedDataTable) {
        rowCount = ((BufferedDataTable) m_inputTable).size();
    } else if (m_inputTable instanceof ContainerTable) {
        rowCount = ((ContainerTable) m_inputTable).size();
    } else {
        // unknown, no progress
        rowCount = -1;
    }
    publish(new NodeProgress(0.0, "Starting table sort..."));
    Collection<String> sortColNames = new ArrayList<String>(2);
    DataTableSpec spec = m_inputTable.getDataTableSpec();
    for (int i : m_sortOrder.getSortColumnIndices()) {
        String name;
        if (i < 0) {
            // row id
            name = DataTableSorter.ROWKEY_SORT_SPEC.getName();
        } else {
            name = spec.getColumnSpec(i).getName();
        }
        sortColNames.add(name);
    }
    long start = System.currentTimeMillis();
    LOGGER.debug("Starting interactive table sorting on column(s) " + sortColNames);
    boolean[] sortOrders = m_sortOrder.getSortColumnOrder();
    // it DOES NOT respect blobs -- they will be copied (expensive)
    DataTableSorter sorter = new DataTableSorter(m_inputTable, rowCount, sortColNames, sortOrders, false);
    NodeProgressListener progLis = new NodeProgressListener() {

        @Override
        public void progressChanged(final NodeProgressEvent pe) {
            publish(pe.getNodeProgress());
        }
    };
    m_nodeProgressMonitor = new DefaultNodeProgressMonitor();
    ExecutionMonitor exec = new ExecutionMonitor(m_nodeProgressMonitor);
    m_nodeProgressMonitor.addProgressListener(progLis);
    try {
        DataTable result = sorter.sort(exec);
        long elapsedMS = System.currentTimeMillis() - start;
        String time = StringFormat.formatElapsedTime(elapsedMS);
        LOGGER.debug("Interactive table sorting finished (" + time + ")");
        return result;
    } finally {
        m_nodeProgressMonitor.removeProgressListener(progLis);
    }
}
Also used : DataTable(org.knime.core.data.DataTable) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataTableSpec(org.knime.core.data.DataTableSpec) NodeProgressListener(org.knime.core.node.workflow.NodeProgressListener) NodeProgress(org.knime.core.node.workflow.NodeProgress) ArrayList(java.util.ArrayList) ContainerTable(org.knime.core.data.container.ContainerTable) NodeProgressEvent(org.knime.core.node.workflow.NodeProgressEvent) DataTableSorter(org.knime.core.data.sort.DataTableSorter) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) BufferedDataTable(org.knime.core.node.BufferedDataTable) ExecutionMonitor(org.knime.core.node.ExecutionMonitor)

Example 9 with DefaultNodeProgressMonitor

use of org.knime.core.node.DefaultNodeProgressMonitor in project knime-core by knime.

the class TableSorterTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    NodeFactory<NodeModel> dummyFactory = (NodeFactory) new VirtualParallelizedChunkPortObjectInNodeFactory(new PortType[0]);
    m_exec = new ExecutionContext(new DefaultNodeProgressMonitor(), new Node(dummyFactory), SingleNodeContainer.MemoryPolicy.CacheOnDisc, new HashMap<Integer, ContainerTable>());
}
Also used : NodeModel(org.knime.core.node.NodeModel) ExecutionContext(org.knime.core.node.ExecutionContext) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) NodeFactory(org.knime.core.node.NodeFactory) HashMap(java.util.HashMap) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) Node(org.knime.core.node.Node) PortType(org.knime.core.node.port.PortType) Before(org.junit.Before)

Example 10 with DefaultNodeProgressMonitor

use of org.knime.core.node.DefaultNodeProgressMonitor in project knime-core by knime.

the class Enh1536_CancelDuringLoad method setUp.

@Before
public void setUp() throws Exception {
    m_workflowDirectory = FileUtil.createTempDir(getClass().getSimpleName());
    NODE_PROGRESS_THREAD_LOCAL.set(new DefaultNodeProgressMonitor());
    final WorkflowCreationHelper creationHelper = new WorkflowCreationHelper();
    creationHelper.setWorkflowContext(new WorkflowContext.Factory(m_workflowDirectory).createContext());
    WorkflowManager wm = WorkflowManager.ROOT.createAndAddProject(getClass().getSimpleName(), creationHelper);
    NodeID sourceNode = wm.addNode(new AdapterNodeFactory(true));
    NodeID cancelOnLoadNode = wm.addNode(new CancelDuringLoadInternalsNodeFactory());
    NodeID checkLoadInternalNotCalledNode = wm.addNode(new CheckLoadInternalsNotCalledNodeFactory());
    wm.addConnection(sourceNode, 1, cancelOnLoadNode, 1);
    wm.addConnection(cancelOnLoadNode, 1, checkLoadInternalNotCalledNode, 1);
    wm.executeAllAndWaitUntilDone();
    assertEquals(wm.printNodeSummary(wm.getID(), 0), InternalNodeContainerState.EXECUTED, wm.getInternalState());
    wm.save(m_workflowDirectory, new ExecutionMonitor(), true);
    WorkflowManager.ROOT.removeNode(wm.getID());
}
Also used : DefaultNodeProgressMonitor(org.knime.core.node.DefaultNodeProgressMonitor) AdapterNodeFactory(org.knime.core.node.workflow.node.adapter.AdapterNodeFactory) AdapterNodeFactory(org.knime.core.node.workflow.node.adapter.AdapterNodeFactory) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) Before(org.junit.Before)

Aggregations

DefaultNodeProgressMonitor (org.knime.core.node.DefaultNodeProgressMonitor)10 Before (org.junit.Before)7 HashMap (java.util.HashMap)6 ExecutionContext (org.knime.core.node.ExecutionContext)6 Node (org.knime.core.node.Node)6 NodeFactory (org.knime.core.node.NodeFactory)6 NodeModel (org.knime.core.node.NodeModel)5 PortType (org.knime.core.node.port.PortType)5 VirtualParallelizedChunkPortObjectInNodeFactory (org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory)5 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)4 DataTableSpec (org.knime.core.data.DataTableSpec)2 Frame (java.awt.Frame)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)1 DataTable (org.knime.core.data.DataTable)1 ContainerTable (org.knime.core.data.container.ContainerTable)1 DataTableSorter (org.knime.core.data.sort.DataTableSorter)1 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)1