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

Fix bug in verdi daemon restart --reset #3969

Merged
merged 1 commit into from
Apr 27, 2020

Conversation

sphuber
Copy link
Contributor

@sphuber sphuber commented Apr 25, 2020

Fixes #3960

The command verdi daemon restart --reset was excepting when it was
invoking the verdi daemon start command. The reason being that recently
the number argument of verdi daemon start was changed to not define
a default directly, but to go through a callback. This would then set
the default based on a configuration option for the current profile.

However, due to a bug in click, parameter callbacks are not called
when invoking a command through Context.invoke, which caused the
number argument to be None which triggered an exception. Until that
bug is fixed in click, which has issue #950, we add a workaround to
manually defining the default value, that would normally have been done
by the argument callback, and explicitly passing it in the invoke call.

N.B.: I opened a PR that fixes the underlying bug in click.

@sphuber sphuber added the pr/blocked PR is blocked by another PR that should be merged first label Apr 25, 2020
@codecov
Copy link

codecov bot commented Apr 25, 2020

Codecov Report

Merging #3969 into develop will increase coverage by 0.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3969      +/-   ##
===========================================
+ Coverage    78.33%   78.44%   +0.10%     
===========================================
  Files          461      461              
  Lines        34076    34077       +1     
===========================================
+ Hits         26694    26731      +37     
+ Misses        7382     7346      -36     
Flag Coverage Δ
#django 70.48% <100.00%> (+0.10%) ⬆️
#sqlalchemy 71.34% <100.00%> (+0.10%) ⬆️
Impacted Files Coverage Δ
aiida/cmdline/commands/cmd_daemon.py 72.67% <100.00%> (+16.53%) ⬆️
aiida/engine/daemon/client.py 72.57% <0.00%> (+1.71%) ⬆️
aiida/cmdline/utils/daemon.py 73.33% <0.00%> (+8.33%) ⬆️

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 98e21da...7a111dd. Read the comment docs.

@sphuber sphuber force-pushed the fix/3960/verdi-daemon-restart branch from bfaf1a1 to f374f9b Compare April 27, 2020 06:49
@sphuber sphuber added pr/ready-for-review PR is ready to be reviewed and removed pr/blocked PR is blocked by another PR that should be merged first labels Apr 27, 2020
Copy link
Member

@giovannipizzi giovannipizzi left a comment

Choose a reason for hiding this comment

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

I left a comment with a doubt (but if you know it works, it's ok to merge), and a typo (feel free to fix it)

tests/cmdline/commands/test_daemon.py Outdated Show resolved Hide resolved
# Due to that bug, the `callback` of the `number` argument the `start` command is not being called, which is
# responsible for settting the default value, which causes `None` to be passed and that triggers an exception.
# As a temporary workaround, we fetch the default here manually and pass that in explicitly.
number = ctx.obj.config.get_option('daemon.default_workers', ctx.obj.profile.name)
Copy link
Member

Choose a reason for hiding this comment

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

Just to double check, ctx.obj.profile.name is always set even if not explicitly specified?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Barring a bug, it should be. It is set in aiida.cmdline.commands.cmd_verdi.verdi

The command `verdi daemon restart --reset` was excepting when it was
invoking the `verdi daemon start` command. The reason being that recently
the `number` argument of `verdi daemon start` was changed to not define
a default directly, but to go through a callback. This would then set
the default based on a configuration option for the current profile.

However, due to a bug in `click`, parameter callbacks are not called
when invoking a command through `Context.invoke`, which caused the
`number` argument to be `None` which triggered an exception. Until that
bug is fixed in `click`, which has issue aiidateam#950, we add a workaround to
manually defining the default value, that would normally have been done
by the argument callback, and explicitly passing it in the invoke call.
@sphuber sphuber force-pushed the fix/3960/verdi-daemon-restart branch from f374f9b to 7a111dd Compare April 27, 2020 09:06
@sphuber sphuber merged commit 1df4270 into aiidateam:develop Apr 27, 2020
@sphuber sphuber deleted the fix/3960/verdi-daemon-restart branch April 27, 2020 09:31
@sphuber sphuber modified the milestone: v1.2.2 May 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/ready-for-review PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception in verdi daemon restart --reset
2 participants