Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mselite opened this issue Aug 3, 2021 · 0 comments

Comments

@mselite
Copy link

mselite commented Aug 3, 2021

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant