-
Notifications
You must be signed in to change notification settings - Fork 192
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 computer setup migrated to click #1735
verdi computer setup migrated to click #1735
Conversation
It is still incomplete, some options are missing, and the test infrastructure has not been adapted yet.
Many tests already added for the non-interactive part. Still a few to add for the interactive part, and to adapt the tests.
Also, changed back the default question from 'disabled' to 'enabled'
Codecov Report
@@ Coverage Diff @@
## verdi #1735 +/- ##
=========================================
+ Coverage 61.66% 62.2% +0.53%
=========================================
Files 300 300
Lines 33471 33430 -41
=========================================
+ Hits 20641 20794 +153
+ Misses 12830 12636 -194
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, just a few minor things, and also please add the relevant files to .pre-commit-config.yaml
self.runner = CliRunner() | ||
|
||
def test_help(self): | ||
self.runner.invoke(setup_computer, ['--help']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this does not fail if the command throws an error, use
self.runner.invoke(setup_computer, ['--help'], catch_exceptions=False)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I copied this from test_code so I will fix this there too.
|
||
def test_reachable(self): | ||
import subprocess as sp | ||
output = sp.check_output(['verdi', 'computer', 'setup', '--help']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch off exception catching here too, because 'Usage' will also be in the output if computer
is considered an invalid command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is check_output, that raises an exception in case of non-zero return code: https://docs.python.org/2/library/subprocess.html#subprocess.check_output
So I don't think I need to change here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad...
output = sp.check_output(['verdi', 'computer', 'setup', '--help']) | ||
self.assertIn('Usage:', output) | ||
|
||
# TODO: test that mpiprocs-per-machine is not requested e.g. for SGE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this into an issue instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it looks like you have a test for this already!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've a couple of leftover comments, I'm going to clean these up
|
||
def test_noninteractive_optional_default_mpiprocs_2(self): | ||
""" | ||
Test 'verdi setup' and check that if is the specified value is zero, it means unspecified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"... check that if the value specified for mpiprocs-per-machine is zero ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
aiida/cmdline/commands/computer.py
Outdated
except EOFError: | ||
# Ctrl+D pressed: end of input. | ||
pass | ||
## Todo: reenable interactive and mixed tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They look enabled to me, please double-check and remove this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
@@ -151,7 +151,7 @@ def active_process_states(): | |||
RAW = OverridableOption('-r', '--raw', 'raw', is_flag=True, default=False, | |||
help='display only raw query results, without any headers or footers') | |||
|
|||
HOSTNAME = OverridableOption('-H', '--hostname', help='hostname') | |||
HOSTNAME = OverridableOption('-H', '--hostname', help='the computer hostname') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind this is also used for the postgres host name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I revert this back, anyway I put a longer one for verdi computer setup
aiida/control/computer.py
Outdated
"""Build a computer with validation of attribute combinations""" | ||
|
||
def __init__(self, **kwargs): | ||
self._computer_spec = kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ltalirz mentioned in the CodeBuilder that this would be safer instead:
for key, value in kwargs.items():
self.__setattr__(key, value)
As it validates each keyword argument while setting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Also, removing two stale files that are not needed after non-interactive verdi code setup
Fixed. Files are not added to the pre-commit because this is only a partial fix to verdi code and there is still much to improve especially for prospector. We will add them with the final commit (some of the files are already on precommit). |
verdi computer setup
migration to click.The other two interactive options (configure and update) will come in a later PR.