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

Graph traversals using QueryBuilder #3535

Closed
lekah opened this issue Nov 11, 2019 · 4 comments
Closed

Graph traversals using QueryBuilder #3535

lekah opened this issue Nov 11, 2019 · 4 comments

Comments

@lekah
Copy link
Contributor

lekah commented Nov 11, 2019

A long time ago in a galaxy far far away we discussed the possibility of having an additional tool for graph traversal queries using the QueryBuilder, as in:
node = load_node() node.qb.incoming(filters={}, project=...).outgoing(filters={}, project=....).all() # get all outgoing of all incoming of node
This functionality existed before in a very preliminary state (undocumented and untested). Some of it disappeared (see #3526). If we want this functionality as a quick way to traverse a graph around a given entry, we should properly add this light-weight feature based on the newest naming conventions and supply tests and documentation. If this functionality is not wanted, we have to remove some legacy functions in the QB. @sphuber @giovannipizzi @CasperWA @ltalirz

@sphuber
Copy link
Contributor

sphuber commented Nov 11, 2019

A (large) part of what you describe all ready exists and is provided by the get_incoming and get_outgoing methods of the Node class. They support filtering on link labels and types and node types of neighboring nodes. Not sure what else you had in mind, but based on your example, that only excludes the projection and filtering on node "properties". There is a primitive form of projection as there is a keyword only_uuid to only project UUIDs. I am not sure that we should add even more functionality at the risk of the methods becoming too unwieldy but if there are concrete use-cases, I'd be happy to discuss of course.

@lekah
Copy link
Contributor Author

lekah commented Nov 11, 2019

Yes, you can do this at the first level, i.e, node.get_incoming().all(). But if you want the incoming of the incoming, there is no quick way, as far as I know at least, other than expanding the list ([i.get_coming().all() for i in node.get_incoming().all()]).
The goal was to have something that works recursively, as in node.incoming.incoming -> incoming of incoming of node (and imagine there are several incoming at every layer).
This could also be put into the LinkManager class, but using the QueryBuilder under the hood could add functionality since the LinkManager allows few and basic projections and filters.

@giovannipizzi
Copy link
Member

I think that we should clarify the goal (for me: writing faster common qb queries) and in this case it would be nice to see a couple of commands where writing with the new syntax is a big advantage than writing a qb from scratch (that for novice users takes some time).
I.e., write it a one-liner in a shell rather than opening an editor an writing a multiline qb code to then run.

Also, if the purpose is solely to reduce typing (which I think that by itself is a noble goal to attract users), should we then decide these commands are really shortcuts, and e.g. use f= for filters, p= for projections, .i for incoming etc.?

@lekah
Copy link
Contributor Author

lekah commented Apr 1, 2020

A new Graph Traversal tool was added to AiiDA (#3686), solving this ussue or making it obsolete

@lekah lekah closed this as completed Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants