Python/Neptune/Gremlin: "'list' object has no attribute 'next'"

249 views Asked by At

I trying to mirror the following gremlin code in Python to do pagination.

gremlin> t = g.V().hasLabel('person');[]
gremlin> t.next(2)
==>v[1]
==>v[2]
gremlin> t.next(2)
==>v[4]
==>v[6]

Here are the Python code

    from neptune_python_utils.gremlin_utils import GremlinUtils
    from neptune_python_utils.endpoints import Endpoints

    GremlinUtils.init_statics(globals())

    endpoints = '...'
    gremlin_utils = GremlinUtils(endpoints)

    conn = gremlin_utils.remote_connection()
    g = gremlin_utils.traversal_source(connection=conn)

    t = g.V().hasLabel('my-label')

    cnt, ipp = True, 100
    while cnt:
        r = t.next(ipp)
        if not r: 
            cnt = False

But I'm getting error

  "errorMessage": "'list' object has no attribute 'next'",
  "errorType": "AttributeError"
  on line ---> r = t.next(ipp)

The trace show that the first iteration for r = t.next(ipp) actually ran, but it returned a list object, so there is no .next() anymore. How can I keep the traversal in the iterations?

0

There are 0 answers