Iterating arrays and @keep=false

37 views
Skip to first unread message

Ville Rantanen

unread,
Aug 8, 2013, 9:15:06 AM8/8/13
to andur...@googlegroups.com
Hi, 

I've recently encountered a problem where user has been iterating over an Array, using @keep=false, and noticing that files are deleted too early, before the component consuming them is executed.  Here's the situation:

arr = ArrayProducingComponent(... , @keep=false)
inputs
={}
dataConsumer
={}
for el: std.iterArray(arr['arrayPort']) {
    inputs
[el.key] = INPUT(path=el.file)
    dataConsumer
[el.key] = SomeComponent( inputs[el.key] )
}

Now, the question is, why do the files in arr get deleted before SomeComponent is run?
  • Anduril does not see that there is a continuous line of data going through arr -> inputs -> dataConsumer, because INPUT components (despite the name) do NOT have input ports!   The flow of output-ports to input-ports is broken by carrying the file location information as a string parameter. If an output port is not connected to an input port, and @keep=false is issued, the files are deleted.
How to fix the script? Skip the INPUT phase! 

arr = ArrayProducingComponent(... , @keep=false)
dataConsumer
={}
for el: std.iterArray(arr['arrayPort']) {
    dataConsumer
[el.key] = SomeComponent( arr['arrayPort'][el.key] )
}

Now, the output and input ports are directly connected, and early deletions do not occur.


lauri...@gmail.com

unread,
Oct 2, 2013, 10:46:58 AM10/2/13
to andur...@googlegroups.com
In the iter branch there is an alternate syntax. It's probably going to incorporated into Anduril, once it has been tested.

The new syntax would be:


for el: std.iterArray(arr['arrayPort']) {

    dataConsumer
[el.key] = SomeComponent( el.port )
}

So, referring to the array itself wouldn't be necessary inside the loop at all. A similar syntax will likely work for iterating files in a directory.
Reply all
Reply to author
Forward
0 new messages