2

Using python gremlin on Neptune workbench, I have two functions:

The first adds a Vertex with a set of properties, and returns a reference to the traversal operation

The second adds to that traversal operation.

For some reason, the first function's operations are getting persisted to the DB, but the second operations do not. Why is this?

Here are the two functions:


def add_v(v_type, name):
    tmp_id = get_id(f"{v_type}-{name}")
    result = g.addV(v_type).property('id', tmp_id).property('name', name)
    result.iterate()
    return result

def process_records(features):
    for i in features:
        v_type = i[0]
        name = i[1]
        v = add_v(v_type, name)

        if len(i) > 2:
            %debug
            props = i[2]
            for r in props:
                v.property(r[0], r[1]).iterate()

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
lostinplace
  • 1,538
  • 3
  • 14
  • 38

1 Answers1

2

Your add_V method has already iterated the traversal. If you want to return the traversal from add_v in a way that you can add to it remove the iterate.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
  • The concept I was missing was this: The result of `addV` is a "traversal operation" not a vertex. Once you've executed a traversal operation (by iterating) it's useless – lostinplace May 29 '20 at 15:00