Skip to main content

desflow

Realistic event streams from a simulation you can steer while it runs.

CI Pipeline Documentation PyPI version Python Versions License: MIT

desflow simulates a system over time and writes each step as an event. It is a Python library and a command. One run can write its events to several destinations at once: Kafka, Redis, PostgreSQL, Parquet or JSONL files on local disk or in cloud storage, and Iceberg tables. You can change the simulation while it runs, such as how often work arrives or how many workers or machines handle it, and the events change with it.

desflow runs a discrete-event simulation (DES) on SimPy: the model moves from one event, such as an order arriving or a packer finishing, to the next. In a shop, orders queue for the packers, waits grow at busy times, and a backlog builds when orders arrive faster than they can be packed. Each change in the data therefore has a cause in the model, as in a real system, which rows drawn at random do not have.

desflow architecture

How desflow Works explains each part of this diagram. Why desflow tells how the project started.

What It Is For

  • Simulation studies. A question such as how many packers a shop needs is answered from many runs of a model, not from one. desflow repeats the runs, gives each result with its margin of error and compares designs of the shop. Before a long run, desflow explain names the busiest resource from the model alone.
  • Data engineering. Batch and streaming pipelines need test data that behaves like a real system. One run can write a week of history at full speed, then keep streaming in real time. In the Kafka Digital Twin example, a dashboard changes an arrival rate or a capacity during a run, and the data follows without a restart.
  • Machine learning and MLOps. A model that predicts delays needs training data in which queues build and clear for a reason. A change made during a run shifts the data at a known time, which is what a drift monitor has to catch.
  • AI. Scoring an anomaly detector or an AI agent needs a known answer. A run can plant a fault, such as a label printer going offline, and record what it planted in separate label records. An AI coding assistant can write and check models with the desflow skill.
Live parameter updates from the control dashboard

Features

Group What it covers
Ways to write a model a YAML blueprint, a Python script with the builder API, or SimPy code with the low-level API, which build the same model
Model parts arrivals, tasks in a flow with routing and priorities, resources with queues, preemption and breakdowns, stores and containers
Time a run in real time or at full speed, history written fast and then carried on live, and a run that ends at a time or an event
Live changes arrival rates, service times and capacities changed by name during a run, from a scenario, a local schedule, a file you edit, Kafka, Redis or PostgreSQL
Records events, telemetry with the statistics, and label records of each planned change, as JSON, Avro, JSON Schema, Protobuf or Pydantic
Connectors several sinks in one run: Kafka, Redis, PostgreSQL, Parquet or JSONL files on local disk or cloud storage, and Iceberg tables
Studies statistics with a warm-up, replications with a 95% interval, experiments that compare designs, and distributions fitted to measured times
Tools the desflow command, and a JSON Schema that gives an editor completion for blueprints
Integrations a study run as a task of Airflow, Dagster, Prefect or Kestra, and a later task that reads the figures from the file the run writes
AI Assistants a plugin for Claude Code, Codex or Antigravity with the desflow skill and the desflow mcp server

Installation

Install the core library with uv or pip.

With uv:

# desflow command
uv tool install desflow

# Or the library, in a uv project
uv add desflow

With pip:

pip install desflow

Connectors and input fitting are optional extras. For example, uv add "desflow[kafka,parquet]" or pip install "desflow[kafka,parquet]", and uv tool install "desflow[kafka,parquet]" for the desflow command:

Extra Adds
kafka Kafka ingress and egress
confluent Avro, JSON Schema and Protobuf with the Confluent Schema Registry (includes kafka)
glue Avro, JSON Schema and Protobuf with the AWS Glue Schema Registry (includes kafka)
redis Redis ingress and egress
postgres PostgreSQL ingress and egress
parquet Parquet and JSONL files on local disk, S3-compatible storage, Google Cloud Storage or Azure Blob Storage
iceberg Apache Iceberg tables through a REST catalog, a SQL catalog on SQLite or PostgreSQL, or the Glue catalog
fit scipy and matplotlib, for input fitting with desflow fit
fake Faker, for the fake generator of realistic names, addresses and dates
watch watchfiles, for desflow run --watch, which runs the file again each time it changes
mcp the MCP Python SDK, for desflow mcp, which serves the desflow commands as tools to an AI assistant
all Every extra above

Installation gives the cautions of the fake extra, and Upgrading to 1.0 moves code from dynamic-des, the earlier name of desflow.

Quick Start

This blueprint models the shop: one packer, an order about every 2 seconds and 1.5 seconds of packing, with every record printed to the terminal:

# First Simulation tutorial: the shop as a blueprint.
# Run it with: desflow run first_shop.yaml
simulation:
  sim_id: Shop
  factor: 1.0  # 1 simulated second takes 1 real second
  random_seed: 42  # the same arrival times on every run

resources:
  packers: {current_cap: 1, max_cap: 1}

services:
  # Every order takes exactly 1.5 seconds to pack
  packing: {dist: constant, value: 1.5}

arrivals:
  # One order every 2 seconds on average; each arrival spawns pack_order
  orders: {dist: exponential, rate: 0.5, spawn: pack_order}

tasks:
  pack_order:
    service: packing
    resource: packers
    # The value of the finished event
    payload: {event_type: order_packed}

egress:
  - {type: Console}

run: {until: 20}

tests:
  # Run with: desflow test first_shop.yaml
  - name: seven_orders_in_20_seconds
    expect: {tasks.pack_order.finished: 7}

Save it as first_shop.yaml and run desflow run first_shop.yaml. First Simulation builds it step by step.

Each runnable example is a complete model. The local example needs no container:

desflow examples get local --api yaml
cd local/yaml
desflow run local.yaml

--api builder or --api low-level downloads the other two versions, and each example page says which odctl service it needs.

Commands

The desflow command runs a blueprint, and checks, compares and fits models, with no Python code. Command Line uses every command on one shop.

Integrations

An orchestrator runs a study as one task of a pipeline, and a later task reads the figures from the file that desflow run --summary writes:

  • Airflow: a DAG with a BashOperator that runs the study.
  • Dagster: an asset that runs the study and keeps the figures as metadata.
  • Prefect: a flow with a task that runs the study.
  • Kestra: a flow whose Python task runs the study in a container.

AI Assistants

The desflow plugin gives Claude Code, Codex or Antigravity the desflow skill and the desflow commands as MCP tools. Install desflow with the mcp extra, uv tool install "desflow[mcp]>=1.1", then the plugin:

claude plugin marketplace add jaehyeon-kim/desflow && claude plugin install desflow@desflow   # Claude Code
codex plugin marketplace add jaehyeon-kim/desflow && codex plugin add desflow@desflow         # Codex
agy plugin install https://github.com/jaehyeon-kim/desflow                                    # Antigravity

Plugin checks the install and copies the skill for another assistant. desflow mcp serves the tools to any MCP client, as MCP Server shows.

Projects Using desflow

Six public projects generate their data with desflow: four data engineering and MLOps demos in benchtop, the Agentic Analytics System and a hot strip mill digital twin. Projects Using desflow says what desflow simulates in each.

Learn More

  • The documentation covers every part of desflow.
  • Learn teaches discrete-event simulation from the start, then builds one shop through a whole study.
  • The roadmap page shows what each release adds and what comes next.
  • Blog posts about desflow are tagged desflow on jaehyeon.me.

Contributing

CONTRIBUTING.md explains how to set up the repository, run the tests, add a connector or a distribution, and write the docs.

License

MIT

Metadata

Release files for desflow 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for desflow 1.1.0
File Size Uploaded Provenance Actions
desflow-1.1.0.tar.gz 654.4 kB With provenance Details for desflow-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for desflow 1.1.0
File Interpreter ABI Platform Actions
desflow-1.1.0-py3-none-any.whl Python 3 none any Details for desflow-1.1.0-py3-none-any.whl

Total release size: 1.4 MB

Release files / desflow-1.1.0.tar.gz

Download URL desflow-1.1.0.tar.gz
Size 654.4 kB
Tags Source
SHA-256 checksum
How to use checksums
329b6dec3e652ecba6eff35e5a89d4b71e528804b3636f69b18a0bb751168b26
BLAKE2b-256 checksum
How to use checksums
278c5c89f55fb98d1ff7442c3c1c0c41b40b00c1ed40c2ceee127b748d9bf77b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / desflow-1.1.0-py3-none-any.whl

Download URL desflow-1.1.0-py3-none-any.whl
Size 710.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c36cc071343c012edafc9b59c49f29437d121fb154d0dc3e5b4b8d91e9b33a6d
BLAKE2b-256 checksum
How to use checksums
c10fb4c87e33ab38c46c0bdb9f486e248a2a6742adbd7bf915c8898a6dcf499c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for desflow 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for desflow-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page