Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Views created with c.direct_view() fail #986

Closed
takluyver opened this Issue · 3 comments

2 participants

@takluyver
Owner

Going through a basic example from the docs, I ran into this failure. It looks like view.targets is 'all', when it should be a collection of IDs. Creating the equivalent view with c[:] works.

In [3]: v = c.direct_view()

In [4]: v
Out[4]: <DirectView all>

In [5]: v.map_sync(lambda x: x**10, range(32))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/home/thomas/Code/virtualenvs/ipy-trunk/<ipython-input-5-b937e0334e06> in <module>()
----> 1 v.map_sync(lambda x: x**10, range(32))

/home/thomas/Code/virtualenvs/ipy-trunk/local/lib/python2.7/site-packages/IPython/parallel/client/view.pyc in map_sync(self, f, *sequences, **kwargs)
    340             raise TypeError("map_sync doesn't take a `block` keyword argument.")
    341         kwargs['block'] = True
--> 342         return self.map(f,*sequences,**kwargs)
    343 
    344     def imap(self, f, *sequences, **kwargs):

/home/thomas/Code/virtualenvs/ipy-trunk/<string> in map(self, f, *sequences, **kwargs)

/home/thomas/Code/virtualenvs/ipy-trunk/local/lib/python2.7/site-packages/IPython/parallel/client/view.pyc in spin_after(f, self, *args, **kwargs)
     66 def spin_after(f, self, *args, **kwargs):
     67     """call spin after the method."""
---> 68     ret = f(self, *args, **kwargs)
     69     self.spin()
     70     return ret

/home/thomas/Code/virtualenvs/ipy-trunk/local/lib/python2.7/site-packages/IPython/parallel/client/view.pyc in map(self, f, *sequences, **kwargs)
    575         assert len(sequences) > 0, "must have some sequences to map onto!"
    576         pf = ParallelFunction(self, f, block=block, **kwargs)
--> 577         return pf.map(*sequences)
    578 
    579     def execute(self, code, targets=None, block=None):

/home/thomas/Code/virtualenvs/ipy-trunk/local/lib/python2.7/site-packages/IPython/parallel/client/remotefunction.pyc in map(self, *sequences)
    212         self._map = True
    213         try:
--> 214             ret = self.__call__(*sequences)
    215         finally:
    216             del self._map

/home/thomas/Code/virtualenvs/ipy-trunk/local/lib/python2.7/site-packages/IPython/parallel/client/remotefunction.pyc in __call__(self, *sequences)
    185                 f=self.func
    186 
--> 187             view = self.view if balanced else client[t]
    188             with view.temp_flags(block=False, **self.flags):
    189                 ar = view.apply(f, *args)

/home/thomas/Code/virtualenvs/ipy-trunk/local/lib/python2.7/site-packages/IPython/parallel/client/client.pyc in __getitem__(self, key)
    763         Must be int, slice, or list/tuple/xrange of ints"""
    764         if not isinstance(key, (int, slice, tuple, list, xrange)):
--> 765             raise TypeError("key by int/slice/iterable of ints only, not %s"%(type(key)))
    766         else:
    767             return self.direct_view(key)

TypeError: key by int/slice/iterable of ints only, not <type 'str'>
@minrk
Owner

'all' is actually correct, because it is meant to be lazily evaluated (rc.direct_view('all') != rc[:]), but the remotefunction code doesn't handle that properly. Fix is easy and forthcoming.

Thanks!

@minrk
Owner

Where is the example that doesn't work? I can't find one that would do this.

@minrk minrk was assigned
@takluyver
Owner

Sorry, I should have been clearer - the example itself uses c[:], but I had deviated slightly from it. I was going from this: http://ipython.org/ipython-doc/stable/parallel/parallel_multiengine.html#parallel-map

@minrk minrk closed this issue from a commit
@minrk minrk handle targets='all' in remotefunction
* add explanation of lazy evaluation of 'all' to direct_view docstring
* previously failing test included

closes gh-986
55d81f8
@minrk minrk closed this in 55d81f8
@ellisonbg ellisonbg referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@mattvonrocketstein mattvonrocketstein referenced this issue from a commit in mattvonrocketstein/ipython
@minrk minrk handle targets='all' in remotefunction
* add explanation of lazy evaluation of 'all' to direct_view docstring
* previously failing test included

closes gh-986
b826ade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.