Pass a variable to Python script node

I am trying to use Parameter Optimization Loop Start to make variables and pass to Python Script Node for some calculation. However in Python Script Node, I can’t see the variable created by Parameter Optimization Loop Start.

It seems Parameter Optimization Loop Start can create and pass variables to next node but Python Script Node cannot receive variables from any node.

I also try some other nodes between Parameter Optimization Loop Start and Python Script Node, such as Python Edit Variable node, Merge Variables node, and even Variable to Table Row node and then Table Row to Variable node, none of them can pass the variable to Python Script Node.

I have another node input data frame to Python Script node so I can only use Flow Variable Port for the variables.

It should be possible to send Flow Variables to and from Python script nodes:

3 Likes

I can do it at Python Source node but doesn’t work at Python Script node, any idea?

Screenshot 2021-04-21 234541 Screenshot 2021-04-21 234516

Seems it is a looping issue. I am trying to loop different group of data by different parameters, python script doesn’t accept like this. Any idea?

Screenshot 2021-04-22 at 12.01.31 PM

Hello @anguslou,

your design is not right. You can not have same node connected to two loop start nodes. (You should get warning in Console about this saying that loops/scopes not properly nested.) So in original issue if your Python Script is already in a loop wrapping it up around Parameter Optimization Loop will not work and you won’t be able to see flow variables from it. Solution is to nest one loop within other meaning in your case to to connect one of preceding nodes to Parameter Optimization Loop Start using flow variable connection.

Br,
Ivan

3 Likes

Why do you want to use a Parameteroptimization loop when you use a python script anyway?
br

1 Like

Now I fix it by revising the Python code. But somehow I may have some cases need to optimise parameters in another loop so better think for a solution.

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