Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem creating graph from existing edge collections #223

Open
pedrocassalpacheco opened this issue Mar 11, 2022 · 2 comments
Open

Problem creating graph from existing edge collections #223

pedrocassalpacheco opened this issue Mar 11, 2022 · 2 comments

Comments

@pedrocassalpacheco
Copy link

Code:
networks = ["co", "mg", "ne", "no", "rj", "sul"]
edges = []

for network in networks:
edges_collection_name = network + "_edges"
node_collection_name = network + "_routers"
print
edges.append(EdgeDefinition(edges_collection_name, fromCollections=[node_collection_name], toCollections=[node_collection_name]))

class RSNac1(Graph) :
_edgeDefinitions = edges
_orphanedCollections = []

theGraph = db.createGraph("RSNac1", createCollections=True)

Output:

ValueError Traceback (most recent call last)
in
16 _orphanedCollections = []
17
---> 18 theGraph = db.createGraph("RSNac1", createCollections=True)

/opt/anaconda3/lib/python3.8/site-packages/pyArango/database.py in createGraph(self, name, createCollections, isSmart, numberOfShards, smartGraphAttribute, replicationFactor, writeConcern)
159 for e in graphClass._edgeDefinitions:
160 if not COL.isEdgeCollection(e.edgesCollection):
--> 161 raise ValueError("'%s' is not a defined Edge Collection" % e.edgesCollection)
162 _checkCollectionList(e.fromCollections)
163 _checkCollectionList(e.toCollections)

ValueError: 'co_edges' is not a defined Edge Collection

Data:
db.collections["co_edges"]
ArangoDB collection name: co_edges, id: 6814744, type: edge, status: loaded

What have I tried:
Used example to create collections and graphs. Collections and graphs use class templates. Works
Used the code above where the collection (edge and node) are already on the database. Not that error is a false negavite. The collection is an edge collection

@tariqdaouda
Copy link
Collaborator

Have you checked in the GUI that all edge definitions are the same as is in the python definition?
It seems that you are referencing an edge collection named "co_edges" that was not created before hand (i.e. not present in the database).

Also you cannot change definitions once the graph is created in ArangoDB.
If you add and edge collection to the code after the creation of the graph, that edge collection will not be added to the graph definition in ArangoDB.

@pedrocassalpacheco
Copy link
Author

Yes, I did. Unless the collections are created by the code, the COL.isCollection (or something like that fails) albeit the collection exists. Just so I could finish what I was working on, I simply removed the checks and it worked.

for e in graphClass._edgeDefinitions:
#if not COL.isEdgeCollection(e.edgesCollection):
# raise ValueError("'%s' is not a defined Edge Collection" % e.edgesCollection)
#_checkCollectionList(e.fromCollections)
#_checkCollectionList(e.toCollections)
I know, I hacked it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants