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

The computer configure command include profile if not in the current profile #5259

Merged

Conversation

unkcpz
Copy link
Member

@unkcpz unkcpz commented Dec 8, 2021

Fixes #4679

If setup computer for another profile with -p <profile_name> when it is not the current default profile, the prompt hint for setting the computer configure will now include the -p <profile_name>.

@unkcpz unkcpz requested a review from ltalirz December 8, 2021 13:17
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 , makes sense to me. Would maybe just suggest to always include the profile in the suggested command. Makes it consistent and also makes the code simpler.

aiida/cmdline/commands/cmd_computer.py Outdated Show resolved Hide resolved
@ltalirz ltalirz removed their request for review December 9, 2021 10:42
@unkcpz unkcpz force-pushed the fix/4679/enhance-cli-computer-setup-echo branch 2 times, most recently from a39792f to c92e51b Compare December 9, 2021 14:11
@unkcpz
Copy link
Member Author

unkcpz commented Dec 9, 2021

@sphuber Thanks!
I also fix the tests by changing them to pytest. But there is one tests/cmdline/commands/test_computer.py::test_computer_duplicate_interactive stuck and failed.

@unkcpz unkcpz requested a review from sphuber December 9, 2021 14:13
@codecov
Copy link

codecov bot commented Dec 9, 2021

Codecov Report

Merging #5259 (3cc2df5) into develop (12e4320) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #5259      +/-   ##
===========================================
- Coverage    81.46%   81.46%   -0.00%     
===========================================
  Files          530      530              
  Lines        37113    37116       +3     
===========================================
- Hits         30232    30231       -1     
- Misses        6881     6885       +4     
Flag Coverage Δ
django 76.92% <100.00%> (-<0.01%) ⬇️
sqlalchemy 75.92% <100.00%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
aiida/cmdline/commands/cmd_computer.py 81.40% <100.00%> (+0.11%) ⬆️
aiida/manage/tests/pytest_fixtures.py 93.43% <100.00%> (+0.09%) ⬆️
aiida/cmdline/utils/echo.py 81.71% <0.00%> (-1.21%) ⬇️
aiida/engine/daemon/client.py 75.26% <0.00%> (-1.01%) ⬇️
aiida/transports/plugins/local.py 81.41% <0.00%> (-0.25%) ⬇️

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 12e4320...3cc2df5. Read the comment docs.

@sphuber
Copy link
Contributor

sphuber commented Dec 9, 2021

@sphuber Thanks! I also fix the tests by changing them to pytest. But there is one tests/cmdline/commands/test_computer.py::test_computer_duplicate_interactive stuck and failed.

Thanks a lot @unkcpz that's great. One possible reason for the hanging is that some of the tests are running the commands that open an editor to enter the prepend and append text. To fix this, you need to use a special fixture which will automatically close the editor. You will find an example at the bottom of the file of a test that was already in pytest form:

@pytest.mark.parametrize('non_interactive_editor', ('sleep 1; vim -cwq',), indirect=True)

@unkcpz unkcpz force-pushed the fix/4679/enhance-cli-computer-setup-echo branch from 35ba257 to e277e44 Compare December 9, 2021 15:21
Comment on lines 742 to 743
@pytest.mark.parametrize('non_interactive_editor', ('vim -cwq',), indirect=True)
def test_computer_duplicate_interactive(run_cli_command, comp, non_interactive_editor):
Copy link
Member Author

Choose a reason for hiding this comment

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

Hi @sphuber , thanks for the advice. I add the fixture but seems not work. Maybe is the problem is the user_input is wrong? Because for the next test_computer_duplicate_non_interactive test, I need to pass --hostname=localhost, where this hostname is a required parameter for the verdi computer duplicate.

Copy link
Contributor

@sphuber sphuber Dec 9, 2021

Choose a reason for hiding this comment

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

The test that seems to be hanging though is test_computer_test. That is part of a class that you haven't converted to pytest yet (although you did change it from self.assertTrue to assert). I am not sure, but maybe the fact that you are mixing two styles is causing the problem?

Edit: scratch that, that test actually completes. Weirdly enough the logs don't say what test is run after and so which one seems to be blocking.

Copy link
Contributor

Choose a reason for hiding this comment

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

I found the problem and pushed a commit with the fix. See commit message for details

Copy link
Member Author

@unkcpz unkcpz Dec 9, 2021

Choose a reason for hiding this comment

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

@sphuber Cool! I spend half an hour and cannot find how to fix this. Super thanks.

I rebased the commits and fix the pre-commit error.

unkcpz and others added 2 commits December 9, 2021 22:19
Fixes aiidateam#4679

When setup computer for not the current profile by `-p <profile>`, the proposed message for
computer configure command does not contain this profile name, which lead to the copy
paste of the proposed message for configure commad not apply to the correct profile.
We read the profile name from ctx.obj and pass it to the proposed configere message.

- Some of unittests in test_computer.py are moved to pytest.
The problem was that the computer that was being duplicated did not
define the `default_mpiprocs_per_machine`, but the `user_input` just
provided enters. Since there was no default, it kept prompting. By
setting the `default_mpiprocs_per_machine` on the computer that is being
duplicated, the problem is fixed. Note that this is done on the
`aiida_localhost` fixture from the `conftest.py`. This allows to remove
the ad-hoc fixture `comp` which was doing exactly the same.
@unkcpz unkcpz force-pushed the fix/4679/enhance-cli-computer-setup-echo branch from dc13287 to 396229a Compare December 9, 2021 21:20
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

@sphuber sphuber merged commit 10e392d into aiidateam:develop Dec 9, 2021
@unkcpz unkcpz deleted the fix/4679/enhance-cli-computer-setup-echo branch December 10, 2021 09:14
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.

Computer setup: proposed configure command does not include profile
2 participants