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

cli: notify users of runner usage #4663

Merged
merged 2 commits into from
Aug 13, 2021
Merged

Conversation

ltalirz
Copy link
Member

@ltalirz ltalirz commented Jan 14, 2021

The extra query performed in verdi process list to get the load on the
daemon runners is slow - and usually results in no output for the user.
This PR at least lets the user know what is being queried (which also may be useful
to monitor runner load).

@ltalirz
Copy link
Member Author

ltalirz commented Jan 14, 2021

Not sure why the tests failed... didn't change docs + this should not be backend-specific behavior

@ltalirz ltalirz requested a review from sphuber January 14, 2021 23:03
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 @ltalirz . Fine by me, would just not add the case where daemon is not running as that is already covered in verdi process list itself.

@ltalirz ltalirz force-pushed the process-list-2 branch 2 times, most recently from afcbc32 to 797b7c9 Compare January 18, 2021 12:19
@ltalirz
Copy link
Member Author

ltalirz commented Jan 18, 2021

Thanks @ltalirz . Fine by me, would just not add the case where daemon is not running as that is already covered in verdi process list itself.

Thanks - I've pulled out that check from the previous function and now call the worker query only when needed.

@@ -323,11 +323,9 @@ Below is a list with all available subcommands.
.aiida extension for these HTTP addresses. Automatically
discovered archive URLs will be downloaded and added to
ARCHIVES for importing
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: I first removed these changes again but then noticed that they also appear on the CI pre-commit check - some updated version perhaps?

@ltalirz
Copy link
Member Author

ltalirz commented Jan 27, 2021

@sphuber Now that the print is gone when no daemon is running (which I think is the right thing to do here), the test checking its output fails.

What do you think is the best approach here - fake a running daemon or move this test to the daemon tests?
I'm wondering whether one could fake a running daemon by running things inside a with block that creates the pid file, something along the lines of (untested)

with open(get_daemon_client().circus_port_file, 'w', encoding='utf8') as fhandle:
   fhandle.write(123)

   test..

Perhaps there are cleaner approaches

The extra query performed in `verdi process list` to get the load on the
daemon runners is slow - and usually results in no output for the user
in case that the load is below the threshold. With this change, the load
is shown even when below the threshold. Furthermore, the query is only
performed if the daemon is running and skipped otherwise.
@sphuber
Copy link
Contributor

sphuber commented Aug 12, 2021

Perhaps there are cleaner approaches

The typical way is to simply monkeypatch the DaemonClient.is_daemon_running property to always return True. This is made easy using pytest, so I have migrated the test to pytest and it should now work. Let me know if you also are happy with the changes, then I will approve and merge @ltalirz

@codecov
Copy link

codecov bot commented Aug 12, 2021

Codecov Report

Merging #4663 (c0d1f23) into develop (fa498bc) will decrease coverage by 0.01%.
The diff coverage is 80.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4663      +/-   ##
===========================================
- Coverage    80.47%   80.47%   -0.00%     
===========================================
  Files          530      531       +1     
  Lines        36944    36950       +6     
===========================================
+ Hits         29727    29731       +4     
- Misses        7217     7219       +2     
Flag Coverage Δ
django 74.98% <80.00%> (-<0.01%) ⬇️
sqlalchemy 73.89% <80.00%> (-<0.01%) ⬇️

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

Impacted Files Coverage Δ
aiida/cmdline/utils/common.py 67.04% <40.00%> (-0.61%) ⬇️
aiida/cmdline/commands/cmd_process.py 47.85% <88.89%> (+0.25%) ⬆️
aiida/engine/__init__.py 100.00% <100.00%> (ø)
aiida/engine/daemon/__init__.py 100.00% <100.00%> (ø)
aiida/engine/daemon/client.py 75.26% <100.00%> (+0.13%) ⬆️

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 fa498bc...c0d1f23. Read the comment docs.

Copy link
Member Author

@ltalirz ltalirz left a comment

Choose a reason for hiding this comment

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

thanks @sphuber !

@sphuber sphuber merged commit c041163 into aiidateam:develop Aug 13, 2021
@sphuber sphuber deleted the process-list-2 branch August 13, 2021 07:47
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.

2 participants