corelay.processor.base

Base classes Param and Processor.

Functions

ensure_processor

Make sure argument is a Processor and, if it is not, but callable, make it a FunctionProcessor.

Classes

FunctionProcessor

Processor instance initialized with a supplied function

Processor

Base class of processors of tasks in a pipeline instance.

class corelay.processor.base.FunctionProcessor(*args, **kwargs)[source]

Bases: Processor

Processor instance initialized with a supplied function

function

The function around which to create the FunctionProcessor. It wil be bound as a method if bind_method.

Type:

types.FunctionType or types.MethodType

bind_method

Will bind function to this class, enabling it to access self.

Type:

bool

class corelay.processor.base.Processor(*args, **kwargs)[source]

Bases: Plugboard

Base class of processors of tasks in a pipeline instance.

is_output

Assigned as Param, will be assigned as an instance attribute in __init__. Defines whether the Processor should yield an output for a Pipeline.

Type:

bool

is_checkpoint

Assigned as Param, will be assigned as an instance attribute in __init__. Defines whether checkpointed pipeline computations should start at this point, if there exists a previously computed checkpoint value.

Type:

bool

checkpoint_data

If this Processor is a checkpoint, and if the Processor was called at least once, stores the output of this processor.

Type:

object

copy()[source]

Copy self, creating a new Processor instance with the same values for Param attribute defined parameters.

Returns:

New instance with copied parameter values.

Return type:

Processor

abstract function(data)[source]

Abstract function this Processor should apply on input

Parameters:

data (object) – Input data to this Processor.

Raises:

NotImplementedError – Always, since this is an abstract function.

identifiers()[source]

Returns a dict containing the class qualifer name, as well all Parameters marked as identifiers with their values

Returns:

OrderedDict, containing the qualifier class name and all Parameters marked as identifiers with their values

Return type:

collections.OrderedDict

param_values()[source]

Get values for all parameters defined through Param attributes.

Returns:

Dict of the instance values of defined parameters.

Return type:

dict of object

corelay.processor.base.ensure_processor(proc, **kwargs)[source]

Make sure argument is a Processor and, if it is not, but callable, make it a FunctionProcessor. Set attributes of resulting processor as stated in **kwargs.

Parameters:
  • proc (Processor or callable) – Object to ensure to be a Processor.

  • **kwargs – Keyword arguments stating new default values for Parameters of proc.

Returns:

Original object proc with updated attributes if it was a Processor, else a FunctionProcessor with supplied function. proc and attributes as given in **kwargs.

Return type:

Processor