Giter Site home page Giter Site logo

kappa-dev / regraph Goto Github PK

View Code? Open in Web Editor NEW
71.0 8.0 15.0 109.56 MB

Tool for building graph-based hierarchical knowledge representation systems

Home Page: http://dev.executableknowledge.org/ReGraph/

License: MIT License

Python 100.00%
graph-rewriting-library knowledge-representation graph hierarchy graph-transformation-systems

regraph's People

Contributors

eugeniashurko avatar florianperon avatar ismailbennani avatar pirbo avatar raimon-fa avatar sergred avatar ylecornec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

regraph's Issues

Support for networkx 2.2

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!

Bug with updated data

When we update the data's node in python script, that doesn't replace the previous value but add the new one.

Accessing loop variable outside of loop

value_set.add(v)

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

Errors in unit tests

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'

Add not immediate lhs and rhs typing

  • - Not immediate lhs typing helps to define more abstract typing of a pattern to match (to loosen the constraints)
  • - Not immediate rhs typing allows to force propagation 'downwards'

Recurring error in unit tests

ERROR: test_primitives.TestPrimitives.test_set_edge

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

Typing of a rule (+ changes in the typing of a rewritten graph)

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?)

Not compatible with latest version of Neo4j driver

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.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.