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

Deprecate methods that refer to a computer's label as name #4309

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Aug 19, 2020

Fixes #4304 and fixes #4313

All entities use label as the human readable string identifier, but
Computer was using name. This was already changed in the front-end
ORM in a previous commit where a label property was introduced and
the old name properties were deprecated, however, a few derivative
methods in other classes were missed and still use contain "name".
These methods are now also deprecated:

  • verdi computer rename: use verdi computer relabel instead
  • Code.get_computer_name: use self.computer.label instead
  • Code.get_full_text_info: will be removed
  • RemoteData.get_computer_name: use self.computer.label instead
  • Transport.get_valid_transports: get_entry_point_names instead

Finally, deprecations of Computer getters and setters as introduced
in commit 592dd36 were still being used internally leading to
a lot of deprecation warnings. These have now been properly replaced.

@sphuber sphuber requested a review from ltalirz August 19, 2020 10:16
@sphuber sphuber force-pushed the fix/4304/computer-deprecated-methods branch from 795c49c to 269bc7d Compare August 19, 2020 10:57
All entities use `label` as the human readable string identifier, but
`Computer` was using `name`. This was already changed in the front-end
ORM in a previous commit where a `label` property was introduced and
the old `name` properties were deprecated, however, a few derivative
methods in other classes were missed and still use contain "name".
These methods are now also deprecated:

  * `verdi computer rename`: use `verdi computer relabel` instead
  * `Code.get_computer_name`: use `self.computer.label` instead
  * `Code.get_full_text_info`: will be removed
  * `RemoteData.get_computer_name`: use `self.computer.label` instead
  * `Transport.get_valid_transports`: `get_entry_point_names` instead

Finally, deprecations of `Computer` getters and setters as introduced
in commit 592dd36 were still being used internally leading to
a lot of deprecation warnings. These have now been properly replaced.
@sphuber sphuber force-pushed the fix/4304/computer-deprecated-methods branch from 269bc7d to 3480c48 Compare August 19, 2020 11:30
@codecov
Copy link

codecov bot commented Aug 19, 2020

Codecov Report

Merging #4309 into develop will decrease coverage by 0.18%.
The diff coverage is 76.86%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4309      +/-   ##
===========================================
- Coverage    79.22%   79.04%   -0.17%     
===========================================
  Files          468      468              
  Lines        34556    34602      +46     
===========================================
- Hits         27373    27348      -25     
- Misses        7183     7254      +71     
Flag Coverage Δ
#django 72.66% <76.86%> (-0.16%) ⬇️
#sqlalchemy 71.85% <76.86%> (-0.16%) ⬇️

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

Impacted Files Coverage Δ
aiida/cmdline/commands/cmd_calcjob.py 68.80% <0.00%> (ø)
aiida/engine/daemon/execmanager.py 62.55% <ø> (ø)
aiida/engine/processes/calcjobs/calcjob.py 82.02% <ø> (ø)
aiida/orm/nodes/data/remote.py 58.52% <0.00%> (-1.06%) ⬇️
aiida/transports/transport.py 63.23% <0.00%> (-2.06%) ⬇️
aiida/orm/authinfos.py 84.00% <33.34%> (ø)
aiida/tools/visualization/graph.py 82.36% <50.00%> (ø)
aiida/cmdline/commands/cmd_code.py 88.61% <69.24%> (-2.55%) ⬇️
aiida/orm/computers.py 68.23% <83.34%> (-12.48%) ⬇️
aiida/cmdline/commands/cmd_computer.py 78.91% <87.81%> (+1.16%) ⬆️
... and 10 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 f250a04...b088edf. Read the comment docs.

Copy link
Member

@ramirezfranciscof ramirezfranciscof left a comment

Choose a reason for hiding this comment

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

Lookin' good! I only have one design question and one random comment, but feel free to merge.



@verdi_computer.command('rename')
@arguments.COMPUTER()
@arguments.LABEL('NEW_NAME')
@deprecated_command("This command has been deprecated. Please use 'verdi computer relabel' instead.")
Copy link
Member

Choose a reason for hiding this comment

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

Completely unrelated, but should we maybe have @deprecated_command automatically append the "This command has been deprecated" text to the string passed through, so it is not necessary to include that part each time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would certainly be an option, although low priority I would say. Usually you copy this line from some other place anyway so it is already there.

@@ -168,7 +168,36 @@ def code_duplicate(ctx, code, non_interactive, **kwargs):
@with_dbenv()
def show(code, verbose):
"""Display detailed information for a code."""
click.echo(tabulate.tabulate(code.get_full_text_info(verbose)))
Copy link
Member

Choose a reason for hiding this comment

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

So, can I ask what is the intended purpose of the commands show and computer_show modified in this PR? Because I'm not sure I understand why you are removing the general get_full_text_info method to implement two relatively similar versions directly into each of those commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that one is verdi code show and the other verdi computer show. I removed the methods from the classes because they don't really belong there. Especially the Computer one was bad since it was baking in the formatting. It was returning a string fully formatted. This is really inflexible as the caller cannot do anything to modify it. The Code one is already slightly better since it simply returned a list of tuples. Still I think deciding what information should be displayed is still very situation dependent and so there is no need to have a dedicated method for this. It was no wonder that the methods were also just used in one place, namely the show CLI commands. Might as well put that logic there so it has all the freedom it needs to choose what and how to display the information

Copy link
Member

@ramirezfranciscof ramirezfranciscof Aug 20, 2020

Choose a reason for hiding this comment

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

Ah, I see, I didn't notice these were methods of different classes. Thanks!

@sphuber sphuber merged commit e8d5e76 into aiidateam:develop Aug 20, 2020
@sphuber sphuber deleted the fix/4304/computer-deprecated-methods branch August 20, 2020 15:29
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.

Coordinate text between code and computer setting up new computer raises deprecation warnings
2 participants