lostinplace
lostinplace

Reputation: 1518

Vertex in Python Gremlin not updating

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()

Upvotes: 1

Views: 153

Answers (1)

Kelvin Lawrence
Kelvin Lawrence

Reputation: 14371

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.

Upvotes: 1

Related Questions