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 computer setup migrated to click #1735

Conversation

giovannipizzi
Copy link
Member

verdi computer setup migration to click.
The other two interactive options (configure and update) will come in a later PR.

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-io
Copy link

codecov-io commented Jul 9, 2018

Codecov Report

Merging #1735 into verdi will increase coverage by 0.53%.
The diff coverage is 84.48%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
aiida/cmdline/commands/code.py 90.96% <100%> (+0.32%) ⬆️
aiida/orm/implementation/general/computer.py 64.47% <50%> (+13.6%) ⬆️
aiida/cmdline/params/types/computer.py 80.48% <76.47%> (-19.52%) ⬇️
aiida/control/computer.py 85.71% <85.71%> (ø)
aiida/cmdline/commands/computer.py 45.05% <88.33%> (+12.87%) ⬆️
aiida/backends/djsite/db/models.py 75.34% <0%> (+0.12%) ⬆️
aiida/scheduler/datastructures.py 63.97% <0%> (+0.62%) ⬆️
aiida/orm/implementation/django/computer.py 65.95% <0%> (+2.65%) ⬆️
aiida/backends/sqlalchemy/models/computer.py 87.14% <0%> (+2.85%) ⬆️
... and 3 more

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 7943be3...3443372. Read the comment docs.

Copy link
Contributor

@DropD DropD left a 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'])
Copy link
Contributor

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)

Copy link
Member Author

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'])
Copy link
Contributor

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.

Copy link
Member Author

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

Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

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!

Copy link
Member Author

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
Copy link
Contributor

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 ..."

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

except EOFError:
# Ctrl+D pressed: end of input.
pass
## Todo: reenable interactive and mixed tests
Copy link
Contributor

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

Copy link
Member Author

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')
Copy link
Contributor

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

Copy link
Member Author

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

"""Build a computer with validation of attribute combinations"""

def __init__(self, **kwargs):
self._computer_spec = kwargs
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

giovannipizzi and others added 2 commits July 10, 2018 15:53
Also, removing two stale files that are not needed after
non-interactive verdi code setup
@giovannipizzi
Copy link
Member Author

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).
For me it's good to merge.

@DropD DropD merged commit 2463538 into aiidateam:verdi Jul 10, 2018
@giovannipizzi giovannipizzi deleted the fix_1582_verdi_computer_click_only_interactive branch July 10, 2018 14:15
@ltalirz ltalirz mentioned this pull request Sep 26, 2018
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.

3 participants