goblin icon indicating copy to clipboard operation
goblin copied to clipboard

goblin does not work with aiohttp>=3.0.0

Open xzy3 opened this issue 7 years ago • 5 comments

Related to https://github.com/davebshow/aiogremlin/issues/15 something in the newest aiohttp breaks Goblin. In the following script await session.flush() never returns. There is no error in the database logs and by logging in with the gremlin shell I can see that vertexes are successfully created. I had to apply the change in https://github.com/davebshow/aiogremlin/pull/16 to get that far. Downgrading to aiohttp==2.3.7 fixes the problem.

gremlinpython 3.2.6 goblin 2.1.0 aiogremlin 3.2.6 janusgraph 0.2.0 aiohttp 3.1.0

import asyncio
from goblin import Goblin,Property,String,Integer,Vertex,Edge,VertexProperty

class Person(Vertex):
  name = Property(String())
  age = Property(Integer())

class Knows(Edge):
  pass

loop = asyncio.get_event_loop()
goblin_app = loop.run_until_complete(Goblin.open(loop,
  hosts = ['localhost'],
  port = '8182',
  scheme = 'ws'))
goblin_app.register(Person, Knows)
print("Initialized all the goblin stuff")

async def create(app, data):
  print('getting session')
  session = await app.session()
  print('creating data', data)
  session.add(data)
  print('flushing')
  await session.flush()
  print('done')
  return data

leif = Person()
leif.name = 'Leif'
leif.age = 28
leif = loop.run_until_complete(create(goblin_app, leif))

jon = Person()
jon.name = 'Jon'
jon.age = 32
jon = loop.run_until_complete(create(goblin_app, jon))

works_with = Knows(leif, jon)
works_with = loop.run_until_complete(create(goblin_app, works_with))

xzy3 avatar Mar 22 '18 12:03 xzy3

Well I found an aiogremlin/aiohttp incompatability that partially causes this. I'll be rolling it into the PR I've submitted over there. Now I am getting:

Traceback (most recent call last):
  File "test.py", line 35, in <module>
    leif = loop.run_until_complete(create(goblin_app, leif))
  File "/apps/x86_64/python/3.6.1/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "test.py", line 23, in create
    print('getting session')
  File "/scicomp/home/xzy3/.local/virtualenvs/stantz3/lib/python3.6/site-packages/goblin/session.py", line 242, in flush
    await self.save(elem)
  File "/scicomp/home/xzy3/.local/virtualenvs/stantz3/lib/python3.6/site-packages/goblin/session.py", line 294, in save
    result = await self.save_edge(elem)
  File "/scicomp/home/xzy3/.local/virtualenvs/stantz3/lib/python3.6/site-packages/goblin/session.py", line 332, in save_edge
    self.current[hashable_id] = result
TypeError: unhashable type: 'dict'

xzy3 avatar Mar 22 '18 13:03 xzy3

Turns out it was the aiogremlin problem and then the need for the special get_hashable_id for JanusGraph. It took me a while to find the goblin-janus-examples repo. It would be helpful to be directed to it more prominently in the documentation.

xzy3 avatar Mar 27 '18 12:03 xzy3

Yeah I kind of randomly made that repo for a guy a was working for, never really thought about it as docs. Maybe there should be a section in the official docs called "Using Goblin with JanusGraph", though unfortunately I don't have time to do it right now...

davebshow avatar Mar 27 '18 15:03 davebshow

@davebshow something like pull request #104 ? I basically regurgitated some of your comments from recent bugs and things I found in the janus-examples repo. If you point me at other information I can add it/reword/edit.

xzy3 avatar Mar 29 '18 19:03 xzy3

Thanks @xzy3. I'll review your PR this week when I get a minute

davebshow avatar Apr 04 '18 18:04 davebshow