Decorators

action

action(*args, **kwargs)[source]

Decorator for action methods in Batch classes

Parameters
  • use_lock (bool or str) – whether to lock an action when a pipeline is executed. It can be bool or a lock name. A pipeline variable with a lock is created in the pipeline during the execution.

  • no_eval (str or a sequence of str) – parameters to skip from named expression evaluation. A parameter should be passed as a named argument only.

Examples

@action
def some_action(self, arg1, arg2):
    ...

@action(no_eval='dst')
def calc_offset(self, src, dst=None):
    ...

@action(use_lock=True)
def critical_section(self, some_arg, another_arg):
    ...

@action(use_lock='lock_name')
def another_critical_section(self, some_arg, another_arg):
    ...

inbatch_parallel

parallel

apply_parallel

apply_parallel(*args, **kwargs)[source]

Mark class method for transform in its metaclass.

Decorator writes kwargs to the method attribute apply_kwargs, so they can be extracted and used in metaclass.

Parameters
  • args – other parameters passed to apply_parallel method of the class where this decorator is being used

  • kwargs – other parameters passed to apply_parallel method of the class where this decorator is being used

Notes

Redefine the attribute apply_defaults <.Batch.apply_defaults> in the batch class. This is proposed solely for the purposes of brevity — in order to avoid repeated heavily loaded class methods decoration, e.g. @apply_parallel(src=’images’, target=’for’) which in most cases is actually equivalent to simple @apply_parallel assuming that the defaults are redefined for the class whose methods are being transformed.

Note, that if no defaults redefined those from the nearest parent class will be used in MethodsTransformingMeta.

any_action_failed

any_action_failed(results)[source]

Return True if some parallelized invocations threw exceptions

mjit

mjit(*args, nopython=True, nogil=True, **kwargs)[source]

jit decorator for methods

Notes

This decorator should be applied directly to a method, not another decorator.

deprecated

deprecated(msg)[source]

Decorator for deprecated functions and methods