knime-mpicbg / knime-scripting

knime-scripting includes scripting extensions for KNIME to integrate R, Matlab, Python and Groovy scripts. These extensions include a collection of nodes to develop and deploy templates in the respective languages.
https://github.com/knime-mpicbg/knime-scripting/wiki
Other
44 stars 25 forks source link

Matlab Snippet: Output argument not assigned during call to ... #95

Closed stelfrich closed 6 years ago

stelfrich commented 6 years ago

I am trying to execute MatlabSnippetError.knwf.zip with MATLAB R2018a and KNIME 3.5.3 and get the following error in the KNIME log:

2018-06-29 11:59:20,407 : DEBUG : KNIME-Worker-5 : Node : Matlab Snippet : 4:5 : Execute failed: MATLAB:Containers:Map:EmptyValues, When keys are specified, values must also be specified. Check your MATLAB code!
java.lang.RuntimeException: MATLAB:Containers:Map:EmptyValues, When keys are specified, values must also be specified. Check your MATLAB code!
    at de.mpicbg.knime.scripting.matlab.ctrl.MatlabCode.checkForScriptErrors(MatlabCode.java:157)
    at de.mpicbg.knime.scripting.matlab.snippet.MatlabSnippetNodeModel.executeImpl(MatlabSnippetNodeModel.java:80)
    at de.mpicbg.knime.scripting.core.AbstractScriptingNodeModel.execute(AbstractScriptingNodeModel.java:174)
    at org.knime.core.node.NodeModel.executeModel(NodeModel.java:567)
    at org.knime.core.node.Node.invokeFullyNodeModelExecute(Node.java:1172)
    at org.knime.core.node.Node.execute(Node.java:959)
    at org.knime.core.node.workflow.NativeNodeContainer.performExecuteNode(NativeNodeContainer.java:561)
    at org.knime.core.node.exec.LocalNodeExecutionJob.mainExecute(LocalNodeExecutionJob.java:95)
    at org.knime.core.node.workflow.NodeExecutionJob.internalRun(NodeExecutionJob.java:179)
    at org.knime.core.node.workflow.NodeExecutionJob.run(NodeExecutionJob.java:110)
    at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:328)
    at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:204)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
    at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)

mOut is available in the MATLAB workspace and filled with the correct content.

imagejan commented 6 years ago

How many rows are in your mOut? I remember similar errors when I tried the MATLAB Snippet node, and I had to provide at least two rows in the output to get it work.

fmeyenhofer commented 6 years ago

Hey @stelfrich a workaround is to append the following line to the end of you snippet: mOut.Properties.VarDescription = {'Septal.length', 'Septal.width', 'Petal.length', 'Petal.width'};

I know, this is not very transparent at the moment, but you can use the VarDescription property of dataset and table matlab objects to carry the column names of the output table. This is because dataset does not allow white spaces and a couple of other characters.

I am now working on the matlab code that transfers the data to the matlab workspace to make the default behaviour a bit more consistent and add a bit of explanation to the default snippet.

fmeyenhofer commented 6 years ago

cd39a4639be14e53b366cb454897c91a961846b2

stelfrich commented 6 years ago

I know, this is not very transparent at the moment, but you can use the VarDescription property of dataset and table matlab objects to carry the column names of the output table. This is because dataset does not allow white spaces and a couple of other characters.

Is it documented somewhere and was I just too stupid to find it? I guess it would make sense to add documentation about that possibility to the node description, even with the fix available.

Thanks for your efforts on this (and I mean knime-scripting in general not just this fix), @Meyenhofer! 👍

fmeyenhofer commented 6 years ago

You can find information about the dataset/table properties in the node description (see screenshot). Now with the more consistent behauviour concerning column naming from the matlab output I hope that this will not make anymore trouble.

screen shot 2018-07-06 at 12 21 12