[IPython-user] Trivial parallelisation

Jose Gómez-Dans jgomezdans@gmail....
Tue Dec 2 12:28:24 CST 2008


Hi Brian, 


On Monday 01 December 2008 19:00:25 Brian Granger wrote:
> Yes, IPython will handle this beautifully.  Here is an example, with
> everything done interactively:

Many thanks for your mail. My code has a class that does a number of things. 
One of the class methods needs to be run in parallel (à la map()), but I have 
a problem:
<CrunchData is my instantiated class)
output = mec.map ( CrunchData.ProcessFile, CrunchData.files)
[...]
AssertionError: func must be a fuction or str

CrunchData.ProcessFile is defined as ( self, fname), so I'm doing something 
wrong here.

If I try execute, and a single file, no luck...
pr=mec.execute ('CrunchData.ProcessFile("%s")'%CrunchData.files[0])
pr.r
[...]
CompositeError: one or more exceptions from call to method: execute
[0:execute]: NameError: name 'CrunchData' is not defined
[1:execute]: NameError: name 'CrunchData' is not defined
[2:execute]: NameError: name 'CrunchData' is not defined
[3:execute]: NameError: name 'CrunchData' is not defined
[4:execute]: NameError: name 'CrunchData' is not defined
[5:execute]: NameError: name 'CrunchData' is not defined
[6:execute]: NameError: name 'CrunchData' is not defined
[7:execute]: NameError: name 'CrunchData' is not defined

I guess that the other avenue left is to use push_function() or similar, but 
can I do this with class methods?

Sorry, I think I'm a bit confused about it all!

Thanks!
Jose


More information about the IPython-user mailing list