Open stevencox opened 5 years ago
Hi @stevencox,
Could you give an estimation on the amount of nodes and edges you're trying to create within a single call to commit
I would start of with a small graph and see if it still hangs.
Also it might be useful to use Redismonitor
command to see the exact query which get send by redisgraph-py,
I'm not familiar with NetworkX, I would need to find some time and see what it's all about.
Hi @swilly22, Thanks for getting back to me.
Graph size:
nodes 988
edges 888
With incremental commits at a batch size of 10, it seems to hang on the first commit:
def to_knowledge_graph (self, in_graph, out_graph):
''' Convert a networkx graph to Ros KnowledgeGraph. '''
id2node = {}
print (f"---------> c0")
for j, n in enumerate(in_graph.nodes (data=True)):
i = n[0]
attr = n[1]['attr_dict']
id2node[i] = out_graph.add_node (label=attr['type'], props=attr)
if j % 10 == 0:
print ("commit")
out_graph.commit ()
out_graph.commit ()
print (f"---------> c1")
for i, e in enumerate(in_graph.edges (data=True)):
attr = e[2]['attr_dict']
subj = id2node[e[0]]
pred = attr['type']
obj = id2node[e[1]]
print (f"subj: {subj}")
print (f" pred: {pred}")
print (f" obj: {obj}")
out_graph.add_edge (subj=id2node[e[0]],
pred=attr['type'],
obj=id2node[e[1]],
props=attr)
if i % 10 == 0:
out_graph.commit ()
out_graph.commit ()
print (f"---------> c2")
But playing with the batch size, it seems to hang after around 6 objects. i.e. it will do five commits or so of single objects or two commits with a batch size of 3, for example.
I restarted the docker container to be sure it wasn't hung in some way.
Any suggestions welcome.
Alright so the graph is quite small, the fact that you're able to commit in batches, feels like there might be an escaping issue, and so if you could either provide me with Redis monitor
output or the actual raw data I'll be able to help further.
@swilly22 - this code hangs on the commit():
where out_graph is an instance of this:
So, am I doing something wrong with regard to the usage of commit()?
The code above prints a bunch of nodes and edges, then:
where it hangs indefinitely.
FWIW, I'm using the docker container version of redisgraph on OSX.
On a related note, the first snippet is a nearly general insert for NetworkX, related to issue #4. It would be pretty great if redisgraph-py supported NetworkX natively in both directions.