Skip to main content

dpo-rewrite

Minimal DPO graph rewriting core for graph workflows and graph databases.

Scope

  • DPO rule representation (left, interface, right, optional nac)
  • JSON import and schema validation
  • Application to nx.MultiDiGraph
  • Cypher export for graph database execution

Install

Available on PyPI:

pip install dpo-rewrite

Usage

from dpo_rewrite import load_rule, to_cypher, validate

payload = {
    "left": {
        "nodes": [{"id": "a", "label": "Node", "props": {"id": "A"}}],
        "edges": [],
    },
    "interface": {
        "nodes": [{"id": "a", "label": "Node", "props": {"id": "A"}}],
        "edges": [],
    },
    "right": {
        "nodes": [
            {"id": "a", "label": "Node", "props": {"id": "A"}},
            {"id": "b", "label": "Node", "props": {"id": "B"}},
        ],
        "edges": [{"source": "a", "target": "b", "type": "LINKS_TO"}],
    },
}

validate(payload)
rule = load_rule(payload)
cypher = to_cypher(rule)
print(cypher.query)
print(cypher.params)

Sample Script

See examples/ for a minimal end-to-end examples.

Release files for dpo-rewrite 0.1.3

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

Source distribution (sdist)

Source distribution for dpo-rewrite 0.1.3
File Size Uploaded
dpo_rewrite-0.1.3.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dpo-rewrite 0.1.3
File Interpreter ABI Platform
dpo_rewrite-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 32.0 kB

Release files / dpo_rewrite-0.1.3.tar.gz

Download URL dpo_rewrite-0.1.3.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d468ffba643eed0c214c496e3e3b3f36653189b6a3b62e18cbb7e1115d2e5b77
BLAKE2b-256 checksum
How to use checksums
91324fd94bdcc7ec0c3e2595ca86cf9dd92e2f110844287a57d5d95328176f08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / dpo_rewrite-0.1.3-py3-none-any.whl

Download URL dpo_rewrite-0.1.3-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04a9da8f0df41d10bdbdac0a7ab0d4cfa27f75e3fd2f616440ae269a03765eb6
BLAKE2b-256 checksum
How to use checksums
32ebd0651dde924820f444aecf3686de877ceb4c3c42f6600d893e09eb48a822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

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