Search code examples
pythontitangremlingoblin

passing numbers into gremlin via goblin in python


I'd like to repeat a bit of a traversal in gremlin, like this:

g.V(1).repeat(out()).times(1)

using the goblin package for python, and the default titan11 install (which is, I think, titan+casssandra+gremlin+elasticsearch but, well, this stuff is confusing).

In python I write more or less the exact same thing as above, after doing some special imports:

from gremlin_python import statics
from gremlin_python.process.graph_traversal import __
statics.load_statics(globals())

# ... lots of other badass async python stuff and some networkx stuff etc

sg = g.V(seed_id).repeat(out()).times(1)

(see https://github.com/mikedewar/graphLearning/blob/master/conditional_traversal.py#L107 for all the other bits and bobs if you think it might help)

When I iterate over the sg traversal using goblin I get a Java error from, I think, gremlin:

goblin.exception.GremlinServerError: 597: No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.DefaultGraphTraversal.times() is applicable for argument types: (java.lang.Long) values: [1]
Possible solutions: toSet(), size(), min(), take(int), sleep(long), is(java.lang.Object)

So I think maybe it doesn't like the integer I pass to it.

Please help! I'd like to be able to repeat stuff in gremlin.


Solution

  • This is a bug in the old Groovy translator implementation that is provided with Goblin in order to provide backwards compatibility with GraphSON version 1. It was causing all integers to be serialized as longs. Because the times method signature expects an integer, this was resulting in an error. I fixed it with this commit. This fix will be included in the next release. For now, please install from Github:

    pip install git+https://github.com/ZEROFAIL/goblin.git
    

    I understand that you were unsure of the source of this problem, but maybe in the future a Github issue would be a better place to start.