bosk.block.zoo.output_plugs#

Package Contents#

Classes#

BaseOutputBlock

Base output block. It is guaranteed that is has a single output and some name.

BlockExecutionProperties

Block execution properties.

BlockMeta

Block meta, containing input and output slots description.

DynamicBlockMetaStub

Meta stub for blocks with dynamic meta.

OutputBlock

Output block.

Functions#

make_simple_meta(input_names, output_names, ...)

Make simple block meta from input and output slot names.

Attributes#

BlockInputData

Block input values container data type.

TransformOutputData

Block transform output values container data type.

class bosk.block.zoo.output_plugs.BaseOutputBlock#

Bases: BaseBlock

Base output block. It is guaranteed that is has a single output and some name.

An output block can help to automatically determine pipeline outputs. The name can be None, in this case the block is not considered as one of pipeline outputs.

abstract property name: Optional[str]#

Get the input name.

Returns:

The block instance name or None if the block does not have name.

Return type:

Optional[str]

_make_slots()#

Make slots

get_single_output()#

Get the single block output slot.

Returns:

The block output slot.

Return type:

BlockOutputSlot

bosk.block.zoo.output_plugs.BlockInputData#

Block input values container data type.

It is indexed by input slot names.

bosk.block.zoo.output_plugs.TransformOutputData#

Block transform output values container data type.

It is indexed by output slot names.

class bosk.block.zoo.output_plugs.BlockExecutionProperties#

Block execution properties.

cpu :bool = True#

Has CPU implementation that handles CPU data.

gpu :bool = False#

Has GPU implementation that handles GPU data.

threadsafe :bool = False#

CPU/GPU implementation is thread safe, can be executed in parallel.

plain :bool = False#

Block implementation is straightforward and not computantionally expensive, it should not be parallelized (parallelization costs are larger than computation).

class bosk.block.zoo.output_plugs.BlockMeta(*, inputs=None, outputs=None, execution_props=None)#

Block meta, containing input and output slots description.

inputs :Mapping[str, InputSlotMeta]#

Mapping from input slots names to their meta.

outputs :Mapping[str, OutputSlotMeta]#

Mapping from output slots names to their meta.

execution_props :BlockExecutionProperties#

Block execution properties.

static list_of_slots_meta_to_mapping(slots_meta_list)#

Convert list of slots meta to mapping (name -> slot meta).

Parameters:

slots_meta_list (List[BaseSlotMeta]) – List of slots meta.

Returns:

Mapping dict (name -> slot meta).

Return type:

Mapping[str, BaseSlotMeta]

class bosk.block.zoo.output_plugs.DynamicBlockMetaStub(*, inputs=None, outputs=None, execution_props=None)#

Bases: BlockMeta

Meta stub for blocks with dynamic meta.

Usually blocks define static meta, but sometimes meta can be defined at block initialization time.

In this case, the stub can be used to express that the meta is dynamic.

bosk.block.zoo.output_plugs.make_simple_meta(input_names, output_names, **additional_params)#

Make simple block meta from input and output slot names.

Parameters:
  • input_names (List[str]) – List of input slot names.

  • output_names (List[str]) – List of output slot names.

  • **additional_params – Additional meta params.

Returns:

Block meta with given inputs and outputs.

Return type:

BlockMeta

class bosk.block.zoo.output_plugs.OutputBlock(name=None)#

Bases: bosk.block.base.BaseOutputBlock

Output block.

Bypasses its input. Can be used to mark outputs when building pipeline in functional style.

Dynamically specifies the meta information.

Parameters:

name (Optional[str]) – The output slot name. If None, the default name is used.

Input slots#

Fit inputs#

The fit step is bypassed.

Transform inputs#
  • name (default=”out”): Output data array.

Output slots#

  • name (default=”out”): Output data array.

DEFAULT_OUTPUT_NAME = out#
name#
meta :bosk.block.meta.BlockMeta#
fit(_inputs)#

The block bypasses the fit step.

Parameters:

_inputs (bosk.block.base.BlockInputData) –

Return type:

OutputBlock

transform(inputs)#

Transform the given input data, i.e. compute values for each output slot.

Parameters:

inputs (bosk.block.base.BlockInputData) – Block input data for the transforming stage.

Returns:

Outputs calculated for the given inputs.

Return type:

bosk.block.base.TransformOutputData