IPython Documentation

Table Of Contents

Previous topic

Module: parallel.client.view

Next topic

Module: parallel.controller.dictdb

This Page

Module: parallel.controller.dependency

Dependency utilities

Authors:

  • Min RK

3 Classes

class IPython.parallel.controller.dependency.depend(f, *args, **kwargs)

Bases: object

Dependency decorator, for use with tasks.

@depend lets you define a function for engine dependencies just like you use apply for tasks.

Examples

@depend(df, a,b, c=5)
def f(m,n,p)

view.apply(f, 1,2,3)

will call df(a,b,c=5) on the engine, and if it returns False or raises an UnmetDependency error, then the task will not be run and another engine will be tried.

__init__(f, *args, **kwargs)
class IPython.parallel.controller.dependency.dependent(f, df, *dargs, **dkwargs)

Bases: object

A function that depends on another function. This is an object to prevent the closure used in traditional decorators, which are not picklable.

__init__(f, df, *dargs, **dkwargs)
class IPython.parallel.controller.dependency.Dependency(dependencies=[], all=True, success=True, failure=False)

Bases: set

An object for representing a set of msg_id dependencies.

Subclassed from set().

Parameters :

dependencies: list/set of msg_ids or AsyncResult objects or output of Dependency.as_dict() :

The msg_ids to depend on

all : bool [default True]

Whether the dependency should be considered met when all depending tasks have completed or only when any have been completed.

success : bool [default True]

Whether to consider successes as fulfilling dependencies.

failure : bool [default False]

Whether to consider failures as fulfilling dependencies.

If `all=success=True` and `failure=False`, then the task will fail with an ImpossibleDependency :

as soon as the first depended-upon task fails.

__init__(dependencies=[], all=True, success=True, failure=False)
as_dict()

Represent this dependency as a dict. For json compatibility.

check(completed, failed=None)

check whether our dependencies have been met.

unreachable(completed, failed=None)

return whether this dependency has become impossible.

1 Function

IPython.parallel.controller.dependency.require(*mods)

Simple decorator for requiring names to be importable.

Examples

In [1]: @require(‘numpy’)
...: def norm(a): ...: import numpy ...: return numpy.linalg.norm(a,2)