Skip to content

ComputeEngine API Reference

The ComputeEngine class is designed to process and execute computational flows defined by a set of blocks and flow schemas.

Class barfi.flow.ComputeEngine

Parameters

  • blocks (Union[List[Block], Dict[str, List[Block]]]): A collection of Block instances representing the components available for computation. Can be provided as:
    • A list of Block instances
    • A dictionary where keys are category names and values are lists of Block instances

Example

from barfi.flow import Block, ComputeEngine
 
block1 = Block(name="block1")
block2 = Block(name="block2")
blocks = [block1, block2]
 
engine = ComputeEngine(blocks)

Methods

execute(schema: FlowSchema) -> None

Executes a flow schema using the registered blocks.

Parameters

  • schema (FlowSchema): The flow schema to execute, containing block configurations and connections.

Raises

  • ValueError: If the schema contains invalid block references or connections.

Example

flow_schema = FlowSchema(...)
engine.execute(schema=flow_schema)