How do you get the Titan graph database working with Python?
Asked Answered
P

2

6

I'm new to this and am trying to get Titan working with Python. I've been beating my head on this for a day and a half and can't get anywhere. I've tried bulbs and rexpro-python but nothing seems to work.

In rexpro-python the following code:

from rexpro import RexProConnection
conn = RexProConnection('localhost', 8184, 'graph')

will hang and the server produces the following message (for titan versions 0.3.2, 0.3.1 and 0.2.1)

13/09/18 16:59:27 WARN filter.RexProMessageFilter: unsupported rexpro version: 1

In Bulbs:

from bulbs.config import Config, DEBUG
from bulbs.rexster import Graph

config = Config('http://localhost:8182/graphs/graph')
g = Graph(config)

Produces the following error:

SystemError: ({'status': '500', 'transfer-encoding': 'chunked', 'server': 'grizzly/2.2.16', 'connection': 'close', 'date': 'Wed, 18 Sep 2013 21:06:27 GMT', 'access-control-allow-origin': '*', 'content-type': 'application/json'}, '{"message":"","error":"javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: groovy.lang.MissingMethodException.idx() is applicable for argument types: () values: []\\nPossible solutions: is(java.lang.Object), any(), find(), any(groovy.lang.Closure), with(groovy.lang.Closure), _(groovy.lang.Closure)","api":{"description":"evaluate an ad-hoc Gremlin script for a graph.","parameters":{"rexster.returnKeys":"an array of element property keys to return (default is to return all element properties)","rexster.showTypes":"displays the properties of the elements with their native data type (default is false)","load":"a list of \'stored procedures\' to execute prior to the \'script\' (if \'script\' is not specified then the last script in this argument will return the values","rexster.offset.end":"end index for a paged set of data to be returned","rexster.offset.start":"start index for a paged set of data to be returned","params":"a map of parameters to bind to the script engine","language":"the gremlin language flavor to use (default to groovy)","script":"the Gremlin script to be evaluated"}},"success":false}')

with a similar exception on the Titan server. Has anyone gotten this to work?

Parodic answered 18/9, 2013 at 21:12 Comment(1)
Use bulbs.titan not bulbs.rexsterAnticatalyst
R
1

In the case of rexpro-python, you have a version issue. The latest version of RexPro Python will connect to TinkerPop/Rexster 2.4.0. Titan does not support that version yet. As of Titan 0.3.2 it supports TinkerPop 2.3.x. It looks like this is the last commit prior to the bump to 2.4.0 compatibility for rexpro-python:

https://github.com/bdeggleston/rexpro-python/commit/3597f4ce5a4da69ec64f174aa1a064abf7524693

but you may want to review the commit history a bit to be sure you get the right one.

Bulbs looks like it is making a call to a manual index, something Titan doesn't support. There are a number of posts on this in the gremlin-users and/or areuliusgraphs mailing lists. Check out this post with a reference to your exact problem:

https://groups.google.com/forum/#!msg/gremlin-users/s7Ag1tjbxLs/nC5WjtHh6woJ

Short answer it looks like Bulbs was updated to support Titan. Perhaps, you have some version incompatibility somewhere still.

Reproach answered 19/9, 2013 at 11:11 Comment(3)
I got the version of RexPro you mentioned working with Titan 0.3.1. I suspect the other versions would work as well.Parodic
Revisiting this, I suspect the Bulbs interface wasn't working because in Titan 0.3.2 (probably 0.3.1, etc, too) had a bug that caused the REST server (although not RexPro) not to start by default. I'm now using 0.4.0.Parodic
Use bubls.titan not bulbs.rexsterAnticatalyst
A
1

With Titan 1.0.0 or later, we have better ways to connect from python.

Now titan comes with Gremlin server. Gremlin server provides ability for Non-JVM languages (e.g. Python, Javascript, etc.) to communicate with the TinkerPop stack.

Gremlin Server is the replacement for Rexster.

To start gremlin server (this script is packaged with titan):

sh gremlin-server.sh 

Similar batch script is available for windows in same directory.

Once started, following python drivers should help connect with Gremlin server:

  • aiogremlin - A Python 3 library based on asyncio and aiohttp that uses websockets to communicate with the Gremlin Server.
  • gremlinclient - An asynchronous Python 2/3 client for Gremlin Server that allows for flexible coroutine syntax - Trollius, Tornado, Asyncio. This is from the same author as aiogremlin. I believe, aiogremlin is no longer supported and this is the latest project that he works on.
  • gremlinrestclient - Python 2/3 library that uses HTTP to communicate with the Gremlin Server over REST.

Python based Query language libraries, that can help during development:

  • gremlin-py - Write pure Python Gremlin that can be sent to Gremlin Server.
  • gremlin-python - Allows usage of Python syntax when traversing property graphs.
Actin answered 9/5, 2016 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.