Schedula

1.6.15 · active · verified Thu Apr 16

Schedula is a dynamic flow-based programming environment for Python that automatically handles the control flow of programs. It produces a plan that dispatches calls based on a graph of functions, satisfying data dependencies. The library helps to define and execute dataflow execution models, extract sub-models, and can be used to deploy web API services. It is currently at version 1.6.15 and is actively maintained with regular updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define a simple dataflow model using `schedula.Dispatcher`, add functions with data dependencies using the `@sh.add_function` decorator, and then execute the workflow by calling `dispatch` with initial inputs and desired outputs. Schedula automatically determines the execution order based on data dependencies.

import schedula as sh

# 1. Define a Dispatcher, which is the main model for your dataflow
dsp = sh.Dispatcher(name='my_simple_workflow')

# 2. Define functions and add them to the Dispatcher using the decorator
@sh.add_function(dsp, outputs=['y'])
def add_one(x):
    print(f"Executing add_one with x={x}")
    return x + 1

@sh.add_function(dsp, outputs=['z'])
def multiply_by_two(y):
    print(f"Executing multiply_by_two with y={y}")
    return y * 2

# 3. Dispatch the workflow with initial inputs and desired outputs
initial_inputs = {'x': 5}
desired_outputs = ['z']

try:
    results = dsp.dispatch(inputs=initial_inputs, outputs=desired_outputs)
    print(f"\nFinal result for 'z': {results['z']}")
except Exception as e:
    print(f"An error occurred during dispatch: {e}")

view raw JSON →