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

verdi code setup: validate the uniqueness of label for local codes #5215

Merged

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Nov 2, 2021

In commit d25339d verdi code setup
was improved to have a callback for the label option to check for its
uniqueness. However, it only implemented this for "remote" computers,
which have an associated Computer and so the uniqueness criterion is
on the "full label", which is the label@computer.label.

However, there are also "local" codes, which don't have an associated
computer and so only have the label as the identifier that should be
unique. The callback validate_label_uniqueness is now updated to
distinguish between these two cases.

@codecov
Copy link

codecov bot commented Nov 2, 2021

Codecov Report

Merging #5215 (f85d029) into develop (f8d1615) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5215      +/-   ##
===========================================
+ Coverage    81.23%   81.23%   +0.01%     
===========================================
  Files          533      533              
  Lines        37345    37356      +11     
===========================================
+ Hits         30332    30343      +11     
  Misses        7013     7013              
Flag Coverage Δ
django 76.11% <100.00%> (+0.01%) ⬆️
sqlalchemy 75.19% <100.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
aiida/cmdline/params/options/commands/code.py 100.00% <100.00%> (ø)

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 f8d1615...f85d029. 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.

Looks good to me! The only thing I would add is some tests monkeypatching load_code to raise exceptions.MultipleObjectsError just for coverage completeness. Also, more up to you, but I think it is better, since we already know it is a MultipleObjectsError exception, to mention this in the message (f'multiple copies of the code `{value}` already exist.').

@ramirezfranciscof
Copy link
Member

ramirezfranciscof commented Nov 16, 2021

One side comment that I've just notice is that I think we are not catching "@" in the user input, no? Couldn't this cause problems inside of load_code? (I think the method _get_query_builder_label_identifier assumes there will only be the one separating code and machine) Bah, maybe I'm missing something. Anyways this is separate and can be done in a different PR, just mentioning here for relevance.

(EDIT: Wooops wrong ping)

@ramirezfranciscof
Copy link
Member

@janssenhenning did you want to take a look at this before we merge? We could probably wait some days if you wanted to check this but don't have time right now, otherwise once my comments are addressed by @sphuber we would probably merge this by the end of the week. Let us know.

In commit d25339d `verdi code setup`
was improved to have a callback for the `label` option to check for its
uniqueness. However, it only implemented this for "remote" computers,
which have an associated `Computer` and so the uniqueness criterion is
on the "full label", which is the `label@computer.label`.

However, there are also "local" codes, which don't have an associated
computer and so only have the label as the identifier that should be
unique. The callback `validate_label_uniqueness` is now updated to
distinguish between these two cases.
@sphuber sphuber force-pushed the fix/verdi-code-setup-local-uniqueness branch from 7285d26 to f85d029 Compare November 16, 2021 13:32
@sphuber
Copy link
Contributor Author

sphuber commented Nov 16, 2021

@ramirezfranciscof thanks for the review. Updated the exception message and added tests.

@janssenhenning
Copy link
Contributor

@ramirezfranciscof Sorry I did not have time so far. The fix looks fine to me

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.

Great, thanks @janssenhenning and @sphuber , this can go right in!

@sphuber sphuber merged commit 01a8846 into aiidateam:develop Nov 17, 2021
@sphuber sphuber deleted the fix/verdi-code-setup-local-uniqueness branch November 17, 2021 08:04
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.

None yet

3 participants