Warning
This documentation is for an old version of IPython. You can find docs for newer versions here.
Views of remote engines.
Authors:
Bases: IPython.utils.traitlets.HasTraits
Base View class for more convenint apply(f,*args,**kwargs) syntax via attributes.
Don’t use this class, use subclasses.
Methods: | spin :
wait :
execution methods :
data movement :
query methods :
control methods :
|
---|
Abort jobs on my engines.
Parameters: | jobs : None, str, list of strs, optional
|
---|
calls f(*args, **kwargs) on remote engines, returning the result.
This method sets all apply flags via this View’s attributes.
calls f(*args, **kwargs) on remote engines in a nonblocking manner.
returns AsyncResult
return one or more results, specified by history index or msg_id.
See client.get_result for details.
Parallel version of itertools.imap.
See self.map for details.
override in subclasses
Parallel version of builtin map, using this view’s engines.
This is equivalent to map(...block=False)
See self.map for details.
Parallel version of builtin map, using this view’s engines.
This is equivalent to map(...block=True)
See self.map for details.
Decorator for making a ParallelFunction
Instruct the controller to forget specific results.
Fetch the Queue status of my engines
Decorator for making a RemoteFunction
set my attribute flags by keyword.
Views determine behavior with a few attributes (block, track, etc.). These attributes can be set all at once by name with this method.
Parameters: | block : bool
track : bool
|
---|
Terminates one or more engine processes, optionally including the hub.
spin the client, and sync
temporarily set flags, for use in with statements.
See set_flags for permanent setting of flags
Examples
>>> view.track=False
...
>>> with view.temp_flags(track=True):
... ar = view.apply(dostuff, my_big_array)
... ar.tracker.wait() # wait for send to finish
>>> view.track
False
waits on one or more jobs, for up to timeout seconds.
Parameters: | jobs : int, str, or list of ints and/or strs, or one or more AsyncResult objects
timeout : float
|
---|---|
Returns: | True : when all msg_ids are done False : timeout reached, some msg_ids still outstanding |
Bases: IPython.parallel.client.view.View
Direct Multiplexer View of one or more engines.
These are created via indexed access to a client:
>>> dv_1 = client[1]
>>> dv_all = client[:]
>>> dv_even = client[::2]
>>> dv_some = client[1:3]
This object provides dictionary access to engine namespaces:
# push a=5: >>> dv[‘a’] = 5 # pull ‘foo’: >>> db[‘foo’]
Activate IPython magics associated with this View
Defines the magics %px, %autopx, %pxresult, %%px, %pxconfig
Parameters: | suffix: str [default: ‘’] :
|
---|
Clear the remote namespaces on my engines.
Executes code on targets in blocking or nonblocking manner.
execute is always bound (affects engine namespace)
Parameters: | code : str
block : bool
|
---|
Gather a partitioned sequence on a set of engines as a single local seq.
get object(s) by key_s from remote namespace
see pull for details.
sync_imports(local=True) as a property.
See sync_imports for details.
view.map(f, *sequences, block=self.block) => list|AsyncMapResult
Parallel version of builtin map, using this View’s targets.
There will be one task per target, so work will be chunked if the sequences are longer than targets.
Results can be iterated as they are ready, but will become available in chunks.
Parameters: | f : callable
*sequences: one or more sequences of matching length :
block : bool
|
---|---|
Returns: | if block=False: :
else: :
|
get object(s) by name from remote namespace
will return one object if it is a key. can also take a list of keys, in which case it will return a list of objects.
update remote namespace with dict ns
Parameters: | ns : dict
block : bool [default
|
---|
Execute contents of filename on my engine(s).
This simply reads the contents of the file and calls execute.
Parameters: | filename : str
targets : int/str/list of ints/strs
block : bool
|
---|
Partition a Python sequence and send the partitions to a set of engines.
Context Manager for performing simultaneous local and remote imports.
‘import x as y’ will not work. The ‘as y’ part will simply be ignored.
If local=True, then the package will also be imported locally.
If quiet=True, no output will be produced when attempting remote imports.
Note that remote-only (local=False) imports have not been implemented.
>>> with view.sync_imports():
... from numpy import recarray
importing recarray from numpy on engine(s)
update remote namespace with dict ns
See push for details.
Bases: IPython.parallel.client.view.View
An load-balancing View that only executes via the Task scheduler.
Load-balanced views can be created with the client’s view method:
>>> v = client.load_balanced_view()
or targets can be specified, to restrict the potential destinations:
>>> v = client.client.load_balanced_view([1,3])
which would restrict loadbalancing to between engines 1 and 3.
view.map(f, *sequences, block=self.block, chunksize=1, ordered=True) => list|AsyncMapResult
Parallel version of builtin map, load-balanced by this View.
block, and chunksize can be specified by keyword only.
Each chunksize elements will be a separate task, and will be load-balanced. This lets individual elements be available for iteration as soon as they arrive.
Parameters: | f : callable
*sequences: one or more sequences of matching length :
block : bool [default self.block]
track : bool
chunksize : int [default 1]
ordered : bool [default True]
|
---|---|
Returns: | if block=False: :
|
set my attribute flags by keyword.
A View is a wrapper for the Client’s apply method, but with attributes that specify keyword arguments, those attributes can be set by keyword argument with this method.
Parameters: | block : bool
track : bool
after : Dependency or collection of msg_ids
follow : Dependency or collection of msg_ids
timeout : float/int or None
retries : int
|
---|
Keep our history and outstanding attributes up to date after a method call.
sync relevant results from self.client to our results attribute.
call spin after the method.