Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Code a real sub class of Data #2193

Conversation

ConradJohnston
Copy link
Contributor

Fixes #2173 .
Subclasses Code from Data rather than Node, and simplifies places in the code where code had to be treated as a 'special' data-like node.

Simplify code where nodes have had to be treated as either Code type or Data type.
@sphuber sphuber force-pushed the Fix_2173_make_code_real_subclass_of_data branch 3 times, most recently from 3323169 to c378d01 Compare November 13, 2018 21:33
@sphuber sphuber changed the title Fix 2173 make code real subclass of data Make Code a real sub class of Data Nov 13, 2018
@coveralls
Copy link

coveralls commented Nov 13, 2018

Coverage Status

Coverage decreased (-0.008%) to 67.547% when pulling 2c2fbc8 on ConradJohnston:Fix_2173_make_code_real_subclass_of_data into 1461883 on aiidateam:provenance_redesign.

By making `Code` a proper sub class of `Data` instead of `Node`, its type string
is also changed from `code.Code.` to `data.code.Code.` so we add a migration to
update these for existing databases.

In addition, the `aiida:code` plugin group no longer makes sense and so the entry
point for the `Code` class is moved to `aiida.data:code`. The entity loaders and
`QueryBuilder` will now do the right thing after updating the entry point loader
logic to treat `Code` as a sub class of `Data`.

Finally, the `Code` class no longer needed any backend specific code, so the
`AbstractCode` class is made concrete, moved to `aiida.orm.data.code` and the
backend specific implementations are removed.
@sphuber sphuber force-pushed the Fix_2173_make_code_real_subclass_of_data branch from c378d01 to 2c2fbc8 Compare November 13, 2018 21:55
@sphuber
Copy link
Contributor

sphuber commented Nov 13, 2018

@giovannipizzi @muhrin this is now ready for review. @ConradJohnston requested me, but since I have now changed a significant portion as well, I think it is a good idea if one of you has a gander. I have made the code class concrete by removing the remaining backend dependent methods and moved it to aiida.orm.data.code. This was necessary anyway to prevent crazy cyclic import dependencies. In addition, I removed the aiida.code entry point group and added aiida.data:code inline with the ORM class inheritance. To finally make everything work, I put in a migration to update the type string for code nodes to from code.Code. to data.code.Code.

Copy link
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.

Fantastic!


if qb.count() == 0:
raise NotExistent("'{}' is not a valid code "
"name.".format(label))
raise NotExistent("'{}' is not a valid code " "name.".format(label))
Copy link
Member

Choose a reason for hiding this comment

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

There are a few of " " around, I guess after yapf, that could be fixed, maybe in a different PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I will make a note, we can do one great sweep at the end of this project

@sphuber sphuber merged commit 2f1b74a into aiidateam:provenance_redesign Nov 13, 2018
@ConradJohnston
Copy link
Contributor Author

Nice one @sphuber , thank you!

@ConradJohnston ConradJohnston deleted the Fix_2173_make_code_real_subclass_of_data branch November 21, 2018 15:23
@sphuber sphuber mentioned this pull request Dec 3, 2018
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.

4 participants