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

Rename name column of Computer database table to label #4882

Merged
merged 2 commits into from
Apr 29, 2021

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Apr 28, 2021

Fixes #2926

All other database models already use label so using the same for the
Computer model is more consistent. The name attribute was already
deprecated in the ORM in aiida-core==1.0.0 and replaced by label.
Here we apply the actual database migration to also perform the change
in the database models.

@sphuber sphuber added the pr/blocked PR is blocked by another PR that should be merged first label Apr 28, 2021
@sphuber
Copy link
Contributor Author

sphuber commented Apr 28, 2021

I started the deprecation path for this change in v1.0.0 by adding label in our front-end ORM and raising deprecation warnings when name was used. However, we could not provide a deprecation path for all uses. Most notably, when using the QueryBuilder one had to continue to use name when specifying it in the filters or projections. The same goes for the REST API, where name is still being used. With this PR, the database tables are updated to use label and the final remnants of name are removed. This does mean, however, that this will break code that manually uses the QueryBuilder to query for computers and filter or project on name, so this could be an argument to not merge these changes.

However, on the other hand, currently there is an inconsistency where in the ORM one has to use label whereas in the REST API and QB one should use name. By merging these changes, we get rid of this inconsistency.

@sphuber sphuber force-pushed the fix/2926/computer-name-to-label branch from 19ad33a to 00ecb44 Compare April 29, 2021 06:22
@codecov
Copy link

codecov bot commented Apr 29, 2021

Codecov Report

Merging #4882 (2d14abf) into develop (c7897c5) will increase coverage by 0.02%.
The diff coverage is 87.63%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4882      +/-   ##
===========================================
+ Coverage    80.08%   80.10%   +0.02%     
===========================================
  Files          514      517       +3     
  Lines        36576    36617      +41     
===========================================
+ Hits         29288    29327      +39     
- Misses        7288     7290       +2     
Flag Coverage Δ
django 74.57% <58.77%> (-0.02%) ⬇️
sqlalchemy 73.51% <65.98%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aiida/backends/sqlalchemy/models/authinfo.py 88.47% <0.00%> (ø)
aiida/orm/implementation/computers.py 68.43% <ø> (ø)
aiida/orm/implementation/django/convert.py 75.87% <ø> (ø)
aiida/backends/djsite/db/models.py 81.40% <25.00%> (ø)
aiida/backends/sqlalchemy/models/computer.py 92.31% <50.00%> (ø)
aiida/orm/implementation/sqlalchemy/computers.py 76.25% <66.67%> (ø)
aiida/orm/computers.py 81.42% <80.00%> (+0.17%) ⬆️
aiida/orm/implementation/django/computers.py 77.78% <80.00%> (ø)
...ools/importexport/archive/migrations/v11_to_v12.py 88.89% <88.89%> (ø)
...jsite/db/migrations/0048_computer_name_to_label.py 100.00% <100.00%> (ø)
... and 18 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c7897c5...2d14abf. Read the comment docs.

@sphuber sphuber force-pushed the fix/2926/computer-name-to-label branch from 00ecb44 to 1e53cc9 Compare April 29, 2021 08:40
All other database models already use `label` so using the same for the
`Computer` model is more consistent. The `name` attribute was already
deprecated in the ORM in `aiida-core==1.0.0` and replaced by `label`.
Here we apply the actual database migration to also perform the change
in the database models.

A new migration is also added for existing archives as the metadata
needs to update the key `name` to `label` for the `Computer` entity and
the data needs to be updated as well.
@sphuber sphuber force-pushed the fix/2926/computer-name-to-label branch from 1e53cc9 to 48c2c0b Compare April 29, 2021 08:46
@sphuber sphuber removed the pr/blocked PR is blocked by another PR that should be merged first label Apr 29, 2021
@sphuber
Copy link
Contributor Author

sphuber commented Apr 29, 2021

@ramirezfranciscof @chrisjsewell this is now ready for review

@sphuber sphuber requested a review from ltalirz April 29, 2021 14:43
Copy link
Member

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

thanks @sphuber !

I went through the files and the changes all look fine.
It's a pity that we we could not do a deprecation for the querybuilder and the REST API, so some people might run into issues, but this change needs to happen and it should happen in 2.0.

I notice that the file tests/static/graphs/graph1.aiida was deleted - was this just no longer needed?

'display_name': 'Name',
'help_text': 'Name of the object',
'label': {
'display_name': 'Label',
Copy link
Member

Choose a reason for hiding this comment

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

to be fully consistent, one might argue that display_name should become display_label.
but I'm ok with keeping this inconsistency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I notice that the file tests/static/graphs/graph1.aiida was deleted - was this just no longer needed?

It wasn't deleted, it was just migrated since it needed to also perform the name -> label change in the archive. Due to the new archive format that is already there, the size was just reduced.

@ltalirz ltalirz self-requested a review April 29, 2021 15:36
@sphuber sphuber merged commit 975affe into aiidateam:develop Apr 29, 2021
@sphuber sphuber deleted the fix/2926/computer-name-to-label branch April 29, 2021 15:48
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.

Rename name column of Computer to label
2 participants