Message and progress usage

15 views
Skip to first unread message

Juju

unread,
Nov 23, 2011, 6:41:18 AM11/23/11
to PyF Framework Users
Dear listI followed the excellent tube design tutorial but
I can't figure out how to use message and progress callbacks
for instance in the tube tutorial
in the code producer
how could I display a message between each User yield
or have the progress bar progressing :) ?

another question :
Is there a way to stop a tube execution ?
Either brute force or with resuming option ...

Regards

Mathieu Bridon

unread,
Nov 23, 2011, 9:36:54 PM11/23/11
to pyf-...@googlegroups.com
On Wed, 2011-11-23 at 03:41 -0800, Juju wrote:
> Dear listI followed the excellent tube design tutorial but
> I can't figure out how to use message and progress callbacks
> for instance in the tube tutorial
> in the code producer
> how could I display a message between each User yield
> or have the progress bar progressing :) ?

The documentation should probably be made clearer about that, but it
does say:
----------
2. Once launched, you are on the event track page with progression
and messages.
* To add messages there, you can call message_callback in your nodes
* To update progression, use progression_callback in the producer.
----------

That means you have access to two functions in code components:
message_callback and progression_callback (they are automatically
available in the local scope of your code component).

For example, you can do the following (off the top of my head, might not
be perfect) :

----------
items = session.query(MyModel)
total = items.count()

for index, item in enumerate(items):
progression_callback((index+1)/total)
yield item
----------

You might want to update the progression every X items (with X > 1) to
avoid impacting too much the performance of the tube. ;)

The progression_callback and message_callback functions are documented
here:
http://pyfproject.org/documentation/contents/modules/componentized/base_components/#base-code-component


--
Mathieu


Juju

unread,
Nov 24, 2011, 3:28:31 AM11/24/11
to PyF Framework Users
Ok, I thought progress_callback and message_callback where place
holders for custom callbacks or something like that.

Its clear and simple :) I like it.

Regards

> here:http://pyfproject.org/documentation/contents/modules/componentized/ba...
>
> --
> Mathieu

Reply all
Reply to author
Forward
0 new messages