Skip to content

Define correct type string for CalcJobNode instances#2376

Merged
sphuber merged 1 commit into
aiidateam:provenance_redesignfrom
sphuber:fix_1603_plugin_loader
Jan 10, 2019
Merged

Define correct type string for CalcJobNode instances#2376
sphuber merged 1 commit into
aiidateam:provenance_redesignfrom
sphuber:fix_1603_plugin_loader

Conversation

@sphuber
Copy link
Copy Markdown
Contributor

@sphuber sphuber commented Jan 9, 2019

The type string of a CalcJobNode should now be just that of the
node 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 type column of the node,
should be used to load the CalcJobNode class when loading from
the database. 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.

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.
@sphuber sphuber requested a review from giovannipizzi January 9, 2019 17:44
@coveralls
Copy link
Copy Markdown

coveralls commented Jan 9, 2019

Coverage Status

Coverage decreased (-0.005%) to 69.026% when pulling 9baed10 on sphuber:fix_1603_plugin_loader into dd0b1b9 on aiidateam:provenance_redesign.

@sphuber sphuber merged commit 1e339c3 into aiidateam:provenance_redesign Jan 10, 2019
@sphuber sphuber deleted the fix_1603_plugin_loader branch January 10, 2019 07:09
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