无法使用JanusGraph,Cassandra,gremlinpython和Python3迭代创建边缘

时间:2019-07-17 20:07:01

标签: python cassandra gremlin tinkerpop janusgraph

将JanusGraph和Tinkerpop与Gremlinpython,OpenJDK和python3结合使用,我无法使用以下常规语句添加边线:

g.V().has("node_property", 1).as_("a").V().has("node_property", 2).as_("b").addE("link").property("edge_property", 12).from_("a").to("b").iterate()

完整的代码段:

from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))

# in a loop add nodes and properties to get a small graph for testing
t = g.addV('testnode').property('val',1)
    for i in range(2,11):
    t = g.addV('testnode').property('val', i)
    t.iterate()

# proceed to create edge (as_ and from_ contain an underscore because as & from are python's reserved words)
g.V().has("val", 2).as_("a").V().has("val", 4).as_("b").addE("link").property("someproperty", "abc").from_("a").to("b").iterate()

不幸的是,这是结果(从终端粘贴):

Traceback (most recent call last):
  File "test_addingVEs.py", line 45, in <module>

  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/process/traversal.py", line 57, in iterate
    try: self.nextTraverser()
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/process/traversal.py", line 61, in nextTraverser
    self.traversal_strategies.apply_strategies(self)
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/process/traversal.py", line 346, in apply_strategies
    traversal_strategy.apply(traversal)
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/remote_connection.py", line 143, in apply
    remote_traversal = self.remote_connection.submit(traversal.bytecode)
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/driver_remote_connection.py", line 54, in submit
    results = result_set.all().result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 405, in result
    return self.__get_result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
    raise self._exception
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/resultset.py", line 81, in cb
    f.result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 398, in result
    return self.__get_result()
  File "/usr/lib/python3.5/concurrent/futures/_base.py", line 357, in __get_result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/connection.py", line 77, in _receive
    self._protocol.data_received(data, self._results)
  File "/home/user/.local/lib/python3.5/site-packages/gremlin_python/driver/protocol.py", line 98, in data_received
    "{0}: {1}".format(status_code, message["status"]["message"]))
gremlin_python.driver.protocol.GremlinServerError: 500: Could not execute operation due to backend exception

我不太理解最后一行:

gremlin_python.driver.protocol.GremlinServerError: 500: Could not execute operation due to backend exception

因为我确实跑过:

bin/janusgraph.sh start

并且看到Cassandra正在运行。

  • 我想知道我做错了什么,常规设置是否正确?
  • 我应该将边缘创建分配给(t)变量,然后像在第一个for循环中一样将其传递给.iterate()吗?
  • 还是我不知道的其他事情?

任何建议都将不胜感激。

0 个答案:

没有答案