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

Not prompt memory set for core.direct #5642

Merged
merged 5 commits into from
Sep 20, 2022

Conversation

unkcpz
Copy link
Member

@unkcpz unkcpz commented Sep 15, 2022

The warning Warning: Physical memory limiting is not supported by the direct scheduler. pop up if set the computer by interactive mode.
The default_memory_per_machine should not pop up from computer setup with core.direct scheduler.

But I am not sure where to add the unit test for this.

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 @unkcpz . As for the testing, I would add it to tests/cmdline/commands/test_computer.py. Run a setup command with --scheduler-type=core.direct and make sure that the warning from the DirectJobResource is not printed. There might be a more robust way that would monkeypatch either the option or the command to raise when it is called or the option is specified in the command.

Comment on lines 91 to 92
@classmethod
@abc.abstractmethod
def accepts_default_memory_per_machine(cls):
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize that the existing method accepts_default_mpiprocs_per_machine is abstract, but I think in this case it is better to just implement it on the base class. Currently, the code behaves as is the default is True, so I would just return that here. Then you can simply update the DirectJobResource to return False. This way, we don't risk breaking other JobResource implementations out there that all of a sudden would no longer be concrete.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fully agree, the potential risk you mentioned is true, I found I missing to implement the abstract method to TemplateJobResource.

Comment on lines 43 to 44
If there is a problem in determining the scheduler, return True to
avoid exceptions.
Copy link
Contributor

Choose a reason for hiding this comment

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

This actually doesn't match the behavior. If job_resource_cls is None then it returns False. If the scheduler class cannot be determined, I think it is best to return False, because in that case the option won't be prompted and the user might just have to configure it manually afterwards. If we return True and the scheduler doesn't actually support it, then any CalcJobs that will be run with it, will fail I believe.

So I think the code is correct and should be kept, but the docstring should be updated (see other comments what I suggest).

Comment on lines 56 to 60
"""
Return True if the scheduler can accept 'default_memory_per_machine',
False otherwise.

If there is a problem in determining the scheduler, return True to
avoid exceptions.
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"""
Return True if the scheduler can accept 'default_memory_per_machine',
False otherwise.
If there is a problem in determining the scheduler, return True to
avoid exceptions.
"""
"""Return whether the selected scheduler type accepts `default_memory_per_machine`.
:return: `True` if the scheduler type accepts `default_memory_per_machine`, `False` otherwise. If the scheduler class could not be loaded `False` is returned by default.
"""

Copy link
Contributor

Choose a reason for hiding this comment

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

Idem dito for the should_call_default_mpiprocs_per_machine docstring.

@unkcpz unkcpz force-pushed the fix/xx/supress-ram-set-for-direct branch from f0d33bb to 117b5b9 Compare September 18, 2022 07:57
@unkcpz
Copy link
Member Author

unkcpz commented Sep 18, 2022

@sphuber thanks! I add the test in tests/cmdline/commands/test_computer.py change the test name from test_interactive to test_direct_interactive and pop the unused default-memory-per-machine from the options list.
The test passes with the current implementation as expectation and fails the previous which stuck at asking for the default-memory-per-machine.

@unkcpz unkcpz requested a review from sphuber September 18, 2022 08:42
@sphuber
Copy link
Contributor

sphuber commented Sep 20, 2022

@unkcpz if you fix the tests and docs, I will give another review

@unkcpz unkcpz force-pushed the fix/xx/supress-ram-set-for-direct branch from 7b35651 to c6f5ffb Compare September 20, 2022 10:36
@sphuber sphuber merged commit ee46a2e into aiidateam:main Sep 20, 2022
@sphuber
Copy link
Contributor

sphuber commented Sep 20, 2022

thanks @unkcpz

@unkcpz
Copy link
Member Author

unkcpz commented Sep 20, 2022

Thanks @sphuber, I forget to request for your review again 😆

@unkcpz unkcpz deleted the fix/xx/supress-ram-set-for-direct branch September 20, 2022 11:32
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

2 participants