Unable to use next() in gremlin-python
Hi, has anyone tried to use gremlin-python with janusgraph 1.0.0? It seems that there is a bug that makes next() unusable.
Here is an example of how to reproduce the issue:
This generates a
KeyError
:
Using g.addV('vertex').property('name', 'v1').iterate()
instead of next()
works fine.
Any thoughts?Solution:Jump to solution
This is my config https://github.com/Citegraph/citegraph/blob/main/backend/src/main/resources/gremlin-server-cql.yaml. I just tested python driver and java driver and they both worked well.
10 Replies
Also,
g.V().count().next()
works, but g.V().next()
yields the same KeyError
Try using GraphSONMessageSerializerV3 in your server config, e.g.
{ className: org.apache.tinkerpop.gremlin.util.ser.GraphSONMessageSerializerV3, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
Thanks for the suggestion. Unfortunately, after setting the serializer to
GraphSONMessageSerializerV3
I get the following error 😦
Did you include
config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }
?
If you are still facing the error, could you please share your server config yaml file?Hi, yes, here is the yaml file is attached.
And here is the error:
BTW: When I enable the
GraphSONMessageSerializerV3
serializer in the yaml config file, I also get the same error from a Java app that connects to JanusGraph (my Java app works fine with the default serializer):
Solution
This is my config https://github.com/Citegraph/citegraph/blob/main/backend/src/main/resources/gremlin-server-cql.yaml. I just tested python driver and java driver and they both worked well.
In your java driver case, when you built
Make sure it includes the serializer that your server is using. In the above example, it would only work if your server enables GraphBinaryMessageSerializerV1
Thank you for the examples, they are very useful!
I used your .yaml file, and now gremlin-python works. Earlier, I forgot to specify the serializer. I added the following and now it works OK:
I'll try your solution for the Java code as well. Thanks!
Update: the Java solution also worked, thank you very much!
Interesting though, coz I didn't have to specify the message serializer when using python. I thought the python driver would somehow figure it out by itself.
My 2🪙: I think it just defaults to GraphSONMessageSerializer here: https://github.com/apache/tinkerpop/blob/master/gremlin-python/src/main/python/gremlin_python/driver/driver_remote_connection.py#L65-L68