bosk.pipeline.converter#

Pipeline converters.

Can be used to convert pipeline to different graphs in formats of third-party libraries.

The pipeline conversion is based on visitors: pipelines and blocks can accept them.

Submodules#

Package Contents#

Classes#

DaskConverter

Converts a pipeline to a Dask computational graph.

NetworkXConverter

class bosk.pipeline.converter.DaskConverter(stage, operator_set=TransformDaskOperatorSet())#

Converts a pipeline to a Dask computational graph.

Since Dask does not support multi-output blocks by default, we split each block into multiple nodes:

  • Node that computes the block;

  • A number of nodes that extract data corresponding to outputs.

Parameters:
class Visitor(parent)#

Bases: bosk.visitor.base.BaseVisitor

Base Visitor interface.

Visitor can be used to process any entity of a computational pipeline, such as: block, connection, or even the whole pipeline.

It is important to implement dispatching for all entity types or to make some default method which will not raise NotImplementedError for unknown entity types.

Parameters:

parent (DaskConverter) –

visit(obj)#
_(block)#

Enumerate blocks.

Parameters:

pipeline (bosk.pipeline.base.BasePipeline) –

_(connection)#
Parameters:

pipeline (bosk.pipeline.base.BasePipeline) –

_(pipeline)#
Parameters:

pipeline (bosk.pipeline.base.BasePipeline) –

_mangle_block(block)#
Parameters:

block (bosk.block.base.BaseBlock) –

Return type:

str

_mangle_output_slot(output_slot)#
Return type:

str

_mangle_input_slot(input_slot)#
Return type:

str

__call__(pipeline)#
Parameters:

pipeline (bosk.pipeline.base.BasePipeline) –

Return type:

Mapping[str, Any]

class bosk.pipeline.converter.NetworkXConverter#
class Visitor(graph)#

Bases: bosk.visitor.base.BaseVisitor

Base Visitor interface.

Visitor can be used to process any entity of a computational pipeline, such as: block, connection, or even the whole pipeline.

It is important to implement dispatching for all entity types or to make some default method which will not raise NotImplementedError for unknown entity types.

Parameters:

graph (networkx.Graph) –

visit(obj)#
_(block)#
Parameters:

connection (bosk.pipeline.connection.Connection) –

_(connection)#
Parameters:

connection (bosk.pipeline.connection.Connection) –

__call__(pipeline)#
Parameters:

pipeline (bosk.pipeline.base.BasePipeline) –

Return type:

networkx.Graph