David M. Brown created TINKERPOP-1599:
-----------------------------------------

             Summary: implement real gremlin-python driver
                 Key: TINKERPOP-1599
                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1599
             Project: TinkerPop
          Issue Type: Improvement
          Components: driver, language-variant
    Affects Versions: 3.2.3
            Reporter: David M. Brown
            Assignee: David M. Brown
             Fix For: 3.3.0


It is high time that gremlin-python comes packaged with a real driver. After 
watching the community discussion, it seems that the way to go will be to use 
the {{concurrent.futures}} module with multithreading to provide asynchronous 
I/O. While the default underlying websocket client library will remain Tornado 
due to Python 2/3 compatibility issues, this should be decoupled from the rest 
of the client and easy to replace.

With this is mind, I created a baseline client implementation with [this 
commit|https://github.com/apache/tinkerpop/commit/fb7e7f255585956abbb854fcc5dd3138113cf454]
 in a topic branch {{python_driver}}. Some things to note:

- All I/O is performed using the {{concurrent.futures}} module, which provides 
a standard 2/3 compatible future interface.

- The implementation currently does not include the concept of a cluster, 
instead it assumes a single host.

- The {{transport}} interface makes it easy to plug in client libraries by 
defining a simple wrapper.

- Because this is an example, I didn't fix all the tests to work with the new 
client implementation. Instead I just added a few demo tests. If we decide to 
move forward with this I will update the original tests.

The resulting API looks like this for a simple client:

{code}
client = Client('ws://localhost:8182/gremlin', 'g')
g = Graph().traversal()
t = g.V()
future_result_set = client.submitAsync(t.bytecode)
result_set = future_result_set.result()
results = result_set.all().result()
client.close()
{code}

Using the {{DriverRemoteConnection}}:

{code}
conn = DriverRemoteConnection('ws://localhost:8182/gremlin', 'g')
g = Graph().traversal().withRemote(conn)
t = g.V()
results = t.toList()
conn.close()
{code}

If you have a minute to check out the new driver code that would be great, I 
welcome feedback and suggestions. If we decide to move forward like this, I 
will proceed to finish the driver implementation.





--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to