Define correct type string for CalcJobNode instances#2376
Merged
sphuber merged 1 commit intoJan 10, 2019
Conversation
The correct node sub class that should be used to load a node from the
database is determined by the type string stored in the type column. The
only classes that can legally exist in a database, and therefore be
loaded, are defined in `aiida-core`. Therefore, using the entry point
system to map the type string onto an actual ORM class is no longer
necessary. We rename the `aiida.plugins.loader.load_plugin` function to
the more correct `load_node_class`, which given a type string, will
return the corresponding ORM node sub class.
Note that the whole machinery around generating type and query strings
and loading the nodes based on them is still somewhat convoluted and
contains hacks for two reasons:
1) Data is not yet moved within the `aiida.orm.node` sub module and as
a result gets the `data.Data.` type string, which will not match the
`node.Node.` type when sub classing in queries.
2) CalcJobProcesses are defined by sub classing JobCalculation
Until the user directly define a Process sub class that uses the
`CalcJobNode` as its node class, exceptions will have to be made.
If these two issues are addressed, a lot of the code around type strings
can be simplified and cleaned up.
giovannipizzi
approved these changes
Jan 9, 2019
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.
The type string of a
CalcJobNodeshould now be just that of thenode class and not the sub class. Since the users are currently still
sub classing the node class and not a process class, we have to make
a special exception when generating the type string for the node.
Conversely, this type string, stored in the
typecolumn of the node,should be used to load the
CalcJobNodeclass when loading fromthe database. The only classes that can legally exist in a database, and
therefore be loaded, are defined in
aiida-core. Therefore, using theentry point system to map the type string onto an actual ORM class is no
longer necessary. We rename the
aiida.plugins.loader.load_pluginfunction to the more correct
load_node_class, which given a type string,will return the corresponding ORM node sub class.
Note that the whole machinery around generating type and query strings
and loading the nodes based on them is still somewhat convoluted and
contains hacks for two reasons:
Data is not yet moved within the
aiida.orm.nodesub module and asa result gets the
data.Data.type string, which will not match thenode.Node.type when sub classing in queries.CalcJobProcesses are defined by sub classing JobCalculation
Until the user directly define a Process sub class that uses the
CalcJobNodeas its node class, exceptions will have to be made.If these two issues are addressed, a lot of the code around type strings
can be simplified and cleaned up.