DLR-SC / corpus-annotation-graph-builder

Corpus Annotation Graph builder (CAG) is an architectural framework that employs the build-and-annotate pattern for creating a graph.
MIT License
10 stars 1 forks source link

Edge creation doesn't check edge definition #19

Closed muelldlr closed 1 year ago

muelldlr commented 1 year ago

In the process of working on #18 I noticed that I can create edges between collections even though they do not occur _edge_definitions. Is this intentional? But then _edge_definitions would have no purpose. Please take a look at test_edge_cases for that. Then it should be clear what I mean.

roxanneelbaff commented 1 year ago

if arangoDB allows this behavior, then it is doable. Please elaborate with an example. The Edge is defined in your class but not defined as part of a relation?

roxanneelbaff commented 1 year ago

Please provide a link to test_edge_cases

muelldlr commented 1 year ago

See https://github.com/DLR-SC/corpus-annotation-graph-builder/blob/cf473980e183ba4e1e302316d8e305a41ddbf43e/tests/test_graph_creator/test_simple_init.py#L119

The relation is defined as:

{
            "relation": "HasRelation",
            "from_collections": [CollectionA._name],
            "to_collections": [CollectionB._name],
}

But in this case, I add a Relation to an Collection, which is not defined above:

node = gc.upsert_node(
    CollectionC._name,
    {"value": "val1", "value2": "no change", "_key": "v1"},
)
edge = gc.upsert_edge("HasRelation", node, node)
muelldlr commented 1 year ago

if arangoDB allows this behavior, then it is doable.

I thought about it some more. I would be in favor of checking that out. _edge_definitions should be a kind of contract which relations exist and which collections may be connected to each other and how. Should someone not adhere to it, it is not really noticeable at the present time and others then may wonder why this relation exists at all.

roxanneelbaff commented 1 year ago

yes I see your point. CAG should not restrict the freedom that ArangoDB offers - This is why it is okay to have this behavior.

muelldlr commented 1 year ago

All right understood, then I close the ticket