Skip to content

Final reorganization of the aiida.orm.node module#2497

Merged
sphuber merged 3 commits into
aiidateam:provenance_redesignfrom
sphuber:fix_2490_node_to_nodes
Feb 16, 2019
Merged

Final reorganization of the aiida.orm.node module#2497
sphuber merged 3 commits into
aiidateam:provenance_redesignfrom
sphuber:fix_2490_node_to_nodes

Conversation

@sphuber
Copy link
Copy Markdown
Contributor

@sphuber sphuber commented Feb 16, 2019

Fixes #2490

This completes the final step in the refactoring of the Node classes and the aiida.orm.node module.
The aiida.orm.node module is renamed to aiida.orm.nodes in accordance with the rest of the orm module. 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.tools module.

Finally, a last data migration has been added to remove the node. prefix from all node type strings.

Copy link
Copy Markdown
Member

@giovannipizzi giovannipizzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...).

@sphuber sphuber force-pushed the fix_2490_node_to_nodes branch from 4337a7e to 7000ea4 Compare February 16, 2019 15:08
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.`
@sphuber sphuber force-pushed the fix_2490_node_to_nodes branch from 7000ea4 to 93ff14e Compare February 16, 2019 15:50
@coveralls
Copy link
Copy Markdown

coveralls commented Feb 16, 2019

Coverage Status

Coverage decreased (-0.02%) to 70.003% when pulling 93ff14e on sphuber:fix_2490_node_to_nodes into 1ed73d8 on aiidateam:provenance_redesign.

@sphuber sphuber merged commit 6791557 into aiidateam:provenance_redesign Feb 16, 2019
@sphuber sphuber deleted the fix_2490_node_to_nodes branch February 16, 2019 18:49
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

Successfully merging this pull request may close these issues.

3 participants