Views created with c.direct_view() fail #986

Closed
takluyver opened this Issue Nov 9, 2011 · 3 comments

Comments

Projects
None yet
2 participants
@takluyver
Member

takluyver commented Nov 9, 2011

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

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Nov 9, 2011

Member

'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!

Member

minrk commented Nov 9, 2011

'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

This comment has been minimized.

Show comment
Hide comment
@minrk

minrk Nov 9, 2011

Member

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

Member

minrk commented Nov 9, 2011

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

@ghost ghost assigned minrk Nov 9, 2011

@takluyver

This comment has been minimized.

Show comment
Hide comment
@takluyver

takluyver Nov 9, 2011

Member

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

Member

takluyver commented Nov 9, 2011

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 in 55d81f8 Nov 10, 2011

mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014

handle targets='all' in remotefunction
* add explanation of lazy evaluation of 'all' to direct_view docstring
* previously failing test included

closes gh-986
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment