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

Migrate verdi profile to use the click infrastructure (#1591) #1651

Merged
merged 13 commits into from
Jul 10, 2018

Conversation

waychal
Copy link
Contributor

@waychal waychal commented Jun 18, 2018

No description provided.

@waychal waychal requested review from DropD and sphuber June 18, 2018 14:45
@codecov-io
Copy link

codecov-io commented Jun 18, 2018

Codecov Report

Merging #1651 into verdi will increase coverage by 0.32%.
The diff coverage is 75.3%.

Impacted file tree graph

@@            Coverage Diff            @@
##           verdi    #1651      +/-   ##
=========================================
+ Coverage   62.2%   62.52%   +0.32%     
=========================================
  Files        300      300              
  Lines      33430    33409      -21     
=========================================
+ Hits       20794    20889      +95     
+ Misses     12636    12520     -116
Impacted Files Coverage Δ
aiida/cmdline/commands/profile.py 73.91% <75.3%> (+64.17%) ⬆️
aiida/backends/djsite/db/models.py 76.23% <0%> (+0.88%) ⬆️
aiida/common/additions/config_migrations/_utils.py 97.22% <0%> (+2.77%) ⬆️
.../common/additions/config_migrations/_migrations.py 100% <0%> (+3.44%) ⬆️
aiida/backends/djsite/globalsettings.py 86.84% <0%> (+5.26%) ⬆️
aiida/common/setup.py 49.89% <0%> (+5.66%) ⬆️

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 2463538...75d8616. Read the comment docs.

@waychal waychal force-pushed the fix_1591_profile_click_cmd branch 2 times, most recently from 8346203 to b073051 Compare June 18, 2018 17:05
DropD
DropD previously requested changes Jun 19, 2018
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.

Make sure aiida/backends/tests/cmdline/commands/test_profile.py and aiida/cmdline/commands/profile.py are added to .pre-commit-config.yaml (under both 'yapf' and 'prospector')

@waychal
Copy link
Contributor Author

waychal commented Jun 19, 2018

@DropD Done.

print >> sys.stderr, ("Please specify the profile to be set as the default")
sys.exit(1)
@verdi_profile.command("list")
@click.option('--no-color', is_flag=True, default=False, help='to show results without colors')
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove this option and replace all the print statements below that use color codes manually, with the click functions. click.secho('This will be in yellow: ', fg='yellow') supports setting a color out of the box. Please use that in stead

echo.echo_critical(err_msg)

if default_profile is None:
echo.echo_error("### No default profile configured yet, run 'verdi install'! ###")
Copy link
Contributor

Choose a reason for hiding this comment

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

if you want to return out of the function use echo.echo_critical and then you can remove the return statement

postgres.determine_setup()

import pprint
pprint.pprint(postgres.dbinfo, width=1, indent=2)
Copy link
Contributor

Choose a reason for hiding this comment

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

The idea here was to use something like pprint or json to dump the dictionary into a single string, but the printing should still be done through click.echo or one of our wrapper functions in aiida.cmdline.utils.echo


print('Configuration folder: {}'.format(AIIDA_CONFIG_FOLDER))
:param profiles_to_delete: list of profiles separated by space
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use explicit :param: notation in the docstring. You can define metavar=PROFILES in the click.argument and use that name in the docstring e.g.:

Delete PROFILES from the aiida configuration file along with
their associated database and repository.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is because in click, the docstring of a command becomes it's help text

@DropD DropD added topic/verdi type/accepted feature approved feature request labels Jun 20, 2018
@waychal waychal force-pushed the fix_1591_profile_click_cmd branch 2 times, most recently from 46cd44c to 2f158c9 Compare July 9, 2018 14:03
@DropD
Copy link
Contributor

DropD commented Jul 9, 2018

@waychal after #1733 is merged, rebase on verdi again, it should fix the test faillures you are getting

@waychal waychal force-pushed the fix_1591_profile_click_cmd branch from 2f158c9 to f1e5476 Compare July 10, 2018 12:25
@DropD DropD dismissed their stale review July 10, 2018 12:36

outdated

postgres.determine_setup()

import json
echo.echo(json.dumps(postgres.dbinfo, indent=4))
Copy link
Contributor

Choose a reason for hiding this comment

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

This debug echo statement should be removed before merging

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not a debug statement and printed to give information to user.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I feel it requires some explanation, because this will simply print the dictionary, and the user will have no idea what it means.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here we are telling user which database will be deleted. I can print dbinfo in key: value pair. Do you have any suggestions?

@DropD DropD dismissed sphuber’s stale review July 10, 2018 15:11

everything seems to be attended to

@DropD DropD merged commit 54eb344 into aiidateam:verdi Jul 10, 2018
@DropD
Copy link
Contributor

DropD commented Jul 11, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic/verdi type/accepted feature approved feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants