Bulk upsert in gremlin_python fails with "TypeError: 'GraphTraversal' object is not callable"

Viewed 329

I am new to Gremlin and trying to perform bulk upsert in neptune db with gremlin_python.

I found this solution in google groups

l = [
  [name:'josh',age:29,country:'usa'],
  [name:'bar',age:24,country:'usa']];
 
g.inject(l).
 unfold().as('properties').
 select('name').as('pName').
 coalesce(V().has('name', where(eq('pName'))),
     addV('person')).as('vertex').
 sideEffect(select('properties').
              unfold().as('kv').
              select('vertex').
              property(select('kv').by(Column.keys), select('kv').by(Column.values)))

And tried to adapt it for gremlin_python like this:

l = [
  {'name':'josh','age':29,'country':'usa'},
  {'name':'bar','age':24,'country':'usa'}];
 
g.inject(l).\
 unfold().as_('properties').\
 select('name').as_('pName').\
 coalesce(__.V().has('name', __.where(__.eq('pName'))),
     addV('person')).as_('vertex').\
 sideEffect(select('properties').\
              unfold().as_('kv').\
              select('vertex').\
              property(select('kv').by(Column.keys), select('kv').by(Column.values)))

having following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-162-c262a63ad82e> in <module>
      8  unfold().as_('properties').\
      9  select('name').as_('pName').\
---> 10  coalesce(__.V().has('name', __.where(__.eq('pName'))),
     11      addV('person')).as_('vertex').\
     12  sideEffect(select('properties').\

TypeError: 'GraphTraversal' object is not callable

I assume the code adaptation might be wrong. Can anyone give me a hint about what is going on here?

1 Answers
Related