[IPython-dev] running tests using ipython parallel

Ondrej Certik ondrej@certik...
Tue Mar 17 03:36:30 CDT 2009


I am playing with ipython parallel and it behaves much more robustly
than the multiprocessing module from python2.6. In the multiprocessing
module if I get an exception, the process basically gets stuck, ctrl-c
doesn't help and I need to kill it using the "kill" command.

In ipython it works pretty well. I have couple questions though:

* which approach do you think would be the best to implement parallel
testing? Basically you have a test suite (nosetest and py.test
compatible) and currently in the sequential mode I just call
"execfile", get all functions from the file and execute them. In
parallel I do something along these lines:

        from IPython.kernel import client
        mec = client.MultiEngineClient()
        print "running %d jobs" % self._jobs
        ids = mec.get_ids()
        mec.execute("filename = '%s'" % filename)
        mec.execute("gl = {'__file__': filename}")
        mec.execute("execfile(filename, gl)")
        i = 0
        for f in funcs:
            if i >= len(ids): i = 0
            #mec.push({"f": f})
            #print mec.execute("gl['%s']" % f.__name__, targets=[ids[i]])
            print mec.execute("f", targets=[ids[i]])
            i += 1

funcs list contains all the test functions that I can then execute
using f(). Unfortunately this approach gives me an error at the line

  File "/home/ondrej/repos/sympy/sympy/utilities/runtests.py", line
214, in test_file
  File "/var/lib/python-support/python2.6/IPython/kernel/multiengineclient.py",
line 552, in push
    targets=targets, block=block)
  File "/var/lib/python-support/python2.6/IPython/kernel/multiengineclient.py",
line 441, in _blockFromThread
    result = blockingCallFromThread(function, *args, **kwargs)
  File "/var/lib/python-support/python2.6/IPython/kernel/twistedutil.py",
line 69, in blockingCallFromThread
    return twisted.internet.threads.blockingCallFromThread(reactor, f, *a, **kw)
  File "/usr/lib/python2.6/dist-packages/twisted/internet/threads.py",
line 114, in blockingCallFromThread
  File "/usr/lib/python2.6/dist-packages/twisted/python/failure.py",
line 326, in raiseException
    raise self.type, self.value, self.tb
TypeError: expected string or Unicode object, NoneType found

So I thought, ok, let's not push things in and execute everything at
the engines.

* what things could be safely pushed to engines? I know it can push
some functions, but I didn't manage to get it actually working for the
actual test functions (it works nice for simple functions from the
tutorial). So the only option that seems to me that it should work is
that I first implement a function that executes for "n"th test case
from the test suite and this function will not be transfered to
engines. The only thing that will be pushed is one string ("function
name") and then couple integers to specify all the parameters.


More information about the IPython-dev mailing list