A simple library for dataflow programming in python. It allows you to organize your computation as a directed acyclic graph.
For a more detailed explanation, refer to the documentation. Here's what you need to know to get started quickly.
Install grapes from conda-forge or PyPI with
conda install conda-forge::grapesor
pip install grapesDefine a graph by adding steps and binding functions to them:
import grapes as gr
g = gr.Graph()
gr.add_step(g, "b", "compute_b", "a")
gr.add_step(g, "c", "compute_c", "b")
gr.update_internal_context(g,
{
"compute_b": lambda a: 2*a,
"compute_c": lambda b: b+1
}
)
gr.finalize_definition(g)Execute the graph to find your target, starting from your input context.
context = {"a": 3}
target = "c"
result = gr.execute_graph_from_context(g, context, target)
print(result["c"]) # 7The bulk of grapes development was done by Giulio Foletto in his spare time.
See LICENSE.txt and NOTICE.txt for details on how grapes is distributed.
grapes is inspired by pythonflow but with substantial modifications.
It relies internally on networkx for graph management and on pygraphviz for graph visualization.
Most of the development of grapes was done before AI coding tools were available.
However, recent edits (September 2025) were assisted by GitHub Copilot, especially for writing docstrings.