Access variables at input port inside metanode

I wrapped all the logic (which makes sense to be wrapped) into a metanode. Now I have a variable coming through one input port (a marshalled table of exchange rates as described in here) which I would like to access before any other node does something with the data. This is, because the first operation would be to use the values from the variable to alter the data. The challenge I am facing is, that I don’t see a way to access the variable belonging to an input data flow right at the input port within a metanode.

I know that I could create an additional input port for a “Flowvariable” and connect the flow variable output of the preceding node to it. This does not make sense in my case because the preceding node is also a metanode and would also need an additional output port for a flow variable, which clutters the overall visual representation in an unnecessary way. Also, I don’t want to see this operation on a higher level.

The only solution I see so far is to use some sort of “Noop” node such as “GroupBy” leaving the column selection empty and then aggregating one column using the “first” aggregation method, which should result in a single operation for the whole table, independent of the number of rows in the table. Then I could use the variable output of this node to access the desired variable.
I guess you clearly see how this is not optimal in many ways…

Any suggestions? Will this be a feature request to have the option to tap into the variables of an input port?

Hi @dobo -

After reading the description of your workflow a couple of times, I’m not entirely sure what you are wanting to do. But I have a few thoughts anyway :slight_smile:

  1. Flow variables can be passed along data branches - it isn’t strictly required for you to use a separate red flow variable branch, depending on what you’re trying to do. So maybe that can help clear up some of the clutter.
  2. It sounds like maybe you are using components (or as they were known prior to KNIME 4.0, wrapped metanodes)? If that’s the case, it’s important to understand that flow variables have a local scope - you can’t pass them into and out of components unless you are explicit about it.

At any rate, it would helpful to see a simple workflow that demonstrates what you’re trying to do with a toy example. Then we can help make the appropriate adjustments. Is there a small workflow you can post that would clarify?

Hi @ScottF,
when you read it yourself it sounds crystal clear :stuck_out_tongue: but yeah I know it’s always more clear with a picture. It needs some effort to create a minimal feasible example, but I hope my issue gets clear through the three images below. I am using KNIME 4.0 and metanodes (not components, nor wrapped metanodes) exactly for the reason you mention: passing variables along the flow.

  1. Crisp Overview of the workflow, describing it on a high level without clutter:
    image
    Here I first create a variable (marshalled exchange rate table) which is injected into the data flow of the primary material data, hence being available throughout the whole workflow.

  2. Attach Suppliers (Metanode):
    image
    Inside this node I add new data which first needs to be translated into EUR using the table stored in the variable created at the beginning of the workflow.

Now, the issue I am having is, that I can’t tap into the variables right at the input port inside the “Attach Supplier” metanode. Before I have access to the variables, I need to do something (like no-op) with the data, so that I can tap into the variable port of the no-op node in order to extract the value of the variable:


So my question is whether there is something as a flow variable port at the input port inside a metanode (like I am accessing the variable through the no-op)?

Another possibility, as you mentioned, would be to pass the variable flow also into this node through an input port. But this would add too much clutter to my crips overview (which is way more complex than what’s shown here).

OK, that helps clarify things. Thanks for posting the images.

There are three things that you might try, in increasing order of complexity. I don’t know if all of them will work in your case, but it may give you something to think about at least.

  1. The simplest route is, as you’ve already identified, to create a new flow variable input port into your metanode, and connect that to your Variable to Table Row node. Pro: super easy. Con: visual clutter.

  2. Use global workflow variables. You can set these initially, and call them from any point in the workflow. Pro: cleaner presentation. Con: They’re initially static, which may not work for your use case.

  1. Use Call Local Workflow nodes, where you pass a set of variables into a separate workflow as JSON data (see this workflow for an example). Pro: very flexible. Con: probably much more complicated than what you want or need.
2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.