davebshow / goblin

A Python 3.5 rewrite of the TinkerPop 3 OGM Goblin
Other
93 stars 21 forks source link

How to change version of Goblin OGM Serializer for Janusgraph (TinkerPop 3.2.6) #101

Closed marciodebarros closed 6 years ago

marciodebarros commented 6 years ago

I am trying out a Python application to connect to a Janusgraph 0.2.0. I followed all the setup instructions and I am able to create elements in the graph and traverse them successfully.

`import asyncio

from goblin import Goblin from quart import jsonify, Quart, serving from app.models import Person, Knows

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") quart_app = Quart(name)

async def create(app, data): session = await app.session() session.add(data) await session.flush() 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(goblin_app, works_with)

`

However, when I try to connect from my application and send session.flush() to create an element, the application freezes and nothing else happens. In the gremlin-server.log I am seeing the following error:

1109015 [gremlin-server-worker-1] WARN org.apache.tinkerpop.gremlin.server.handler.WsGremlinBinaryRequestDecoder - Gremlin Server is not configured with a serializer for the requested mime type [application/vnd.gremlin-v3.0+json] - using org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 by default 1109035 [gremlin-server-worker-1] WARN org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0 - Request [PooledUnsafeDirectByteBuf(ridx: 558, widx: 558, cap: 592)] could not be deserialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0. 1109039 [gremlin-server-worker-1] WARN org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler - Invalid OpProcessor requested [null] org.apache.tinkerpop.gremlin.server.op.OpProcessorException: Invalid OpProcessor requested [null] at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:95) at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:50) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335) at io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler$1.channelRead(WebSocketServerProtocolHandler.java:159) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:312) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:286) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:335) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1302) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:356) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:342) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:646) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:581) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:498) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:460) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:131) at java.lang.Thread.run(Thread.java:745) ~

I found some information about replacing the version the GraphSON versions in the gremlin-server.yaml file to add the missing serializer for gremlin-v3.0+json, and I did that, however when I added that I get an error about not being able to find the configured serializer class: 10348 [main] WARN org.apache.tinkerpop.gremlin.server.AbstractChannelizer - Could not find configured serializer class - org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0 - it will not be available 1

So my questions are:

1) Is there a way that I can change the version of the serializer that my application is sending to the Gremlin Server to one of the compatible versions? 2) Would it work if I download the GraphSON version 3.0 and place it in the server ?

davebshow commented 6 years ago

This looks like a version problem. What versions of aiogremlin/gremlinpython do you have installed?

Try this:

pip uninstall gremlinpython
pip uninstall aiogremlin
pip uninstall tornado

pip install gremlinpython==3.2.6 --no-deps
pip install aiogremlin==3.2.6

I suspect that this will solve your problems.

davebshow commented 6 years ago

A bit more info here. Goblin can use any GLV 3.2.6 or later. By default it will install the newest versions of gremlinpython/aiogremlin available on PyPi. JanusGraph 0.2.0 only supports TinkerPop 3.2.6, so if you try to access it with a 3.3.x driver, you are going to have issues with serialization at the very least.

marciodebarros commented 6 years ago

Thanks Dave spot on. That was the issue. I am using PyCharm and automatically the package downloaded was 3.3.x, once I downgraded to 3.2.6, the error was gone.