[kepler-users] 3 Qs re: PythonScript, tokenConsumptionRate, portparameters, and polymorphism

Tom Parris parris at isciences.com
Mon Nov 23 14:10:33 PST 2009


Dear Keplerites:

I have been making steady progress understanding how to write actors for
Kepler using the PythonScript actor.  However, I have hit a stumbling block
in my attempts to set input_tokenConsumptionRate.

To illustrate my problem, I have attached a simple workflow with an actor
titled "IntTokenSum" written with the PythonScript actor.  This actor is
designed to add some number of integer tokens from it's "input" port.  The
number of tokens is defined by the "windowsize" port.  The number of tokens
to consume with each "fire" is defined with the "blocksize" port.   The
current version works as desired with the exception of the blocksize input
prot (it always takes on the value of the windowsize input port).

Q1: As the script is currently configured, the windowsize parameter works as
advertised.  However, I can't seem to get the blocksize parameter to work.
 I've tried a number of approaches to setting the input_tokenConsumptionRate
per the java code for several actors (e.g., DownSample).  But now I'm
wondering if that is the correct approach.  Perhaps its the call to
self.input.get that needs to be changed.  Correct output on Display2 should
be the sequence: 1, 3, 5, 7, 9, 11, 13, 15, 17.

Q2: I'd also like to use an actor along these lines under the SDF director
with portparameters for windowsize and blocksize.  But can't figure out how
to to this with the PythonScript actor.  Is this possible?  If so, I would
welcome guidance.

Q3: Finally, it should be fairly easy to make this actor polymorphic.  I
think this can be done by changing the line:

   val = val + it.intValue()

to

   val = it.add(val)

But I am not sure how to initialize val to the additive identity
(generalized notion of zero).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20091123/be8b6932/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: windowv1.xml
Type: text/xml
Size: 35165 bytes
Desc: not available
URL: <http://lists.nceas.ucsb.edu/kepler/pipermail/kepler-users/attachments/20091123/be8b6932/attachment.xml>


More information about the Kepler-users mailing list