PyMogwai
PyMogwai is a Python-based implementation of the Gremlin graph traversal language, designed to create and handle knowledge graphs entirely in Python without the need for an external Gremlin server.
Features
- Supports knowledge graph creation and manipulation
- Supports the import of arbitrary knowledge graphs with GraphML
- Implements a variety of traversal steps
- Enables one to traverse a graph with these steps
- Ability to integrate data from various sources like Excel, PDF and PowerPoint
- Simple and Pythonic API for graph operations
Demo
Getting started
Creating a Knowledge Graph
To create a graph using PyMogwai
from mogwai.core import MogwaiGraph
graph = MogwaiGraph()
# Add nodes and edges
n1 = graph.add_labeled_node("person", name="Alice", properties={"Age": 30})
n2 = graph.add_labeled_node("person", name="Bob", properties={"Age": 28})
graph.add_labeled_edge(n1, n2, "knows")
Import graphs
from mogwai.parser.graphml_converter import graphml_to_mogwaigraph
graph = graphml_to_mogwaigraph(path, node_label_key="node_label", node_name_key="node_name", edge_label_key="edge_label")
Performing Traversals
To perform any traversal of the graph, create a TraversalSource. Traversals start with a start step (V() or E()), which is followed by a sequence of steps. Note that a traversal can be executed by calling .run() on it.
from mogwai.core.traversal import MogwaiGraphTraversalSource
g = MogwaiGraphTraversalSource(graph)
# Example traversal that returns every person in the graph as a list
res = g.V().has_label("person").to_list().run()
print(res)
In order to use anonymous traversal in complex queries, import the statics module:
from mogwai.core.traversal import MogwaiGraphTraversalSource
from mogwai.core.steps.statics import *
g = MogwaiGraphTraversalSource(graph)
# Example traversal that returns every person in the graph as a list
query = g.V().has_label("person").filter_(properties('age').is_(gte(30))).to_list().by('name')
res = query.run()
print(res)
History
This project started as part of the RWTH Aachen i5 Knowledge Graph Lab SS2024 The original source is hosted at https://git.rwth-aachen.de/i5/teaching/kglab/ss2024/pymogwai 2024-08-15 the repository moved to github for better pypi integration
Metadata
Release files for pyMogwai 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pymogwai-0.1.1.tar.gz | 6.7 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pymogwai-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.7 MB
Release files / pymogwai-0.1.1.tar.gz
| Download URL | pymogwai-0.1.1.tar.gz |
|---|---|
| Size | 6.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a53d4e111e293ff481fc4f80e0a66365d0217b757bd53fbf0d2d7892aa342e6
|
|
BLAKE2b-256 checksum How to use checksums |
a4c39cdf6d370d5c6e7bff18e9c1aa2ba58adcac774cd32cc39e7679883995fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Jul 28, 2025.
Transparency logRelease files / pymogwai-0.1.1-py3-none-any.whl
| Download URL | pymogwai-0.1.1-py3-none-any.whl |
|---|---|
| Size | 1.0 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ab514bce96122d8a63c36fb18e61ec11991a0b7aa67940f8af7cf8fea11ebc9
|
|
BLAKE2b-256 checksum How to use checksums |
2eb3114d17fd7fca6598b845db70c9c562e373af94580c89812406acb64cfda1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Jul 28, 2025.
Transparency log