dags#

_images/logo.svg

dags is a Python library for creating executable directed acyclic graphs (DAGs) from interdependent functions. It automatically determines the execution order based on function signatures and enables efficient composition of complex computational pipelines.

Key Features#

  • Automatic dependency resolution: Functions are ordered based on their parameter names matching other functions’ names

  • Function composition: Combine multiple functions into a single callable

  • Tree structures: Work with nested dictionaries using qualified names

  • Signature manipulation: Rename arguments and manage function signatures

Quick Example#

import dags

def a(x):
    return x ** 2

def b(a):
    return a + 1

def c(a, b):
    return a + b

# Combine functions into one
combined = dags.concatenate_functions(
    functions={"a": a, "b": b, "c": c},
    targets=["c"],
    return_type="dict",
)

result = combined(x=5)  # Returns {"c": 51}

The key is that you can build the combined function at runtime, which allows you to compose a computational pipeline in a way that you do not need to specify in advance, or in a multitude of ways. It has proven very helpful in a framework to solve life cycle models (pylcm) and to model the German taxes and transfers system (ttsim / gettsim).

Installation#

pip install dags

Or with conda:

conda install -c conda-forge dags

Table of Contents#