what can be serialised as a jug task?

22 views
Skip to first unread message

Bryan Lawrence

unread,
Mar 24, 2013, 1:21:36 PM3/24/13
to jug-...@googlegroups.com
Hi Luis

What limitations does jug have on what can be in a jug task?

I'm getting the impression (without looking at the code), but from a series of errors, that the functions which can be decorated with a taskgenerator can themselves not be very sophisticated? 

There appears to be at least two limitations I'm finding:  I can't pass in anything interesting in the arguments, and I can't use user defined classes within the function itself?

e.g, an example of the second would be  I can't do

class MyFileStuff:
   def __init__(self,filename):
      ''' Instantiate with file '''
  def method1(self):
      ''' Do method on file '''
  def method2(self):
     ''' Do something else'''

@TaskGenerator
def myfunction(f,arg):
   y=MyFileStuff(f)
   if arg==1: 
      return y.method1()
   elif arg==2:
     return y.method2()

Do I have that right?

An example of the first would be an attempt to pass MyFileStuff in as an argument to myfunction?

What exactly gets serialised into the backend for each individual jug task? 

(I can probably think of ways around this, but I need to think whether that's a smart move ... much of our diagnostic and plotting code is heavily o-o.)

Or maybe I'm just doing something else wrong, and misunderstanding the problem ... :- :-)

Thanks in advance,
Bryan


Luis Pedro Coelho

unread,
Mar 24, 2013, 2:12:54 PM3/24/13
to jug-...@googlegroups.com
Hi,

The major limitation is that arguments need to be pickle()able. So, user defined classes should be fine, except if they use C-defined extensions.

I was able to run your example without any problems.

Can you share any small example where you ran into problems?

Thanks,
--
Luis Pedro Coelho | University of Lisbon | http://luispedro.org
> --
> You received this message because you are subscribed to the Google Groups "jug-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jug-users+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Bryan Lawrence

unread,
Mar 24, 2013, 3:41:33 PM3/24/13
to jug-...@googlegroups.com
OK thanks.
Picklable should be fine. It's obviously something I'm doing. I'll get back to you.
Many thanks
Bryan

Bryan Lawrence

unread,
Mar 25, 2013, 9:06:14 AM3/25/13
to jug-...@googlegroups.com
Hi Luis

just to say that it was all my fault :-)

I failed to RTFM properly, and my problems were happening in serialisation in my code, because I was getting Task objects after a barrier ... having failed to get their value.  Seeing the serialisation errors with Task objects led me down the garden path of thinking it was happening in jug not in my code ... 

Dumb.

Onwards and forwards.

Cheers
Bryan
Reply all
Reply to author
Forward
0 new messages