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

Add default_memory_per_machine attribute to Computer. #5260

Merged

Conversation

yakutovicha
Copy link
Contributor

@yakutovicha yakutovicha commented Dec 8, 2021

fixes #4297

  • The value units are set to be kB.
  • 0 value means no value has been specified.
  • The max_memory_kb option has the same effect but is a higher priority

@yakutovicha yakutovicha force-pushed the feat/add-memory-option-to-computer-setup branch 3 times, most recently from 1f4af8d to c8e40ca Compare December 8, 2021 15:39
Copy link
Contributor

@muhrin muhrin left a comment

Choose a reason for hiding this comment

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

We should normalise this to make sure that memory units are always treated as integers (currently there is a mix of float and int).

There is one outstanding question of whether to use MB or kB. Currently the code uses kB for the job options while here we are suggesting using MB. I don't think the loss of granularity is a problem, but the lack of consistency may be confusing. Any thoughts @sphuber ?

aiida/cmdline/commands/cmd_computer.py Outdated Show resolved Hide resolved
.github/config/localhost.yaml Outdated Show resolved Hide resolved
aiida/engine/processes/calcjobs/calcjob.py Outdated Show resolved Hide resolved
aiida/orm/computers.py Outdated Show resolved Hide resolved
aiida/orm/utils/builders/computer.py Outdated Show resolved Hide resolved
aiida/cmdline/params/options/commands/computer.py Outdated Show resolved Hide resolved
Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

Thanks @yakutovicha , I have given a first pass. Main thing is that I think mixing kB and MB is going to be confusing, both for the user and in the code.

.github/config/localhost.yaml Outdated Show resolved Hide resolved
aiida/cmdline/commands/cmd_computer.py Outdated Show resolved Hide resolved
aiida/cmdline/params/options/commands/computer.py Outdated Show resolved Hide resolved
aiida/schedulers/datastructures.py Outdated Show resolved Hide resolved
aiida/schedulers/plugins/lsf.py Outdated Show resolved Hide resolved
aiida/schedulers/scheduler.py Outdated Show resolved Hide resolved
aiida/cmdline/params/options/commands/computer.py Outdated Show resolved Hide resolved
aiida/engine/processes/calcjobs/calcjob.py Outdated Show resolved Hide resolved
aiida/orm/computers.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Dec 9, 2021

Codecov Report

Merging #5260 (a38d025) into develop (2ee6dd9) will increase coverage by 0.02%.
The diff coverage is 90.33%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5260      +/-   ##
===========================================
+ Coverage    81.45%   81.46%   +0.02%     
===========================================
  Files          530      530              
  Lines        37116    37139      +23     
===========================================
+ Hits         30229    30253      +24     
+ Misses        6887     6886       -1     
Flag Coverage Δ
django 76.93% <90.33%> (+0.02%) ⬆️
sqlalchemy 75.93% <90.33%> (+0.05%) ⬆️

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

Impacted Files Coverage Δ
aiida/orm/utils/builders/computer.py 87.50% <83.34%> (-0.54%) ⬇️
aiida/orm/computers.py 82.18% <92.86%> (+0.74%) ⬆️
aiida/cmdline/commands/cmd_computer.py 81.51% <100.00%> (+0.11%) ⬆️
aiida/cmdline/params/options/commands/computer.py 86.67% <100.00%> (+0.46%) ⬆️
aiida/engine/processes/calcjobs/calcjob.py 90.18% <100.00%> (+0.37%) ⬆️
aiida/manage/tests/pytest_fixtures.py 93.51% <100.00%> (+0.09%) ⬆️
aiida/schedulers/plugins/direct.py 66.87% <0.00%> (+0.59%) ⬆️

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 2ee6dd9...a38d025. Read the comment docs.

@yakutovicha yakutovicha changed the title Add default_mem_per_machine attribute to Computer. Add default_memory_per_machine attribute to Computer. Dec 9, 2021
muhrin
muhrin previously requested changes Dec 9, 2021
aiida/cmdline/params/options/commands/computer.py Outdated Show resolved Hide resolved
@yakutovicha yakutovicha force-pushed the feat/add-memory-option-to-computer-setup branch 2 times, most recently from efb7fed to bc4ffe2 Compare December 10, 2021 11:24
Copy link
Contributor

@sphuber sphuber left a comment

Choose a reason for hiding this comment

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

Thanks @yakutovicha . Still are some remaining things to be fixed, but then this should be good to go.

.github/config/localhost.yaml Outdated Show resolved Hide resolved
.github/config/slurm-ssh.yaml Outdated Show resolved Hide resolved
aiida/cmdline/params/options/commands/computer.py Outdated Show resolved Hide resolved
@@ -264,6 +264,20 @@ def _default_mpiprocs_per_machine_validator(cls, def_cpus_per_machine: Optional[
'do not want to provide a default value.'
)

@classmethod
def _default_memory_per_machine_validator(cls, def_memory_per_machine: Optional[int]) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think you are actually using this. Did you forget to add this to Computer.validate?

Copy link
Contributor

Choose a reason for hiding this comment

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

This comment still stands correct? This is not being called in the current code.

Copy link
Contributor Author

@yakutovicha yakutovicha Dec 14, 2021

Choose a reason for hiding this comment

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

I think it was correct, but now I call it in set_default_memory_per_machine as you suggest below. I also renamed it to default_memory_per_machine_validator as, presumably, it will be called outside of the class. In case we want to do the validation elsewhere.

aiida/orm/computers.py Outdated Show resolved Hide resolved
"""
if def_memory_per_machine is None:
self.delete_property('default_memory_per_machine', raise_exception=False)
elif not isinstance(def_memory_per_machine, int):
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of doing the validation here again, just call _default_memory_per_machine_validator. This way you don't run the risk that the validation is inconsistent in different places (as is the case now: here you don't check that the int is positive non-zero). If you want to keep the TypeError in case it is not a valid positive integer (which I agree is better than ValidationError) you simply catch the ValidationError and reraise as TypeError.

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 think it would be good to do the validation directly here. The same goes for the other set_ methods. See suggestion #5257.

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 am not saying to not do the validation here, I am just saying to put the validation in one place (let's say a separate method) and have this method and the validate method both call that validation. But then we are sure it is consistent

aiida/orm/utils/builders/computer.py Outdated Show resolved Hide resolved
tests/cmdline/commands/test_computer.py Outdated Show resolved Hide resolved
tests/cmdline/commands/test_computer.py Outdated Show resolved Hide resolved
@yakutovicha yakutovicha force-pushed the feat/add-memory-option-to-computer-setup branch 2 times, most recently from 07f8e58 to 30a6b89 Compare December 13, 2021 15:15
aiida/orm/computers.py Outdated Show resolved Hide resolved
@sphuber
Copy link
Contributor

sphuber commented Dec 13, 2021

@yakutovicha I resolved the majority of outstanding conversations except one: the validation method is not called anywhere. Finally, I added three minor new comments: two small fixes to help strings/error messages and a test that should be removed.

@sphuber
Copy link
Contributor

sphuber commented Dec 15, 2021

@yakutovicha there are still some outstanding things that weren't addressed. For your convenience, I created a commit on top of your branch and pushed it to my fork: sphuber@214cb24

If you agree with the changes, you can simply cherry-pick it and push it to your branch, and then after we update it, I will approve and merge.

yakutovicha and others added 4 commits December 15, 2021 10:19
Co-authored-by: Sebastiaan Huber <mail@sphuber.net>
- Call `default_memory_per_machine_validator` in `Computer.validate`
- Do not handle `0` in the `ComputerBuilder`
- Correct `run_cli_command` usage.
@yakutovicha yakutovicha force-pushed the feat/add-memory-option-to-computer-setup branch from 13f8fd3 to a38d025 Compare December 15, 2021 09:22
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.

memory available in computer nodes
3 participants