gpt4 book ai didi

python - gremlin python 检索 id 和标签 (valueMap(True))

转载 作者:太空宇宙 更新时间:2023-11-03 15:48:33 25 4
gpt4 key购买 nike

python g.V('test_red1').valueMap().toList()

工作正常,但是当我将 true 传递给请求 id 和标签时,我收到此错误。有什么我想念的吗?

g.V('test_red1').valueMap(True).toList()

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ec2-user/environment/merchantGraph/gremlin_python/process/traversal.py", line 52, in toList
return list(iter(self))
File "/home/ec2-user/environment/merchantGraph/gremlin_python/process/traversal.py", line 43, in __next__
...

我是不是漏掉了什么。我正在使用 AWS Neptune ...

我正在添加额外的导入语句

和回溯

import time
import requests
import json
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


import boto3
from os import environ

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection(environ['gremlinNeptuneConnection'],'g'))


# this works
g.V('test_red1').valueMap().toList()

# this fails
g.V('test_red1').valueMap(True).toList()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ec2-user/environment/merchantGraph/gremlin_python/process/traversal.py", line 52, in toList
return list(iter(self))
....
File "/home/ec2-user/environment/merchantGraph/gremlin_python/structure/io/graphsonV3d0.py", line 455, in objectify
new_dict[reader.toObject(l[x])] = reader.toObject(l[x + 1])

TypeError: unhashable type: 'dict'

最佳答案

我的猜测是您遇到了最近报告的 valueMap(true) 错误的麻烦:

https://issues.apache.org/jira/browse/TINKERPOP-1860

它已打补丁,将在 3.3.2 版本中修复。在那之前你将不得不解决这个问题,因为除了恢复到 GraphSON 2.0(它有自己的一系列缺点)之外真的没有解决办法。一种解决方法是 project() 您的结果:

gremlin> g.V().project('props','id','label').
......1> by(valueMap()).
......2> by(id).
......3> by(label)
==>[props:[name:[marko],age:[29]],id:1,label:person]
==>[props:[name:[vadas],age:[27]],id:2,label:person]
==>[props:[name:[lop],lang:[java]],id:3,label:software]
==>[props:[name:[josh],age:[32]],id:4,label:person]
==>[props:[name:[ripple],lang:[java]],id:5,label:software]
==>[props:[name:[peter],age:[35]],id:6,label:person]

关于python - gremlin python 检索 id 和标签 (valueMap(True)),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48350862/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com