whatisgithub

What is twingraph?

parisi-labs/twingraph — explained in plain English

Analysis updated 2026-05-18

21PythonAudience · developerComplexity · 4/5Setup · moderate

In one sentence

A lightweight Python format for describing how real systems like power grids work, so software can check decisions against it without running anything itself.

Mindmap

A visual breakdown will appear here once this repo is fully enriched.

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Model a battery storage or power grid system as a typed, checkable document.

USE CASE 2

Validate that a proposed operational decision satisfies defined constraints before it runs.

USE CASE 3

Pass a stable, versioned description of a real system between different teams or tools.

USE CASE 4

Build a custom runtime that executes plans TwinGraph has already validated.

What is it built with?

Pythonpydantic

How does it compare?

parisi-labs/twingraph0whitedev/detranspiler2951461586/mulerun-pool
Stars212121
LanguagePythonPythonPython
Setup difficultymoderatehardmoderate
Complexity4/54/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Not yet on PyPI, so it must be installed directly from GitHub.

So what is it?

TwinGraph is a small Python package for describing how a real operating system works in a way that both people and software can inspect. Think of it as a shared blueprint format for things like power grids or battery storage systems: it records what equipment exists, how the pieces connect, what is being measured, what can be controlled, what data is available when a decision needs to be made, which prediction models are referenced, and what rules make a decision valid. It is important to understand what TwinGraph is not. It does not run simulations, optimize anything, store data long term, or provide a user interface. It only defines the structure of the information, called an intermediate representation. The package itself depends on almost nothing else, just Python's standard library plus a validation library called pydantic, which keeps it lightweight and easy to trust. A TwinGraph document is built from ten basic building blocks: entities (the objects involved), relations (how they connect), variables (things that change or are measured), data bindings (where live data comes from), model bindings (references to prediction or analysis models), actions (things that can be controlled), constraints, objectives, validators, and evidence. A function called compile_graph checks that all these pieces fit together correctly, catching problems like unknown types, broken references, or mismatched units, without actually running anything. If the document passes this check, TwinGraph produces a plan describing what should happen, but leaves the actual execution to whatever software the user builds separately. The project also ships some ready made vocabularies for common domains, covering things like batteries, solar and wind power, transformers, and data center equipment such as racks and cooling systems. This is aimed at developers building operational or industrial software who need a dependable, well defined format to pass information between real world sensors and decision making systems, rather than end users looking for a finished application.

Copy-paste prompts

Prompt 1
Show me how to define a TwinGraph document with entities, variables, and constraints for a simple battery system.
Prompt 2
Explain what compile_graph checks for and what diagnostic codes like TG_UNIT_MISMATCH mean.
Prompt 3
Help me register a custom model reference and IOContract for use with TwinGraph.
Prompt 4
Walk me through the public physical BESS example referenced in the twingraph README.

Frequently asked questions

What is twingraph?

A lightweight Python format for describing how real systems like power grids work, so software can check decisions against it without running anything itself.

What language is twingraph written in?

Mainly Python. The stack also includes Python, pydantic.

How hard is twingraph to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is twingraph for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.