kappa-dev / regraph Goto Github PK
View Code? Open in Web Editor NEWTool for building graph-based hierarchical knowledge representation systems
Home Page: http://dev.executableknowledge.org/ReGraph/
License: MIT License
Tool for building graph-based hierarchical knowledge representation systems
Home Page: http://dev.executableknowledge.org/ReGraph/
License: MIT License
Networkx 2.2 and 1.11 are syntactically not compatible. I'm using the newer version and the ReGraph examples won't work. For instance
import networkx as nx
from regraph.primitives import add_nodes_from
G = nx.Graph()
add_nodes_from(G, [1, (2, {"a": 1}), 3])
gives
File "test_graph_rewrite.py", line 23, in test_basics
add_nodes_from(G, [1, (2, {"a": 1}), 3])
File "regraph/primitives.py", line 79, in add_nodes_from
add_node(graph, n)
File "regraph/primitives.py", line 51, in add_node
graph.node[node_id] = new_attrs
TypeError: 'NodeView' object does not support item assignment
The reason is that in the newer veresion of networkx graph.node
gives a NodeView object. The errors can be fixed by downgrading to networkx 1.11 (e.g., by usingpip install regraph --upgrade
) but that breaks the rest of my codebase. Moving on to the current networkx version would be really great!
When we update the data's node in python script, that doesn't replace the previous value but add the new one.
Line 963 in 43e362d
When the following try fails
try:
for v in values:
value_set.add(v)
except TypeError:
value_set.add(v)
the exception causes an exception because the parameter 'v' is not assigned outside of the for-loop.
UnboundLocalError: local variable 'v' referenced before assignment
Unit tests contain 3 errors: AttributeError: 'set' object has no attribute 'num_set'
ERROR: test_partial_typing.TestPartialTyping.test_apply_rule
Traceback (most recent call last):
/home/eugenia/anaconda3/lib/python3.5/site-packages/nose/case.py line 198 in runTest
self.test(*self.arg)
tests/test_partial_typing.py line 322 in test_apply_rule
assert(new_h != self.hierarchy)
regraph/hierarchy.py line 388 in __eq__
if not equal(g1, g2):
regraph/primitives.py line 1122 in equal
if graph1.node[node] != graph2.node[node]:
regraph/atset.py line 65 in __eq__
return self.issubset(other) and other.issubset(self)
regraph/atset.py line 56 in issubset
return self.num_set.issubset(other.num_set) and\
AttributeError: 'str' object has no attribute 'num_set'
ERROR: test_rules.TestRule.test_remove_edge_attrs
Traceback (most recent call last):
/home/eugenia/anaconda3/lib/python3.5/site-packages/nose/case.py line 198 in runTest
self.test(*self.arg)
tests/test_rules.py line 219 in test_remove_edge_attrs
assert(rule.p.edge['b']['c'] == t1)
regraph/atset.py line 65 in __eq__
return self.issubset(other) and other.issubset(self)
regraph/atset.py line 56 in issubset
return self.num_set.issubset(other.num_set) and\
AttributeError: 'set' object has no attribute 'num_set'
ERROR: test_rules.TestRule.test_update_edge_attrs
Traceback (most recent call last):
/home/eugenia/anaconda3/lib/python3.5/site-packages/nose/case.py line 198 in runTest
self.test(*self.arg)
tests/test_rules.py line 235 in test_update_edge_attrs
assert(rule.rhs.edge['y']['z'] == test_dict)
regraph/atset.py line 65 in __eq__
return self.issubset(other) and other.issubset(self)
regraph/atset.py line 56 in issubset
return self.num_set.issubset(other.num_set) and\
AttributeError: 'set' object has no attribute 'num_set'
Traceback (most recent call last):
/home/eugenia/anaconda3/lib/python3.5/site-packages/nose/case.py line 198 in runTest
self.test(*self.arg)
tests/test_primitives.py line 241 in test_set_edge
set_edge(g, '6', '7', {'a': 'b'})
regraph/primitives.py line 422 in set_edge
"Edge %s->%s does not exist" % (str(source), str(target)))
GraphError: Edge 6->7 does not exist
How do we type a rule?
Before we had: all the typings (of both LHS and RHS) of a rule were total (could they be partial? if some of the nodes in the lhs are not typed at all: do we match any node in G? -> then how do we type the result of this rewriting?)
The NXGraph constructor has the incoming_graph_data=None
that is never used, it seems that constructing a new NXGraph from the existing networkx graph is currently not supported.
There has been a backwards incompatible change to the Neo4j drivers which changed the package structure. As a result, installing and then importing regraph
fails.
>>> import regraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/benbc/src/opensafely-core/databuilder/.venv/lib/python3.9/site-packages/regraph/__init__.py", line 6, in <module>
from regraph.backends.neo4j.graphs import Neo4jGraph
File "/home/benbc/src/opensafely-core/databuilder/.venv/lib/python3.9/site-packages/regraph/backends/neo4j/__init__.py", line 3, in <module>
from regraph.backends.neo4j.graphs import Neo4jGraph
File "/home/benbc/src/opensafely-core/databuilder/.venv/lib/python3.9/site-packages/regraph/backends/neo4j/graphs.py", line 10, in <module>
from neo4j.v1 import GraphDatabase
ModuleNotFoundError: No module named 'neo4j.v1'
The fix needed is to pin the neo4j-driver
dependency in setup.py
to < 4.0.0
.
As a workaround you can provide this dependency yourself alongside the dependency on regraph
so that the latest version of neo4j-driver
doesn't get installed.
(This project doesn't look like it's maintained, so I'm mostly putting this here as documentation so that other people can find the workaround.)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.