Search in sources :

Example 1 with WorkflowExecutionResult

use of org.knime.core.node.workflow.execresult.WorkflowExecutionResult in project knime-core by knime.

the class WorkflowManager method loadExecutionResult.

/**
 * {@inheritDoc}
 */
@Override
public void loadExecutionResult(final NodeContainerExecutionResult result, final ExecutionMonitor exec, final LoadResult loadResult) {
    CheckUtils.checkArgument(result instanceof WorkflowExecutionResult, "Argument must be instance of \"%s\": %s", WorkflowExecutionResult.class.getSimpleName(), result == null ? "null" : result.getClass().getSimpleName());
    WorkflowExecutionResult r = (WorkflowExecutionResult) result;
    try (WorkflowLock lock = lock()) {
        super.loadExecutionResult(result, exec, loadResult);
        Map<NodeID, NodeContainerExecutionResult> map = r.getExecutionResultMap();
        final int count = map.size();
        // contains the corrected NodeID in this workflow (the node ids in
        // the execution result refer to the base id of the remote workflow)
        Map<NodeID, NodeID> transMap = new HashMap<NodeID, NodeID>();
        NodeID otherIDPrefix = r.getBaseID();
        for (NodeID otherID : map.keySet()) {
            assert otherID.hasSamePrefix(otherIDPrefix);
            transMap.put(new NodeID(getID(), otherID.getIndex()), otherID);
        }
        for (NodeID id : m_workflow.createBreadthFirstSortedList(transMap.keySet(), true).keySet()) {
            NodeID otherID = transMap.get(id);
            NodeContainer nc = m_workflow.getNode(id);
            NodeContainerExecutionResult exResult = map.get(otherID);
            if (exResult == null) {
                loadResult.addError("No execution result for node " + nc.getNameWithID());
                continue;
            }
            exec.setMessage(nc.getNameWithID());
            ExecutionMonitor subExec = exec.createSubProgress(1.0 / count);
            // Propagagte the flow variables
            if (nc instanceof SingleNodeContainer) {
                NodeOutPort[] predecessorOutPorts = assemblePredecessorOutPorts(id);
                FlowObjectStack[] sos = Arrays.stream(predecessorOutPorts).map(p -> p != null ? p.getFlowObjectStack() : null).toArray(FlowObjectStack[]::new);
                createAndSetFlowObjectStackFor((SingleNodeContainer) nc, sos);
            }
            nc.loadExecutionResult(exResult, subExec, loadResult);
            subExec.setProgress(1.0);
        }
    }
}
Also used : Arrays(java.util.Arrays) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) EXECUTING(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTING) ReferencedFile(org.knime.core.internal.ReferencedFile) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) IWriteFileStoreHandler(org.knime.core.data.filestore.internal.IWriteFileStoreHandler) InteractiveNode(org.knime.core.node.interactive.InteractiveNode) CoreException(org.eclipse.core.runtime.CoreException) StringUtils(org.apache.commons.lang3.StringUtils) AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) NodeView(org.knime.core.node.NodeView) NodeContainerExecutionStatus(org.knime.core.node.workflow.execresult.NodeContainerExecutionStatus) Node(org.knime.core.node.Node) Vector(java.util.Vector) Matcher(java.util.regex.Matcher) WorkflowFileStoreHandlerRepository(org.knime.core.data.filestore.internal.WorkflowFileStoreHandlerRepository) Map(java.util.Map) FileStoreHandlerRepository(org.knime.core.data.filestore.internal.FileStoreHandlerRepository) LockFailedException(org.knime.core.util.LockFailedException) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) EXECUTINGREMOTELY(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTINGREMOTELY) Set(java.util.Set) ResolverUtil(org.knime.core.util.pathresolve.ResolverUtil) Executors(java.util.concurrent.Executors) POSTEXECUTE(org.knime.core.node.workflow.InternalNodeContainerState.POSTEXECUTE) InputNode(org.knime.core.node.dialog.InputNode) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Stream(java.util.stream.Stream) CONFIGURED(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) ThreadNodeExecutionJobManager(org.knime.core.node.exec.ThreadNodeExecutionJobManager) CollapseIntoMetaNodeResult(org.knime.core.node.workflow.action.CollapseIntoMetaNodeResult) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) VirtualParallelizedChunkPortObjectInNodeModel(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeModel) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) VMFileLocker(org.knime.core.util.VMFileLocker) RestoredFlowLoopContext(org.knime.core.node.workflow.FlowLoopContext.RestoredFlowLoopContext) SplitType(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings.SplitType) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) EXECUTED_QUEUED(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED_QUEUED) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) NotConfigurableException(org.knime.core.node.NotConfigurableException) UpdateStatus(org.knime.core.node.workflow.MetaNodeTemplateInformation.UpdateStatus) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult) DialogNode(org.knime.core.node.dialog.DialogNode) LinkedHashSet(java.util.LinkedHashSet) VirtualParallelizedChunkNodeInput(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkNodeInput) KNIMEConstants(org.knime.core.node.KNIMEConstants) LoadVersion(org.knime.core.node.workflow.FileWorkflowPersistor.LoadVersion) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode) Executor(java.util.concurrent.Executor) PREEXECUTE(org.knime.core.node.workflow.InternalNodeContainerState.PREEXECUTE) InteractiveView(org.knime.core.node.interactive.InteractiveView) FileOutputStream(java.io.FileOutputStream) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) File(java.io.File) ViewContent(org.knime.core.node.interactive.ViewContent) UNCONFIGURED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.UNCONFIGURED_MARKEDFOREXEC) OutputNode(org.knime.core.node.dialog.OutputNode) Platform(org.eclipse.core.runtime.Platform) LoopStatus(org.knime.core.node.workflow.NativeNodeContainer.LoopStatus) FileUtil(org.knime.core.util.FileUtil) CONFIGURED_QUEUED(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED_QUEUED) NodeType(org.knime.core.node.NodeFactory.NodeType) ExpandSubnodeResult(org.knime.core.node.workflow.action.ExpandSubnodeResult) ListIterator(java.util.ListIterator) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) URL(java.net.URL) Date(java.util.Date) URISyntaxException(java.net.URISyntaxException) WorkflowLoadResult(org.knime.core.node.workflow.WorkflowPersistor.WorkflowLoadResult) ReexecutionCallback(org.knime.core.node.interactive.ReexecutionCallback) MetaNodeLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.MetaNodeLinkUpdateResult) FileFilterUtils(org.apache.commons.io.filefilter.FileFilterUtils) NodeDialogPane(org.knime.core.node.NodeDialogPane) VirtualParallelizedChunkPortObjectInNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectInNodeFactory) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) AbstractNodeView(org.knime.core.node.AbstractNodeView) ConvenienceMethods(org.knime.core.node.util.ConvenienceMethods) URI(java.net.URI) ThreadFactory(java.util.concurrent.ThreadFactory) ContainerTable(org.knime.core.data.container.ContainerTable) MetaNodeToSubNodeResult(org.knime.core.node.workflow.action.MetaNodeToSubNodeResult) PortType(org.knime.core.node.port.PortType) NodeAndInports(org.knime.core.node.workflow.Workflow.NodeAndInports) CONFIGURED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC) Collection(java.util.Collection) CredentialsNode(org.knime.core.node.workflow.CredentialsStore.CredentialsNode) NodeModel(org.knime.core.node.NodeModel) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) BufferedDataTable(org.knime.core.node.BufferedDataTable) WorkflowPortTemplate(org.knime.core.node.workflow.WorkflowPersistor.WorkflowPortTemplate) LoadResultEntryType(org.knime.core.node.workflow.WorkflowPersistor.LoadResultEntry.LoadResultEntryType) NodeContainerTemplateLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.NodeContainerTemplateLinkUpdateResult) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) Entry(java.util.Map.Entry) Optional(java.util.Optional) CheckUtils(org.knime.core.node.util.CheckUtils) CheckUtils.checkState(org.knime.core.node.util.CheckUtils.checkState) PortObject(org.knime.core.node.port.PortObject) NodeContainerExecutionResult(org.knime.core.node.workflow.execresult.NodeContainerExecutionResult) IntStream(java.util.stream.IntStream) IOCase(org.apache.commons.io.IOCase) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) NodeExecutionJobManagerPool(org.knime.core.node.util.NodeExecutionJobManagerPool) SingleNodeContainerSettings(org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings) EXECUTED_MARKEDFOREXEC(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED_MARKEDFOREXEC) HashMap(java.util.HashMap) NodeSettings(org.knime.core.node.NodeSettings) ConnectionType(org.knime.core.node.workflow.ConnectionContainer.ConnectionType) Function(java.util.function.Function) Pair(org.knime.core.util.Pair) HashSet(java.util.HashSet) IDLE(org.knime.core.node.workflow.InternalNodeContainerState.IDLE) ExternalNodeData(org.knime.core.node.dialog.ExternalNodeData) ConnectionContainerTemplate(org.knime.core.node.workflow.WorkflowPersistor.ConnectionContainerTemplate) NodeLogger(org.knime.core.node.NodeLogger) NodeCreationContext(org.knime.core.node.NodeCreationContext) EXECUTED(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult) LinkedList(java.util.LinkedList) Role(org.knime.core.node.workflow.MetaNodeTemplateInformation.Role) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) SubNodeToMetaNodeResult(org.knime.core.node.workflow.action.SubNodeToMetaNodeResult) OutputStream(java.io.OutputStream) NodeFactory(org.knime.core.node.NodeFactory) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) TemplateType(org.knime.core.node.workflow.MetaNodeTemplateInformation.TemplateType) MetaPortInfo(org.knime.core.node.port.MetaPortInfo) VirtualParallelizedChunkPortObjectOutNodeFactory(org.knime.core.node.workflow.virtual.parchunk.VirtualParallelizedChunkPortObjectOutNodeFactory) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) ParallelizedChunkContent(org.knime.core.node.workflow.virtual.parchunk.ParallelizedChunkContent) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) Type(org.knime.core.node.workflow.NodeMessage.Type) TimeUnit(java.util.concurrent.TimeUnit) Condition(java.util.concurrent.locks.Condition) IEarlyStartup(org.knime.core.util.IEarlyStartup) ParallelizedChunkContentMaster(org.knime.core.node.workflow.virtual.parchunk.ParallelizedChunkContentMaster) IFileStoreHandler(org.knime.core.data.filestore.internal.IFileStoreHandler) NodeProperty(org.knime.core.node.workflow.NodePropertyChangedEvent.NodeProperty) Collections(java.util.Collections) NodeContainerExecutionResult(org.knime.core.node.workflow.execresult.NodeContainerExecutionResult) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) ExecutionMonitor(org.knime.core.node.ExecutionMonitor)

Example 2 with WorkflowExecutionResult

use of org.knime.core.node.workflow.execresult.WorkflowExecutionResult in project knime-core by knime.

the class SubNodeContainer method createExecutionResult.

/**
 * {@inheritDoc}
 * @since 2.12
 */
@Override
public SubnodeContainerExecutionResult createExecutionResult(final ExecutionMonitor exec) throws CanceledExecutionException {
    try (WorkflowLock lock = lock()) {
        SubnodeContainerExecutionResult result = new SubnodeContainerExecutionResult(getID());
        super.saveExecutionResult(result);
        WorkflowExecutionResult innerResult = m_wfm.createExecutionResult(exec);
        if (innerResult.needsResetAfterLoad()) {
            result.setNeedsResetAfterLoad();
        }
        // innerResult is success as soon as one of the nodes is a success - be more strict here
        result.setSuccess(innerResult.isSuccess() && getInternalState().equals(EXECUTED));
        result.setWorkflowExecutionResult(innerResult);
        return result;
    }
}
Also used : SubnodeContainerExecutionResult(org.knime.core.node.workflow.execresult.SubnodeContainerExecutionResult) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult)

Example 3 with WorkflowExecutionResult

use of org.knime.core.node.workflow.execresult.WorkflowExecutionResult in project knime-core by knime.

the class WorkflowManager method createExecutionResult.

/**
 * {@inheritDoc}
 */
@Override
public WorkflowExecutionResult createExecutionResult(final ExecutionMonitor exec) throws CanceledExecutionException {
    try (WorkflowLock lock = lock()) {
        WorkflowExecutionResult result = new WorkflowExecutionResult(getID());
        super.saveExecutionResult(result);
        Set<NodeID> bfsSortedSet = m_workflow.createBreadthFirstSortedList(m_workflow.getNodeIDs(), true).keySet();
        boolean success = false;
        for (NodeID id : bfsSortedSet) {
            NodeContainer nc = getNodeContainer(id);
            exec.setMessage(nc.getNameWithID());
            ExecutionMonitor subExec = exec.createSubProgress(1.0 / bfsSortedSet.size());
            NodeContainerExecutionResult subResult = nc.createExecutionResult(subExec);
            if (subResult.isSuccess()) {
                success = true;
            }
            result.addNodeExecutionResult(id, subResult);
        }
        // (important for no-child workflows)
        if (success) {
            result.setSuccess(true);
        }
        return result;
    }
}
Also used : NodeContainerExecutionResult(org.knime.core.node.workflow.execresult.NodeContainerExecutionResult) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult) ExecutionMonitor(org.knime.core.node.ExecutionMonitor)

Example 4 with WorkflowExecutionResult

use of org.knime.core.node.workflow.execresult.WorkflowExecutionResult in project knime-core by knime.

the class SubNodeContainer method loadExecutionResult.

/**
 * {@inheritDoc}
 */
@Override
public void loadExecutionResult(final NodeContainerExecutionResult result, final ExecutionMonitor exec, final LoadResult loadResult) {
    CheckUtils.checkArgument(result instanceof SubnodeContainerExecutionResult, "Argument must be instance of \"%s\": %s", SubnodeContainerExecutionResult.class.getSimpleName(), result == null ? "null" : result.getClass().getSimpleName());
    SubnodeContainerExecutionResult r = (SubnodeContainerExecutionResult) result;
    try (WorkflowLock lock = lock()) {
        super.loadExecutionResult(result, exec, loadResult);
        WorkflowExecutionResult innerExecResult = r.getWorkflowExecutionResult();
        runParentAction(() -> getWorkflowManager().loadExecutionResult(innerExecResult, exec, loadResult));
        // After loading the execution result of the workflow manager we need to set the real output of the subnode
        if (r.isSuccess()) {
            setVirtualOutputIntoOutport(EXECUTED);
        }
    }
}
Also used : SubnodeContainerExecutionResult(org.knime.core.node.workflow.execresult.SubnodeContainerExecutionResult) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult)

Example 5 with WorkflowExecutionResult

use of org.knime.core.node.workflow.execresult.WorkflowExecutionResult in project knime-core by knime.

the class SandboxedNodeCreator method copyExistingTablesIntoSandboxContainer.

/**
 * Copies the tables (port and internal) into the context of the corresponding node in the targetWFM. The execution
 * result must fit to the passed node container.
 *
 * @param execResult the object holding the result of the sourceNC. If the sourceNC is a workflow, this must hold
 *            all results of all contained nodes.
 * @param sourceNC the node that produced the execution result.
 * @param targetNC the context into which the tables are copied into
 * @param progressMon For progress information
 * @param copyDataIntoNewContext as per {@link #setCopyData(boolean)}
 * @throws CanceledExecutionException
 * @throws IOException
 */
public static void copyExistingTablesIntoSandboxContainer(final NodeContainerExecutionResult execResult, final NodeContainer sourceNC, final NodeContainer targetNC, final ExecutionMonitor progressMon, final boolean copyDataIntoNewContext) throws CanceledExecutionException, IOException {
    assert targetNC.getNrOutPorts() == sourceNC.getNrOutPorts();
    if (execResult instanceof NativeNodeContainerExecutionResult) {
        NativeNodeContainerExecutionResult sncResult = (NativeNodeContainerExecutionResult) execResult;
        // execResult and node types must match
        assert sourceNC instanceof NativeNodeContainer;
        assert targetNC instanceof NativeNodeContainer;
        // data is to copy ... get the correct execution context
        ExecutionContext targetExec = copyDataIntoNewContext ? ((SingleNodeContainer) targetNC).createExecutionContext() : null;
        NodeExecutionResult ner = sncResult.getNodeExecutionResult();
        // TODO this copy process has to take place in a different place
        // though it needs the final execution context for correct copy
        // of BDT objects
        PortObject[] resultTables = new PortObject[targetNC.getNrOutPorts()];
        int copyCount = resultTables.length;
        // copy also the internally held tables (such as for instance
        // the table in the table view) -- use the copy of the outports
        // if they match (likely they don't)
        PortObject[] oldInternTables = ner.getInternalHeldPortObjects();
        PortObject[] newInternTables = null;
        if (oldInternTables != null) {
            newInternTables = new PortObject[oldInternTables.length];
            copyCount += newInternTables.length;
        }
        // skip flow variable output
        for (int i = 0; i < resultTables.length; i++) {
            ExecutionMonitor sub = progressMon.createSubProgress(1.0 / copyCount);
            progressMon.setMessage("Port " + i);
            PortObject o = ner.getPortObject(i);
            PortObject newPO = copyPortObject(o, sub, targetExec);
            if (newInternTables != null) {
                for (int j = 0; j < oldInternTables.length; j++) {
                    if (oldInternTables[j] == o) {
                        newInternTables[j] = newPO;
                    }
                }
            }
            sub.setProgress(1.0);
            resultTables[i] = newPO;
        }
        if (newInternTables != null) {
            for (int i = 0; i < newInternTables.length; i++) {
                ExecutionMonitor sub = progressMon.createSubProgress(1.0 / copyCount);
                progressMon.setMessage("Internal Table " + i);
                if (newInternTables[i] == null) {
                    PortObject oldT = oldInternTables[i];
                    PortObject newT = copyPortObject(oldT, sub, targetExec);
                    newInternTables[i] = newT;
                }
                sub.setProgress(1.0);
            }
        }
        if (oldInternTables != null) {
            ner.setInternalHeldPortObjects(newInternTables);
        }
        ner.setPortObjects(resultTables);
    } else if (execResult instanceof WorkflowExecutionResult) {
        WorkflowExecutionResult wfmResult = (WorkflowExecutionResult) execResult;
        // exec result and node types must match
        WorkflowManager targetWFM = (WorkflowManager) targetNC;
        WorkflowManager sourceWFM = (WorkflowManager) sourceNC;
        copyIntoSandboxContainerRecursive(sourceWFM, targetWFM, wfmResult, progressMon, copyDataIntoNewContext);
    } else if (execResult instanceof SubnodeContainerExecutionResult) {
        SubnodeContainerExecutionResult subResult = (SubnodeContainerExecutionResult) execResult;
        WorkflowExecutionResult wfmResult = subResult.getWorkflowExecutionResult();
        WorkflowManager targetWFM = ((SubNodeContainer) targetNC).getWorkflowManager();
        WorkflowManager sourceWFM = ((SubNodeContainer) sourceNC).getWorkflowManager();
        copyIntoSandboxContainerRecursive(sourceWFM, targetWFM, wfmResult, progressMon, copyDataIntoNewContext);
    } else {
        throw new IllegalStateException("Unsupported node result type: " + execResult.getClass().getSimpleName());
    }
}
Also used : NodeExecutionResult(org.knime.core.node.workflow.execresult.NodeExecutionResult) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) ExecutionContext(org.knime.core.node.ExecutionContext) NativeNodeContainerExecutionResult(org.knime.core.node.workflow.execresult.NativeNodeContainerExecutionResult) SubnodeContainerExecutionResult(org.knime.core.node.workflow.execresult.SubnodeContainerExecutionResult) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) PortObject(org.knime.core.node.port.PortObject) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer)

Aggregations

WorkflowExecutionResult (org.knime.core.node.workflow.execresult.WorkflowExecutionResult)5 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)2 SubnodeContainerExecutionResult (org.knime.core.node.workflow.execresult.SubnodeContainerExecutionResult)2 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1