[ 
https://issues.apache.org/jira/browse/TINKERPOP-3169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18004293#comment-18004293
 ] 

Andrea C commented on TINKERPOP-3169:
-------------------------------------

Hi [~publicjirauser] can you give more information about the stopIteration 
error you are seeing?

I was able to use the [python driver example for modern 
traversals|https://github.com/apache/tinkerpop/blob/3.7-dev/gremlin-python/src/main/python/examples/modern_traversals.py]
 to dynamically add vertex properties similarly to what you have described in 
your code using a local gremlin-server loaded with the sample modern graph.

My code:

 
{code:java}
import sys

sys.path.append("..")

from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.driver.driver_remote_connection import 
DriverRemoteConnection


def main():
    rc = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g')
    g = traversal().with_remote(rc)

    props = dict(name="Test", age=25, city="Test City")

    # print original graph data
    print(str(g.V().propertyMap().to_list()))
    
    # add a person with dynamic properties from a map
    t = g.add_v("person")
    for prop, value in props.items():
        t = t.property(prop, value)
    
    # execute the traversal and print the result
    t = t.propertyMap().next()
    print(str(t))
    
    # print the modified graph data
    print(str(g.V().propertyMap().to_list()))
    rc.close()


if __name__ == "__main__":
    main()
{code}
 

 

My output:

 
{code:java}
[{'city': [vp[city->Test City]], 'name': [vp[name->Test]], 'age': 
[vp[age->25]]}, {'name': [vp[name->marko]], 'age': [vp[age->29]]}, {'name': 
[vp[name->vadas]], 'age': [vp[age->27]]}, {'name': [vp[name->lop]], 'lang': 
[vp[lang->java]]}, {'name': [vp[name->josh]], 'age': [vp[age->32]]}, {'name': 
[vp[name->ripple]], 'lang': [vp[lang->java]]}, {'name': [vp[name->peter]], 
'age': [vp[age->35]]}]
{'city': [vp[city->Test City]], 'name': [vp[name->Test]], 'age': [vp[age->25]]}
[{'city': [vp[city->Test City]], 'name': [vp[name->Test]], 'age': 
[vp[age->25]]}, {'name': [vp[name->marko]], 'age': [vp[age->29]]}, {'name': 
[vp[name->vadas]], 'age': [vp[age->27]]}, {'name': [vp[name->lop]], 'lang': 
[vp[lang->java]]}, {'name': [vp[name->josh]], 'age': [vp[age->32]]}, {'name': 
[vp[name->ripple]], 'lang': [vp[lang->java]]}, {'name': [vp[name->peter]], 
'age': [vp[age->35]]}, {'city': [vp[city->Test City]], 'name': 
[vp[name->Test]], 'age': [vp[age->25]]}]
 {code}
 

 

> Vertex Creation Return StopItteraion() Error
> --------------------------------------------
>
>                 Key: TINKERPOP-3169
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3169
>             Project: TinkerPop
>          Issue Type: Bug
>    Affects Versions: 3.7.3
>            Reporter: Alfredo
>            Priority: Major
>
> The vertex gets created with all its properties, however there's a 
> stopItteration() error that is thrown.
> Maybe i'm not doing this correctly but haven't found a way to do it. 
> What i'm trying to do is build my vertex and its properties dynamically from 
> a list, then "commit" it all in one transaction or call to db engine. Im 
> using latest gremlin python library.
> {code:java}
> t = g.add_v("person")
> for prop, value in property_list:
>     t = t.property(prop, value)
> response = t.next() # this creates vertex, throws stopIteration() error
> response = t.to_list() # this creates vertex, throws no error but returns 
> empty list
> ver_count_after = g.V().count().next() # Shows increase in vertices
> # is there a way to create a vertex with dynamic list of properties in one 
> transaction.
> # I cant daisy-chain .property().property() on the command as I don't have a 
> finite number of properties {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to