Module: parallel.controller.dependency — IPython 2.3.1 documentation

### Navigation

- index
- modules |
- modules |
- next |
- home|
- search|
- documentation »
- The IPython API »

# Module: `parallel.controller.dependency`

Dependency utilities

Authors:

- Min RK

## 3 Classes

class `IPython.parallel.controller.dependency.` `depend`(_wrapped_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__`(_wrapped_f, *args, **kwargs)

class `IPython.parallel.controller.dependency.` `dependent`(_wrapped_f, _wrapped_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__`(_wrapped_f, _wrapped_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`(*objects, **mapping)

  Simple decorator for requiring local objects and modules to be available when the decorated function is called on the engine.

  Modules specified by name or passed directly will be imported prior to calling the decorated function.

  Objects other than modules will be pushed as a part of the task. Functions can be passed positionally, and will be pushed to the engine with their __name__. Other objects can be passed by keyword arg.

  Examples:

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

      In [2]: foo = lambda x: x*x
      In [3]: @require(foo)
         ...: def bar(a):
         ...:     return foo(1-a)

### Navigation

- index
- modules |
- modules |
- next |
- home|
- search|
- documentation »
- The IPython API »