Skip to content

How to use GraphComputer with gremlinpython or java api to make some computation like pageRank algorithme ? #182

@mselite

Description

@mselite

Hello there,

Is there any way to use PageRank algorithme through the gremlinpython api or java api with orientdb?
As is said in gremlin documentation PageRank centrality can be calculated with Gremlin with the pageRank()-step which is designed to work with GraphComputer (OLAP) based traversals. So is it possible to use GraphComputer with gremlinpython implementation with orientdb?
Here is the error that I got:

Traceback (most recent call last):
File "/home/msani/Documents/These/Programs/Scripts/NER_Extraction/Gremlin/orientDB/src/orientdbGremlin.py", line 21, in <module>
  print(g.submit(q).next())
File "/home/msani/.pyenv/versions/3.6.7/envs/tinkerpop/lib/python3.6/site-packages/gremlin_python/driver/resultset.py", line 67, in next
  return self.__next__()
File "/home/msani/.pyenv/versions/3.6.7/envs/tinkerpop/lib/python3.6/site-packages/gremlin_python/driver/resultset.py", line 61, in __next__
  result = self.one()
File "/home/msani/.pyenv/versions/3.6.7/envs/tinkerpop/lib/python3.6/site-packages/gremlin_python/driver/resultset.py", line 83, in one
  return self.done.result()
File "/home/msani/.pyenv/versions/3.6.7/lib/python3.6/concurrent/futures/_base.py", line 425, in result
  return self.__get_result()
File "/home/msani/.pyenv/versions/3.6.7/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
  raise self._exception
File "/home/msani/.pyenv/versions/3.6.7/lib/python3.6/concurrent/futures/thread.py", line 56, in run
  result = self.fn(*self.args, **self.kwargs)
File "/home/msani/.pyenv/versions/3.6.7/envs/tinkerpop/lib/python3.6/site-packages/gremlin_python/driver/connection.py", line 83, in _receive
  status_code = self._protocol.data_received(data, self._results)
File "/home/msani/.pyenv/versions/3.6.7/envs/tinkerpop/lib/python3.6/site-packages/gremlin_python/driver/protocol.py", line 118, in data_received
  return self.data_received(data, results_dict)
File "/home/msani/.pyenv/versions/3.6.7/envs/tinkerpop/lib/python3.6/site-packages/gremlin_python/driver/protocol.py", line 131, in data_received
  raise GremlinServerError(message['status'])
gremlin_python.driver.protocol.GremlinServerError: 597: startup failed:
Script10.groovy: 1: expecting ''', found '<EOF>' @ line 1, column 79.
   nth).pageRank().by('pageRank')
                                 ^
1 error
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7fda5bd6def0>
Exception ignored in: <bound method ClientResponse.__del__ of <ClientResponse(ws://localhost:8182/gremlin) [101 Switching Protocols]>
<CIMultiDictProxy('Upgrade': 'websocket', 'Connection': 'Upgrade', 'Sec-WebSocket-Accept': '5jifBwoDrjGqM7drL0ldDmZXqGk=')>
>
Traceback (most recent call last):
  File "/home/msani/.pyenv/versions/3.6.7/envs/tinkerpop/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 803, in __del__
  File "/home/msani/.pyenv/versions/3.6.7/envs/tinkerpop/lib/python3.6/site-packages/aiohttp/connector.py", line 171, in release
  File "/home/msani/.pyenv/versions/3.6.7/envs/tinkerpop/lib/python3.6/site-packages/aiohttp/connector.py", line 650, in _release
  File "/home/msani/.pyenv/versions/3.6.7/envs/tinkerpop/lib/python3.6/site-packages/aiohttp/client_proto.py", line 63, in close
  File "/home/msani/.pyenv/versions/3.6.7/lib/python3.6/asyncio/selector_events.py", line 621, in close
  File "/home/msani/.pyenv/versions/3.6.7/lib/python3.6/asyncio/base_events.py", line 580, in call_soon
  File "/home/msani/.pyenv/versions/3.6.7/lib/python3.6/asyncio/base_events.py", line 366, in _check_closed
RuntimeError: Event loop is closed

Here is my code:

from gremlin_python.driver import client

username="root"
password="rootpwd"
host="localhost"
#port=2480
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)
q = "g.withComputer().V().hasLabel('Article').has('month).pageRank().by('pageRank').valueMap()"
print(g.submit(q).next())

g.close()

I am using this docker image of orientdb: sudo docker run -d --name orientdbtp3 -p 2424:2424 -p 2480:2480 -p 8182:8182 -e ORIENTDB_ROOT_PASSWORD=rootpwd orientdb:3.0.17-tp3.

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions