3

Trying out ipyparallel, and getting stuck on the very early step of pushing code to my engines. Started up my engines with:

ipcluster start -n 4

Then try out putting things on the engines with:

import ipyparallel as ipp
from scipy.interpolate import interp1d
import numpy as np

class supersimple:
    def __init__(self):
        self.dummy = 5
    def __call__(self, x):
        return self.dummy + x

def simplefunc(x):
    return x

if __name__ == '__main__':

    rc = ipp.Client()
    dview = rc[:]

    # Instatiate my class and put it on an engine
    myclass = supersimple()
    rc[0].push({'myclass': myclass})
    # Put my function on the engine
    rc[0].push({'simplefunc': simplefunc})

    # Put a scipy object on the engine
    x = np.arange(10)
    y = 3.+3.3*x
    otherobj = interp1d(x, y)
    rc[0].push({'otherobj': otherobj})

    # Check that everything is on the engine
    print(rc[0]['otherobj'])
    print(rc[0]['simplefunc'])
    print(rc[0]['myclass'])

results in:

<scipy.interpolate.interpolate.interp1d object at 0x117913b38>
<function simplefunc at 0x117923b70>

and

blah blah, boring traceback
ipyparallel.error.RemoteError: NameError(name 'myclass' is not defined)

so, two questions: 1) How do I get my class over to the engine?

(not as important, but I'm curious) 2) Why isn't there any error raised when I try to push things to an engine and it fails? Seems odd for code to just say shruggies when it fails to do something.

I.P. Freeley
  • 885
  • 1
  • 9
  • 19

0 Answers0