juupje / 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.
Apache License 2.0
2 stars 0 forks source link

missing steps #23

Open WolfgangFahl opened 1 week ago

WolfgangFahl commented 1 week ago

implement the following steps:

the live demo notebook and a commented out test also show an issue with

AttributeError: 'Traversal' object has no attribute 'has_property'

juupje commented 5 days ago

Working on this in the steps branch.

juupje commented 5 days ago

The issue with has_property stems from an outdated query. As the properties key in the NetworkX dictionary is no more, you should now use the has step instead (which is how it is done in Gremlin). The query

g.V()
    .has_label("airport")
    .has("city", "Maastricht")
    .as_("start")
    .repeat(
        outE("route")
        .as_("e")
        .inV()
        .filter_(select("e").values("dist").is_(lte(2000)))
        .simple_path()
    )
    .times(3)
    .emit()
    .as_("dest")
    .path()
    .as_("p")
    .count(Scope.local)
    .order(Order.asc)
    .as_("length")
    .dedup()
    .select("dest", "length")
    .to_list()
    .by("city")

should now work