Replies: 6 comments 13 replies
-
|
Thanks for summarising @sphuber, obviously I can adapt #5439, #5442, #5445 and #5446 to these, when agreed on. Some initial responses:
yes
It is used, in
I would just note that this is not facile, since with static analysis it's not foolproof to identify instances of Some initial notes:
|
Beta Was this translation helpful? Give feedback.
-
|
Also to note, for |
Beta Was this translation helpful? Give feedback.
-
|
For the actual implementation, you would do something like: from functools import cached_property
class NodeAttributes:
def __init__(self, node):
self._node = node
def get(self, key):
return self._node.backend_entity.get_attribute(key)
class NodeContext:
def __init__(self, node):
self._node = node
@cached_property
def attributes(self):
return NodeAttributes(self._node)
class Node:
@cached_property
def ctx(self):
return NodeContext(self)You'll note, this means you now have to initialise more objects than just the |
Beta Was this translation helpful? Give feedback.
-
|
First I should mention that I am fully on board with tidying up method namespace of Nodes - it is a nuisance in everyday use and great to see this being tackled. In deciding which methods to keep at the top-level and which to group under sub-namespaces, however, I think besides architectural considerations we should consider which methods are most often used interactively. We could at some point try come up with some sort of statistics, e.g. looking at our tutorial material, but short of that my feeling is that
While the database layout may differ, I think most AiiDA users will consider attributes and extras "properties of the node". Rather than proposing a full layout, here is my list of methods that I believe should remain at the top level of the node in order to avoid unnecessary typing (more can be added for consistency reasons): |
Beta Was this translation helpful? Give feedback.
-
|
Putting attributs/extras aside for a moment, after reading
I expected the That would lead me to an arrangement like (just showing what changes): Just pointing this out as another possible grouping. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks, I agree with the division and the following concepts (e.g. rename objects to collection). Only important comment for me is: I wouldn't use the name I'm not sure of a good suggestion, but I think it should not be |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The
Nodeclass has many methods and attributes in its public namespace. This has been noted as being a problem for users of an interactive shell as it makes it difficult to find what they are looking for and to intuit what is supposed to be part of the public API. Here is a suggestion for reorganizing the namespace byThe main idea is to take all methods that are not directly relevant to the properties of the node itself, but rather have to do with its context in the provenance graph, and move them to a nested namespace. For the sake of argument, let's call this namespace
basefor now. Any methods that are related can be grouped into further sub-namespaces where appropriate. With this approach the top level namespace should be significantly de-cluttered. One potential downside of moving methods from the top-namespace to sub-namespaces is that discoverability may be slightly reduced. Users will now have to "know" for example to go toNode.base.attributes.getto get an attribute. Still the changes may be a net gain in terms of clarity and user friendliness.Below is a table with the proposed name changes for each currently public attribute and method:
CollectionNodeCollectiondirectlyadd_commentNode.base.comments.addadd_incomingNode.base.links.add_incomingattributesNode.base.attributes.allattributes_itemsNode.base.attributes.itemsattributes_keysNode.base.attributes.keysbackendbackend_entitycheck_mutabilityNode._check_mutability_attributesclass_node_typeclear_attributesNode.base.attributes.clearclear_extrasNode.base.extras.clearclear_hashNode.base.caching.clear_hashcomputercopy_treeNode.base.repository.copy_treectimedelete_attributeNode.base.attributes.deletedelete_attribute_manyNode.base.attributes.delete_manydelete_extraNode.base.extras.deletedelete_extra_manyNode.base.extras.delete_manydelete_objectNode.base.repository.delete_objectdescriptioneraseNode.base.repository.eraseextrasNode.base.extras.allextras_itemsNode.base.extras.itemsextras_keysNode.base.extras.keysfrom_backend_entitygetNode.objects.getget_all_same_nodesNode.base.caching.get_all_same_nodesget_attributeNode.base.attributes.getget_attribute_manyNode.base.attributes.get_manyget_cache_sourceNode.base.caching.get_cache_sourceget_commentNode.base.comments.getget_commentsNode.base.comments.allget_descriptiondescriptionproperty that just fetches the similarly named column from the database mode. Might require a name change for clarity.get_extraNode.base.extras.getget_extra_manyNode.base.extras.get_manyget_hashNode.base.caching.get_hashget_incomingNode.base.links.get_incomingget_objectNode.base.repository.get_objectget_object_contentNode.base.repository.get_object_contentget_outgoingNode.base.links.get_outgoingget_stored_link_triplesNode.base.links.get_stored_link_triplesglobNode.base.repository.globhas_cached_linksexecmanager.upload_calculationandCalcJob.presubmit, should essentially be replaced withis_storedbecause in that case all links should be stored and the cache is empty.)idpkinsteadinitializeis_created_from_cacheNode.base.caching.is_created_from_cacheis_storedis_valid_cacheNode.base.caching.is_valid_cachelabellist_object_namesNode.base.repository.list_object_nameslist_objectsNode.base.repository.list_objectsloggermtimenode_typeobjectscollectionopenNode.base.repository.openpkprocess_typeput_object_from_fileNode.base.repository.put_object_from_fileput_object_from_filelikeNode.base.repository.put_object_from_filelikeput_object_from_treeNode.base.repository.put_object_from_treerehashNode.base.caching.rehashremove_commentNode.base.comments.removerepository_metadataNode.base.repository.metadatarepository_serializeNode.base.repository.serializereset_attributesNode.base.attributes.resetreset_extrasNode.base.extras.resetset_attributeNode.base.attributes.setset_attribute_manyNode.base.attributes.set_manyset_extraNode.base.extras.setset_extra_manyNode.base.extras.set_manystorestore_allupdate_commentNode.base.comments.updateuseruuidvalidate_incomingNode.base.links.validate_incomingvalidate_outgoingNode.base.links.validate_outgoingvalidate_storabilityNode._validate_storabilityverify_are_parents_storedNode._verify_are_parents_storedwalkNode.base.repository.walkIf these changes were to be adopted, this would be the resulting namespace:
If we can agree on the new naming, the idea would be to get this in
v2.0in a backwards-compatible way. Deprecation warnings could potentially be hidden by default and enabled with a config option or environment variable (see this PR for details). With the development ofaiida-upgradewe can even automate the update of existing code. These kinds of changes would be easy to implement inaiida-upgradeso the change should be relatively painless for users.Beta Was this translation helpful? Give feedback.
All reactions