Skip to main content

DPO graph rewriting core for graph databases.

Project description

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
  • Cypher export for graph database execution

Install

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/simple_rule.py for a minimal end-to-end example.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dpo_rewrite-0.1.2.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dpo_rewrite-0.1.2-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file dpo_rewrite-0.1.2.tar.gz.

File metadata

  • Download URL: dpo_rewrite-0.1.2.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for dpo_rewrite-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0fee722b459a90a4e23f87ebdbd11418d0e3103e5d6007ffeb2c7727df8cdb85
MD5 74e3aca1e93570ca251148a7e54e045b
BLAKE2b-256 2528afdef59174a8566caed055fe6f949845fe4f8ed42ea4b232bff8080e9d7c

See more details on using hashes here.

File details

Details for the file dpo_rewrite-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dpo_rewrite-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for dpo_rewrite-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0b510d987064385fac0f2d29953379781dd89794c5a05a053949fda5b876d9cb
MD5 ec8d606e763f9574be9dabaed0a62311
BLAKE2b-256 89f56975e80a55ccfd13105f1afbd4dee2cd1ef313fcffafe813b15a9aedec03

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page