knime-ip / knip-scijava

KNIP - SciJava Commands Plugin
2 stars 3 forks source link

1-to-1 Command: Table input vs. Dialog input #27

Closed dietzc closed 8 years ago

dietzc commented 8 years ago

If we wrap a 1row-to-1row Command into a KNIME node, there are always two possible ways to resolve required input parameters. Example with String input parameter: we can get the String value from the input table (which is then potentially different for each row) or we can enter the value in a dialog component (which is then always the same for each row, given that this dialog component is not controlled by a flow-variable).

There are three situations:

If we wrap an arbitrary Command we have to define a strategy to resolve the conflict. Here is what I suggest: If both is possible (selection via table or via dialog) we only provide the possibility to enter the desired value via the dialog component as we can always use flow-variables to loop over the input table if desired and therefore simulate the column binding. This is the KNIME way to do it.

However, if someone writes a Command (for now called SciJavaNode), he should be able to control this behaviour in the code. One suggestion is, that he uses the extra @Attr annotation of the @Parameter of SciJava, to give a hint to the UI generation (simple flag with two states) Additionally, we have to add WidgetModels for the column selection itself.

imagejan commented 8 years ago

I have a question regarding the String use case above:

If both is possible (selection via table or via dialog) we only provide the possibility to enter the desired value via the dialog component as we can always use flow-variables to loop over the input table if desired and therefore simulate the column binding. This is the KNIME way to do it.

For example if you have a table with columns "Image_Title" and "Image", and you want to label each image (e.g. by adding a TextROI and draw the pixels or some such). For this you'd need to access both the String column and the Image column of the current row. Is the "KNIME way to do it" really to use yet another node to get the String flow variable?

dietzc commented 8 years ago

Ok, given we write a "pure" KNIME node with the purpose to process huge amounts of images + text, then the KNIME way to do it would be to collect the data from the table of course. However, if we auto-generate nodes from arbitrary Commands (which we didn't write on our own), we can't decide what to do. So the best we can do is to provide both options, again here are two possibilities:

However, with the @Attr we want to provide the flexibility for the developer to decide on his own, if she already knows that she wants to expose her Command as a KNIME node.

Does this make sense?

imagejan commented 8 years ago

Does this make sense?

Alright, yes, that makes sense. Thanks for the clarification!

gab1one commented 8 years ago

So we either have:

I think option B is easier to get done correctly.

dietzc commented 8 years ago

Option B is the correct one. @Attr allows to toggle or enforce a certain behaviour.

gab1one commented 8 years ago

This would like the following:

@Parameter(attrs={@Attr(name = "useKNIMEColumnSelection", value = "true")})
private int someValueFromColumn;

Needs a better name though.