Search code examples
gremlin

gremlin python add vertex KeyError


I'm using gremlinpython. Inserting a vertex with a property value of greater than 32-bits results in a KeyError.

g.addV('test').property('size', 2147483648).iterate()
File "/home/ec2-user/src/common/test.py", line 74, in insert_vertices
    self.g.addV('test').property('size', 2147483648).iterate()
  File "/home/ec2-user/venv/lib64/python3.6/dist-packages/gremlin_python/process/traversal.py", line 65, in iterate
    try: self.nextTraverser()
  File "/home/ec2-user/venv/lib64/python3.6/dist-packages/gremlin_python/process/traversal.py", line 70, in nextTraverser
    self.traversal_strategies.apply_strategies(self)  
  File "/home/ec2-user/venv/lib64/python3.6/dist-packages/gremlin_python/process/traversal.py", line 506, in apply_strategies
    traversal_strategy.apply(traversal)
  File "/home/ec2-user/venv/lib64/python3.6/dist-packages/gremlin_python/driver/remote_connection.py", line 148, in apply
    remote_traversal = self.remote_connection.submit(traversal.bytecode)
  File "/home/ec2-user/venv/lib64/python3.6/dist-packages/gremlin_python/driver/driver_remote_connection.py", line 54, in submit
    results = result_set.all().result()
  File "/usr/lib64/python3.6/concurrent/futures/_base.py", line 432, in result
    return self.__get_result()
  File "/usr/lib64/python3.6/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/home/ec2-user/venv/lib64/python3.6/dist-packages/gremlin_python/driver/resultset.py", line 90, in cb
    f.result()
  File "/usr/lib64/python3.6/concurrent/futures/_base.py", line 425, in result
    return self.__get_result()
  File "/usr/lib64/python3.6/concurrent/futures/_base.py", line 384, in __get_result
    raise self._exception
  File "/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/ec2-user/venv/lib64/python3.6/dist-packages/gremlin_python/driver/connection.py", line 80, in _receive
    status_code = self._protocol.data_received(data, self._results)
  File "/home/ec2-user/venv/lib64/python3.6/dist-packages/gremlin_python/driver/protocol.py", line 83, in data_received
    result_set = results_dict[request_id]
KeyError: None

A value of less than 32 bits works fine

g.addV('test').property('size', 2147483647).iterate()

Casting it to float also works fine

g.addV('test').property('size', float(2147483648)).iterate()

Same behavior with a locally running gremlin server and a remote Neptune DB. It works fine from the gremlin console. So I don't think this is a server issue.

Python version - 3.6 and 3.7

gremlinpython version - 3.4.1


Solution

  • You explicitly need to define that number as a long() like:

    from gremlin_python.statics import *
    
    g.addV('test').property('size', long(2147483648)).iterate()