Further simplification of node type string definition and loading#2401
Merged
giovannipizzi merged 1 commit intoJan 19, 2019
Merged
Conversation
54e8082 to
5a26753
Compare
With the recent introduction of the `CalcJob` process, which no ensures that also for job calculations, it is the `CalcJobNode` that gets stored in the database, which has a type string just like all the other node types. This made a lot of the old logic `aiida.plugins.loader` to determine the correct `type` string for a `Node` (sub) class obsolete as now all node classes are per definition internal to `aiida-core` and have a type string that is based directly on their module path. The few functions that remain, `get_type_string_from_class` that formats the correct type string for a given `Node` class and the `load_node_class` which can reload that class from the string have been moved to `aiida.orm.utils.node` since it has no longer anything to do with a "plugin". Finally, by moving the `WorkflowNode`, `CalculationNode` and `ProcessNode` classes in the `__init__` files of their respective modules allows us to add further simplification to `load_node_class` as well as making all these classes and their subclasses importable from the `aiida.orm.node` module. Eventually, when `aiida.orm.data` is also moved there, all classes can even be exposed directly on `aiida.orm` and that is the deepest a user should ever go for they should need or be allowed to import.
5a26753 to
542a3b6
Compare
Contributor
Author
|
@giovannipizzi this is ready to go. You should check |
giovannipizzi
approved these changes
Jan 19, 2019
| try: | ||
| base_path = type_string.rsplit('.', 2)[0] | ||
| except ValueError: | ||
| raise exceptions.MissingPluginError |
Member
There was a problem hiding this comment.
In a next PR we should put a message to this exception
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 #1603
With the recent introduction of the
CalcJobprocess, which no ensuresthat also for job calculations, it is the
CalcJobNodethat gets storedin the database, which has a type string just like all the other node
types. This made a lot of the old logic
aiida.plugins.loadertodetermine the correct
typestring for aNode(sub) class obsolete asnow all node classes are per definition internal to
aiida-coreandhave a type string that is based directly on their module path.
The few functions that remain,
get_type_string_from_classthat formatsthe correct type string for a given
Nodeclass and theload_node_classwhich can reload that class from the string have beenmoved to
aiida.orm.utils.nodesince it has no longer anything to dowith a "plugin".
Finally, by moving the
WorkflowNode,CalculationNodeandProcessNodeclasses in the__init__files of their respectivemodules allows us to add further simplification to
load_node_classaswell as making all these classes and their subclasses importable from
the
aiida.orm.nodemodule. Eventually, whenaiida.orm.datais alsomoved there, all classes can even be exposed directly on
aiida.ormandthat is the deepest a user should ever go for they should need or be
allowed to import.