Difference between revisions of "Automatic loops"
Line 25: | Line 25: | ||
=== Implementation === | === Implementation === | ||
The branch automatic-loops contains a working version using a ListOf module type. | The branch automatic-loops contains a working version using a ListOf module type. | ||
Using a ListOf module as an input will cause the inputs to be looped over and the results returned as new ListOf modules. This means the downstream will be iterated automatically until a ListOf input port is used. | |||
The ListOf type system is very basic and could be improved. | |||
Cartesian product should be implemented by making it selectable on the module. | |||
=== References === | === References === | ||
How Taverna does it: | How Taverna does it: | ||
http://dev.mygrid.org.uk/wiki/display/taverna/Loops | http://dev.mygrid.org.uk/wiki/display/taverna/Loops |
Revision as of 13:37, 21 January 2014
This page discusses the possibility or getting rid of the awkward controlflow-style looping. We could allow modules to automatically loop if a module's port gets a list of values (or multiple connections).
typed lists?
- list shouldn't be a type like any other
- allow connection List<T> -> T
- allow connection T -> List<T> (make a one-element list, or actual list if the module loops)
- RR proposes: don't duplicate modules to loop, just make update() call compute() several times
- probably needs the dont-use-modules-as-data work -- modules that return themselves are going to break
- add logic in vistrails_module:Module:
if inputport T and input list<T>, call compute several times and build list of outputs
- coupling problem
def test_module(a:T, b:T) -> (c:T, d:T):
- c = a*b
- d = a+b
- test_module([1, 2], [3, 4])
- is it c = [3, 8], d = [4, 6]? (pairwise)
- is it c = [3, 4, 6, 8], d = [4, 5, 5, 6]? (cartesian)
- can probably be settable in module conf (and default to pairwise)
Implementation
The branch automatic-loops contains a working version using a ListOf module type. Using a ListOf module as an input will cause the inputs to be looped over and the results returned as new ListOf modules. This means the downstream will be iterated automatically until a ListOf input port is used.
The ListOf type system is very basic and could be improved.
Cartesian product should be implemented by making it selectable on the module.
References
How Taverna does it: http://dev.mygrid.org.uk/wiki/display/taverna/Loops