Hello everyone,
Over the past months I have published 3 different Python clients for the Gremlin Server: aiogremlin [1], gremlinrestclient [2], and gremlinclient [3]. This may seem like a lot of work to accomplish basically the same thing, so today I would like to explain the reasoning behind each of these libraries. I first became interested in the Gremlin Server because my dissertation will use a graph database for data storage and analysis. I had used Neo4j quite a bit at work, but I was interested in something a bit more flexible for analysis. When I saw the new TInkerpop3 stack I thought it would be a perfect fit, so I set out to develop a driver using my language of choice: Python.When I saw that the Gremlin Server used websockets for communication I decided to take the opportunity to learn the new Python Asyncio [4] module that was introduced in the standard library with the Python 3.4 release. As this was more of a personal project, I didn't really worry about the fact that this would only work with Python 3, which unfortunately has still not been fully adopted by the Python community (I understand why, and this isn't a criticism). I didn't want to implement the websocket protocol from scratch, so I decided to use the aiohttp [5] implementation, as this one of the "sexiest" new Python libraries for asynchronous IO. This worked out great, and it gave me the opportunity to contribute to the websocket client implementation of this library. Hence, aiogremlin was born. To my delight, some other Python developers started experimenting with the library.
Later, we decided at my lab that we wanted to add the Gremlin Server as an optional backend for SylvaDB [6], my lab's graph database management system. SylvaDB previously supported Neo4j and Rexter, but we were intrigued by the possibility of plugging in any of the Tinkerpop vendor implementations into the system. Due to the fact that SylvaDB is a Python 2.7 Django based application, aiogremlin would not be compatible. So, over a period of a couple days I implemented a simple client for Gremlin Server using the REST architecture. This new client, gremlinrestclient, was based on Requests [7], the de facto standard library for HTTP with Python. This gave Python 2 developers an option for using the Gremlin Server, but it limited them to HTTP.
Later, in a conversation with Cody Lee, who developed the Mogwai ORM [8] for Rexster, we decided that the Python community needed an option that was compatible with Python 2 and Python 3 and allowed the user to choose between websockets and HTTP. Furthermore, we wanted a library that was compatible with the Trollius [9] style coroutine syntax, the Tornado [10] asynchronous web development framework, the current Asyncio coroutines, and the future Python asynchronous coroutines introduced in PEP 0492 [11]. This client could then serve as the basis for a new version of Mogwai that was flexible depending on user needs. To do this, we decided to use the Tornado implementation of the websocket protocol to create a client that uses pure callbacks internally (avoiding coroutines) and returns futures. This allows the user to choose the best coroutine style based on the tool kit that they are already using. Thus, gremlinclient, which is still pre-alpha, was born. In the following weeks you can expect to see new releases of gremlinclient and, hopefully soon, a new version of Mogwai.
Phew, that was a really long explanation, so in summary:
aiogremlin is a Python 3 library based on asyncio and aiohttp that uses websockets to communicate with the Gremlin Server.
gremlinrestclient is a Python 2/3 library that uses HTTP to communicate with the Gremlin Server.
gremlinclient is an asynchronous Python 2/3 client for the Gremlin Server that allows for flexible coroutine syntax--Trollius, Tornado, Asyncio--and (will) support both websockets and HTTP.
If you have any more questions, please do not hesitate to ask.
Dave