Python Script Node - Rename Input and Outputs

HI :wave: Is there a way to rename input_table and input_object in python script node?

I don’t think this is possible. You could later rename the object in the Python script if you absolutely must.

2 Likes

Yes I must, when I have multiple inputs and outputs it starts to get really messy and when I change input order it gets even worse.

Is there any place where I can put my suggestion about python node? I think it would be a simple improvement with a high impact.

Thank you @mlauber71 :slight_smile:

1 Like

Hi @VincentV7 , as @mlauber71 said, I don’t think direct renaming of the ports themselves is possible, but there are a couple of workarounds that may be of use to you.

Firstly, from the point of view of writing your code, you can of course create dataframes within your python script so that the only place you need to reference the ports by their physical name is at the start and end of your script. That at least means that if you subsequently change the ordering of the ports, you only change your script in one place.

So if I have a (very) basic python script with 3 input and 3 output ports. My input ports receive tables of Fruits, Vegetables and Drinks. I sort each by name and then deliver them to output ports in a different order, I could do this:

If I subsequently wish to change the order of the ports, I would only change the assignments.

That of course doesn’t help with a different issue which is how to determine in the workflow what the different ports are for, without opening the python script up to remind you. One possible workaround (with a little effort, but it could be worthwhile) is to then wrap you python script as if it were a component. (i.e. make it a component within the workflow consisting of just this one node)

image

You can then of course tie up the ports to the outside world in whichever order you wish (and change them later if need be) without affecting the internal processing of the script.

This also gives you the ability to document the names of the ports (by editing the component documentation)

and this means that if you then hover over the ports of the component in the workflow, you can see which port is which:

image
image
and additionally you can see the different output ports when you right click

Attached is an example workflow. I know it’s not quite what you are after, but hopefully it is helpful.

Named python ports.knwf (14.7 KB)

5 Likes

@takbb Thank you! Amazing answer :muscle:

2 Likes