aws / graph-notebook

Library extending Jupyter notebooks to integrate with Apache TinkerPop, openCypher, and RDF SPARQL.
https://github.com/aws/graph-notebook
Apache License 2.0
718 stars 164 forks source link

Issue with Gremlin serializer #262

Closed henriquelds closed 2 years ago

henriquelds commented 2 years ago

Hello, I am locally running a docker container for gremlin-server:3.5.2 with airport-routes loaded data.

This is my gremlin-server conf file:

host: 172.17.0.2
port: 8182
channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer
graphs: {
  graph: conf/tinkergraph-empty.properties}
scriptEngines: {
  gremlin-groovy: {
    plugins: { org.apache.tinkerpop.gremlin.server.jsr223.GremlinServerGremlinPlugin: {},
               org.apache.tinkerpop.gremlin.tinkergraph.jsr223.TinkerGraphGremlinPlugin: {},
               org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {classImports: [java.lang.Math], methodImports: [java.lang.Math#*]},
               org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin: {files: [scripts/air-routes.groovy]}}}}
serializers:
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0] }}            # application/vnd.gremlin-v3.0+gryo
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}                                                                      # application/vnd.gremlin-v3.0+gryo-stringd
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0] }}        # application/json
metrics: {
  slf4jReporter: {enabled: true, interval: 180000}}
strictTransactionManagement: false
idleConnectionTimeout: 0
keepAliveInterval: 0
maxInitialLineLength: 4096
maxHeaderSize: 8192
maxChunkSize: 8192
maxContentLength: 65536
maxAccumulationBufferComponents: 1024
resultIterationBatchSize: 64

Then I try and succeed to connect my graph-notebook to the local gremlin-server with:

%%graph_notebook_config
{
  "host": "localhost",
  "port": 8182,
  "ssl": false,
  "gremlin": {
    "traversal_source": "g"
  }
}

However, when I run any queries with %%gremlin decorator, I keep receiving this error:

{'error': UnicodeDecodeError('utf-8', b'\x81\x01\x00\x00\x01\xf3\x00\x00\x00\x00$Invalid OpProcessor requested [null]\x00\x00\x00\x00\x00\x00\x00\x00\xfe\x01', 0, 1, 'invalid start byte')}

In my gremlin-server container logs, I noticed this message:

[WARN] 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.GraphBinaryMessageSerializerV1 by default
[WARN] OpSelectorHandler - Invalid OpProcessor requested [null]
org.apache.tinkerpop.gremlin.server.op.OpProcessorException: Invalid OpProcessor requested [null]

So, my guess is that I need to configure a different serializer for this mime type.. But I'm current clueless of which serializer I should choose and how to configure that on the conf yaml file. Do you guys could help me on that?

Thanks in advance

henriquelds commented 2 years ago

So, after researching the tinkerpop github I found out the correct serializer to be used in my conf yaml. https://github.com/apache/tinkerpop/blob/master/gremlin-driver/src/main/java/org/apache/tinkerpop/gremlin/driver/ser/GraphSONMessageSerializerV3d0.java

I basically add the following serializer to my yaml and now it's working fine.


- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config: { ioRegistries: [org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerIoRegistryV3d0] }}