Final reorganization of the aiida.orm.node module#2497
Merged
sphuber merged 3 commits intoFeb 16, 2019
Conversation
giovannipizzi
approved these changes
Feb 16, 2019
Member
giovannipizzi
left a comment
There was a problem hiding this comment.
As we discussed, I think the 'trick' in the second commit should eventually be removed in the code and the migrations should be adapted, but ok to merge for now (I don't think that trick is too dangerous as we should not have anymore nodes with type starting with node., unless there is a big problem in the current logic...).
4337a7e to
7000ea4
Compare
In addition to the move of the node module, the import definitions of the internal modules were cleaned up. This makes it possible to expose all the `Node` sub classes that should be importable by the user, on the top level, i.e. after calling `from aiida import orm` one can access all important node classes directly through the `orm` module. Certain data modules defined top level utility functions to convert the node from its current type into another, often using external libraries such as `ase` and `pymatgen`. These functions typically belong into the `aiida.tools` module. Especially so because these were decorated with the `calcfunction` decorator, requiring the entire `aiida.work` module to be imported when importing the `aiida.orm` module, causing a cyclic dependency. These functions for `cif`, `structure` and `array.trajectory` have been moved to their respective modules within `aiida.tools`.
The `load_node_class` serves to turn a node type string into the corresponding `Node` sub class. This is based on how those type strings are constructed. Currently, they will start either with `data.` or `process.` since the `node.` prefix has been dropped. However, some recent database migrations targeted databases where the `node.` prefix was still present and therefore so did the tests. However, when the migration tests are run, they will do so with the current ORM, which no longer considers type strings starting with `node.` to be valid. To make the migration tests work without changing the migrations themselves, which cannot be done, we need to add an exception in the node class loader for type strings starting with `node.`. By just stripping it, it should once again conform to the current node type spec and the logic can be continued.
Now node type strings will either start with `data.` or `process.`
7000ea4 to
93ff14e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2490
This completes the final step in the refactoring of the
Nodeclasses and theaiida.orm.nodemodule.The
aiida.orm.nodemodule is renamed toaiida.orm.nodesin accordance with the rest of theormmodule. Furthermore, the internal structure of the module has been cleaned such that classes that should be publicly available are now expose on the top level.To prevent circular dependencies, certain utility functions in some data modules have been migrated to the
aiida.toolsmodule.Finally, a last data migration has been added to remove the
node.prefix from all node type strings.