espeed / bulbs

A Python persistence framework for graph databases like Neo4j, OrientDB and Titan.
http://bulbflow.org
Other
622 stars 83 forks source link

RelationshipProxy instruments wrong API calls #138

Open realoptimal opened 10 years ago

realoptimal commented 10 years ago

e.g.

class Person(Node): ... element_type = "person" ... name = String(nullable=False) ... class Knows(Relationship): ... lable = "knows" ... class Knows(Relationship): ... label = "knows" ... created = DateTime(default=current_timestamp, nullable=False) ... g.add_proxy("person", Person) g.add_proxy("knows", Knows)

james = g.person.create(name="James") POST url: http://10.0.3.139:8182/graphs/emptygraph/vertices POST body: {"element_type": "person", "name": "James"} julie = g.person.create(name="Julie") POST url: http://10.0.3.139:8182/graphs/emptygraph/vertices POST body: {"element_type": "person", "name": "Julie"} g.knows.create(james, julie) POST url: http://10.0.3.139:8182/graphs/emptygraph/edges POST body: {"_label": "knows", "created": 1403798951, "_outV": 15, "_inV": 16} <Knows: http://10.0.3.139:8182/graphs/emptygraph/edges/17>

All good, but now:

g.knows.get_all() GET url: http://10.0.3.139:8182/graphs/emptygraph/vertices?value=knows&key=label GET body: None

Hmm, shouldn't the URI should be a request on edges not vertices?

What about?

g.knows.index.lookup(created=1403798951) GET url: http://10.0.3.139:8182/graphs/emptygraph/vertices?value=1403798951&key=created GET body: None

Again, same thing.

espeed commented 10 years ago

Why do you have two Relationship classes?

Also note in the first Relationship class there is a typo: lable

Here's the code that should get called on g.knows.get_all():

https://github.com/espeed/bulbs/blob/master/bulbs/model.py#L915

For some reason, the index object on the knows Relationship model is being set to a Vertex index instead of an Edge index.

espeed commented 10 years ago

Is this resolved?

realoptimal commented 10 years ago

I don't think so -- as you said index object on the knows Relationship model is being set to a Vertex index instead of an Edge index. Since I am not explicitly creating any indexes on model properties, I assume, all properties are indexed. Why shouldn't this return all knows Relationship objects?

espeed commented 10 years ago

The knows object should be hitting the http://10.0.3.139:8182/graphs/emptygraph/edges endpoint for get_all() and index lookup() -- in the code snippet you have two Knows classes, and the first one has a typo for label -- would you mind posting the complete example to a Gist (imports and all) so I can try to reproduce the issue?

realoptimal commented 10 years ago

Yes, sorry, should have done that from the start: https://gist.github.com/realoptimal/d5fe0b566b6eb50165e8

and emptygraph is for me an hbase backed titan-db with configuration in rexster.xml as:

        <graph>
            <graph-enabled>true</graph-enabled>
            <graph-name>emptygraph</graph-name>
            <graph-type>com.thinkaurelius.titan.tinkerpop.rexster.TitanGraphConfiguration</graph-type>
            <graph-read-only>false</graph-read-only>
            <properties>
                <storage.backend>hbase</storage.backend>
                <storage.tablename>titandb_test</storage.tablename>
            </properties>
            <extensions>
                <allows>
                    <allow>tp:gremlin</allow>
                </allows>
            </extensions>
        </graph>