Connect to OrientDB through gremlin-python
Froskekongen opened this issue · comments
While this may be the wrong place for such an inquiry, I try, nonetheless:
Using gremlin-python, how can I connect to OrientDBs gremlin-server?
I have tried running docker run -d --name orientdb -p 2424:2424 -p 2480:2480 -e ORIENTDB_ROOT_PASSWORD=root orientdb:3.0.0RC2
with the following
from gremlin_python.driver import client
cli = client.Client('ws://localhost:2424/demodb','g',username='root',password='root')
Also, with variations in the connect string. This results in a timeout.
2424
is the binary port for OrientDB protocol. You should use the port of the GremlinServer if you want to connect with the gremlin python driver. By default should be 8182
As you can see in ws://localhost:2424/demodb
, I am already using port 2424
.
That's why i suggested 8182
. 2424 is reserved for OrientDB protocol, not GremlinServer one.
http://tinkerpop.apache.org/docs/current/reference/#connecting-via-python
I will try this. I also suggest you update the dockerfile to explicitly expose port 8182 (: (Dockerfile)
Hi,
Maybe this will help you:
I run a docker image with the gremlin server:
docker pull orientdb:3.0.17-tp3
docker run -d --name odbtp3 -p 2424:2424 -p 2480:2480 -p 8182:8182 -e ORIENTDB_ROOT_PASSWORD=rootpwd orientdb:3.0.17-tp3
Here's a python snippet to connect with the generic gremlin client and execute a query:
from gremlin_python.driver import client
username="root"
password="rootpwd"
host="localhost"
port=8182
url="ws://"+host+":"+str(port)+"/gremlin"
print("Connecting to gremlin server at: ", url)
g= client.Client(url=url, traversal_source='g', username=username, password=password)
query = "g.V().label().groupCount()"
print(g.submit(query).next())
For the OrientDB section of http://wiki.bitplan.com/index.php/Gremlin_python#Connecting_to_Gremlin_enabled_graph_databases
I tried to get this working - unfortunately there seems to be some version issues. What would be needed to get gremlin python working with apache-tinkerpop-gremlin-server-3.4.3?
For the OrientDB section of http://wiki.bitplan.com/index.php/Gremlin_python#Connecting_to_Gremlin_enabled_graph_databases
I tried to get this working - unfortunately there seems to be some version issues. What would be needed to get gremlin python working with apache-tinkerpop-gremlin-server-3.4.3?
Could you please describe the version issue?
The version conflict is just an assumption.
Steps to reproduce:
git clone https://github.com/WolfgangFahl/gremlin-python-tutorial
./run -i
docker pull orientdb:3.0.23-tp3
ln -f OrientDB.yaml server.yaml
./run -t
result:
./run -t
======================================= test session starts =======================================
platform darwin -- Python 3.7.4, pytest-5.1.2, py-1.8.0, pluggy-0.12.0
rootdir: /Users/wf/source/python/gremlin-python-tutorial
collecting 0 items / 1 errors g.V().count=0
0 results
{}
collected 1 item / 5 errors
============================================= ERRORS ==============================================
__________________________________ ERROR collecting test_000.py ___________________________________
test_000.py:13: in <module>
test_LoadModern()
test_000.py:10: in test_LoadModern
remoteTraversal.load("tinkerpop-modern.xml")
tutorial/remote.py:33: in load
g.V().drop().iterate()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/process/traversal.py:66: in iterate
try: self.nextTraverser()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/process/traversal.py:71: in nextTraverser
self.traversal_strategies.apply_strategies(self)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/process/traversal.py:573: in apply_strategies
traversal_strategy.apply(traversal)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/remote_connection.py:149: in apply
remote_traversal = self.remote_connection.submit(traversal.bytecode)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/driver_remote_connection.py:54: in submit
results = result_set.all().result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:435: in result
return self.__get_result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:384: in __get_result
raise self._exception
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/resultset.py:90: in cb
f.result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:428: in result
return self.__get_result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:384: in __get_result
raise self._exception
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py:57: in run
result = self.fn(*self.args, **self.kwargs)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/connection.py:80: in _receive
status_code = self._protocol.data_received(data, self._results)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/protocol.py:97: in data_received
return self.data_received(data, results_dict)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/protocol.py:110: in data_received
raise GremlinServerError(message["status"])
E gremlin_python.driver.protocol.GremlinServerError: 599: null:none([])
__________________________________ ERROR collecting test_001.py ___________________________________
test_001.py:20: in <module>
test_VCount()
test_001.py:11: in test_VCount
assert vCount == 6
E assert 0 == 6
______________________________ ERROR collecting test_002_tutorial.py ______________________________
test_002_tutorial.py:82: in <module>
test_tutorial0()
test_002_tutorial.py:23: in test_tutorial0
id1=l[0].id
E IndexError: list index out of range
_________________________________ ERROR collecting test_004_io.py _________________________________
test_004_io.py:31: in <module>
test_loadGraph()
test_004_io.py:13: in test_loadGraph
g.V().drop().iterate()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/process/traversal.py:66: in iterate
try: self.nextTraverser()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/process/traversal.py:71: in nextTraverser
self.traversal_strategies.apply_strategies(self)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/process/traversal.py:573: in apply_strategies
traversal_strategy.apply(traversal)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/remote_connection.py:149: in apply
remote_traversal = self.remote_connection.submit(traversal.bytecode)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/driver_remote_connection.py:54: in submit
results = result_set.all().result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:435: in result
return self.__get_result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:384: in __get_result
raise self._exception
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/resultset.py:90: in cb
f.result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:428: in result
return self.__get_result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:384: in __get_result
raise self._exception
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py:57: in run
result = self.fn(*self.args, **self.kwargs)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/connection.py:80: in _receive
status_code = self._protocol.data_received(data, self._results)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/protocol.py:97: in data_received
return self.data_received(data, results_dict)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/protocol.py:110: in data_received
raise GremlinServerError(message["status"])
E gremlin_python.driver.protocol.GremlinServerError: 599: null:none([])
______________________________ ERROR collecting test_005_graphviz.py ______________________________
test_005_graphviz.py:53: in <module>
test_createGraphvizGraph()
test_005_graphviz.py:14: in test_createGraphvizGraph
remoteTraversal.load("tinkerpop-modern.xml")
tutorial/remote.py:33: in load
g.V().drop().iterate()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/process/traversal.py:66: in iterate
try: self.nextTraverser()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/process/traversal.py:71: in nextTraverser
self.traversal_strategies.apply_strategies(self)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/process/traversal.py:573: in apply_strategies
traversal_strategy.apply(traversal)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/remote_connection.py:149: in apply
remote_traversal = self.remote_connection.submit(traversal.bytecode)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/driver_remote_connection.py:54: in submit
results = result_set.all().result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:435: in result
return self.__get_result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:384: in __get_result
raise self._exception
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/resultset.py:90: in cb
f.result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:428: in result
return self.__get_result()
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py:384: in __get_result
raise self._exception
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py:57: in run
result = self.fn(*self.args, **self.kwargs)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/connection.py:80: in _receive
status_code = self._protocol.data_received(data, self._results)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/protocol.py:97: in data_received
return self.data_received(data, results_dict)
/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gremlin_python/driver/protocol.py:110: in data_received
raise GremlinServerError(message["status"])
E gremlin_python.driver.protocol.GremlinServerError: 599: null:none([])
!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 5 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================== 5 error in 10.34s ========================================
Hi Wolfgang, it looks like a serialization issue. The log of the gremlin server inside docker shows:
2019-09-30 13:49:22:376 SEVER Could not deserialize the Traversal instance [TraversalOpProcessor]Could not deserialize the Traversal instance
org.apache.tinkerpop.gremlin.server.op.OpProcessorException: Could not deserialize the Traversal instance
at org.apache.tinkerpop.gremlin.server.op.traversal.TraversalOpProcessor.iterateBytecodeTraversal(TraversalOpProcessor.java:368)
at org.apache.tinkerpop.gremlin.server.handler.OpExecutorHandler.channelRead0(OpExecutorHandler.java:68)
at org.apache.tinkerpop.gremlin.server.handler.OpExecutorHandler.channelRead0(OpExecutorHandler.java:43)
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356)
I've had similar issues when using gremlin with ODB from java and solved it by specifying an IORegistry or changing the default serialization method. I'm not sure how to do this in python.