-
Notifications
You must be signed in to change notification settings - Fork 203
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
looking for nodes inside Groups #3523
Comments
Daniele mentions it would also be useful to be able to generate graphs from nodes in a group, which would become available e.g. via #3436 |
Re adding flags to Re "I load a group but then how can I easily address nodes within that group, e.g. by uuid/id/label (if unique)/extra (if unique)..." I think now the way is via the query builder. Also here, a suggestion of how you'd like to see this working would be useful. Maybe discussion could be joined with #3535 (more focused on nodes, but also here one could have a short syntax QueryBuilder().append(Group, filters={'id': group.pk}).append(Node, filters={'extras.volume': {'<': 10}}, project='*') so you can order, do .all(), .limit(), ... Shorthand notations could be I think the general question is is this way I'm suggesting of shortening the queries is eventually useful or more confusing - users' opinions would be very appreciated - as well as different easy but general ways of having easy queries |
I guess you mean If the field is not present, we need some indication (but no exception).
Adding a shorthand for the QueryBuilder may be useful (I agree that one has to make sure it's not too confusing). However, this comes at the cost of a query. In our example, we know the nodes we need for a particular visualization and have put them into a group. Currently we are constructing this dictionary manually by looping over |
Well, you do that with a query similar to the one I wrote before, putting appropriate projections, no? This would do a single query. |
You're right - something like this: def group_dict(group, attribute='id'):
"""Return dictionary of nodes inside group.
Nodes can be addressed by any attribute shared by all nodes in the group.
Note: This does a single query, and is therefore more performant than first loading all nodes and then reading their extras (=1 query per node).
"""
qb=QueryBuilder().append(Group, filters={'id': group.pk})
qb.append(Node, project=[attribute, '*'])
res = qb.all()
return { k: v for k,v in res } We could make this function a bit more clever (e.g. to return only the nodes that have the specified attribute) and think about whether it is worth including in AiiDA, perhaps even on the I think using groups as "folders" is an important use case, and this is a first step towards addressing it. |
Groups are a powerful tool for organising data in AiiDA - they can be created after the fact, modified, and they don't pollute the provenance.
One use case we have at the LSMO is to select data for visualizations (e.g. Materials Cloud DISCOVER sections), where they can replace multiple complicated (time-consuming) queries.
Groups have one downside, though: it can be difficult to find the node you are looking for in a group.
Here is an example:
Obviously, it can be difficult to understand which node to pick here.
How about adding
label
This could address the issue on the command line.
Then, there is a related issue in the python API - I load a group but then how can I easily address nodes within that group, e.g. by uuid/id/label (if unique)/extra (if unique)...?
Mentioning @giovannipizzi for comment
Mentioning @danieleongari for info
The text was updated successfully, but these errors were encountered: