gremlin-python 不是可用的 GremlinScriptEngine

gremlin-python is not an available GremlinScriptEngine

我正在尝试使用 gremlin python 在 AWS neptune 上执行 lambda 函数。它击中了我 gremlin-python is not an available GremlinScriptEngine。有人可以帮助解决这个问题。 g.V().out().map(lambda: "lambda x: len(x.get().value('event'))").toList()

图中的每个顶点都包含一个 event 属性 文本

执行的查询:g.V().out().map(lambda: "lambda x: len(x.get().value('event'))").toList() 堆栈跟踪:

GremlinServerError                        Traceback (most recent call last)
<ipython-input-392-602123a0a83a> in <module>()
----> 1 g.V().out().map(lambda: "lambda x: len(x.get().value('event'))").toList()

/usr/local/lib/python3.7/site-packages/gremlin_python/process/traversal.py in toList(self)
     55 
     56     def toList(self):
---> 57         return list(iter(self))
     58 
     59     def toSet(self):

/usr/local/lib/python3.7/site-packages/gremlin_python/process/traversal.py in __next__(self)
     45     def __next__(self):
     46         if self.traversers is None:
---> 47             self.traversal_strategies.apply_strategies(self)
     48         if self.last_traverser is None:
     49             self.last_traverser = next(self.traversers)

/usr/local/lib/python3.7/site-packages/gremlin_python/process/traversal.py in apply_strategies(self, traversal)
    504     def apply_strategies(self, traversal):
    505         for traversal_strategy in self.traversal_strategies:
--> 506             traversal_strategy.apply(traversal)
    507 
    508     def apply_async_strategies(self, traversal):

/usr/local/lib/python3.7/site-packages/gremlin_python/driver/remote_connection.py in apply(self, traversal)
    146     def apply(self, traversal):
    147         if traversal.traversers is None:
--> 148             remote_traversal = self.remote_connection.submit(traversal.bytecode)
    149             traversal.remote_results = remote_traversal
    150             traversal.side_effects = remote_traversal.side_effects

/usr/local/lib/python3.7/site-packages/gremlin_python/driver/driver_remote_connection.py in submit(self, bytecode)
     52     def submit(self, bytecode):
     53         result_set = self._client.submit(bytecode)
---> 54         results = result_set.all().result()
     55         side_effects = RemoteTraversalSideEffects(result_set.request_id, self._client,
     56                                                   result_set.status_attributes)

/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py in result(self, timeout)
    430                 raise CancelledError()
    431             elif self._state == FINISHED:
--> 432                 return self.__get_result()
    433             else:
    434                 raise TimeoutError()

/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py in __get_result(self)
    382     def __get_result(self):
    383         if self._exception:
--> 384             raise self._exception
    385         else:
    386             return self._result

/usr/local/lib/python3.7/site-packages/gremlin_python/driver/resultset.py in cb(f)
     88         def cb(f):
     89             try:
---> 90                 f.result()
     91             except Exception as e:
     92                 future.set_exception(e)

/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py in result(self, timeout)
    423                 raise CancelledError()
    424             elif self._state == FINISHED:
--> 425                 return self.__get_result()
    426 
    427             self._condition.wait(timeout)

/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/_base.py in __get_result(self)
    382     def __get_result(self):
    383         if self._exception:
--> 384             raise self._exception
    385         else:
    386             return self._result

/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/concurrent/futures/thread.py in run(self)
     55 
     56         try:
---> 57             result = self.fn(*self.args, **self.kwargs)
     58         except BaseException as exc:
     59             self.future.set_exception(exc)

/usr/local/lib/python3.7/site-packages/gremlin_python/driver/connection.py in _receive(self)
     78             while True:
     79                 data = self._transport.read()
---> 80                 status_code = self._protocol.data_received(data, self._results)
     81                 if status_code != 206:
     82                     break

/usr/local/lib/python3.7/site-packages/gremlin_python/driver/protocol.py in data_received(self, message, results_dict)
    108         else:
    109             del results_dict[request_id]
--> 110             raise GremlinServerError(message["status"])

GremlinServerError: 599: {"requestId":"b8d8ea20-bcab-4350-94f3-47611fac704a","code":"InternalFailureException","detailedMessage":"gremlin-python is not an available GremlinScriptEngine"}```

如果 gremlin-python 脚本引擎在 Neptune 上可用,我会感到惊讶。实际上,即使使用 Gremlin Server,默认情况下也不会安装 gremlin-python,并且仅作为 plugin that you directly install 提供给 Gremlin Server。

我会说答案是提交您的 lambdas as Groovy scripts 喜欢:

g.V().out().map(lambda: ("it.get().value('name').length()", "gremlin-groovy")).sum().toList()

但总的来说,根本 Neptune doesn't support lambdas 所以这是否有效值得怀疑。我认为您将不得不弄清楚如何在没有此功能的情况下编写您的遍历。

出于安全原因,Amazon Neptune 不允许任何 脚本引擎。文档 [1] 没有具体指出脚本引擎,但它提到 Neptune 不支持 Lambda 和 groovy 等脚本。

[1] https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-differences.html