-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add new functions and update print_result #21
base: master
Are you sure you want to change the base?
Add new functions and update print_result #21
Conversation
6daa2e6
to
1926376
Compare
d95f7d6
to
b2c3384
Compare
a small update:
|
I just say that I do really appreciate the work here but everything we discussed in #15 #16 #17 #18 still applies. It is also not good etiquette to send a single PR with many new and unrelated features and fixes. It makes the review process very difficult and increases the chances the PR won't make it. For instance, I don't think I will be accepting the |
b2c3384
to
bb9a634
Compare
I apologize for this PR, and I also really don't like PR of this size, and I really tried to make it convenient for the PR reviewer. But I also already think, that And... I didn't really understand, why the tests, related to other modules, were failing... I would be very glad, if you could help me with this:
|
bb9a634
to
b70f8f2
Compare
- print_stat - Prints results statistic on stdout. - write_result - Writes results to file. - write_results - Writes results to files.
b70f8f2
to
ff43dd0
Compare
Ok, sounds good. Given that everything is new functionality now I am less concerned about the PR. I will try to put aside some time for this but these days time is very scarce, so apologies if this takes a while. |
LOCK = threading.Lock() | ||
|
||
|
||
init(autoreset=True, strip=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.
this is why the tests are failing, we are initializing colorama twice. Remove this line and the tests will all pass (you will need to fix your 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.
maybe move the other init call to init to have it in a central place
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.
moved colorama
init
to __init__
central place
from nornir.core.task import AggregatedResult, MultiResult, Result | ||
|
||
|
||
LOCK = threading.Lock() |
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.
we should use the same lock that print_result
uses, otherwise, print_result
and print_stat
can interfere with each other
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.
imported print_result
LOCK
for print_stat
function
@@ -0,0 +1,220 @@ | |||
{ |
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.
I'd like to see a test printing all kind of objects directly. Right now you are printing an AggregatedResult
in all the examples in here so it'd be nice to print directly the other types there (i.e. print_stats(results["my_device"])
and print_stats(results["my_device"][0])
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.
Added MultiResult
and Result
objects to function_print_stat.ipynb
tutorial
I like the functionality behind So I think what we could do instead is the following:
We may need to add another parameter to tell colorama to not add escape codes for colors, not sure what the best way of doing that would be though but I am happy to ignore this issue for now.
Thoughts? |
- Move colorama init to __init__ central place - Use the print_result LOCK for print_stat - Add MultiResult and Result objects to function_print_stat.ipynb tutorial - Make the code cleaner
I apologize for such a long pause in this PR and thank you so much for your help with testing. I thought for a long time... and to me, as a user, it seems inconvenient to be able to write to a file in one function (
I see 2 options here:
I have kept here option 2 for further discussion |
I am not sure I understand this. Why can't you do that in my proposal?
What I proposed is to have I think you misunderstood my proposal. In my proposal you don't need to call two functions and you don't need to implement anything that isn't pythonic. You'd have def write_to_files(result: AggregatedResult) -> None:
for hostname, r in result.items():
with open(hostname, "w+") as f:
print_result(r, file=f) |
- Add file, no_errors, print_host parameters to print_result function - Update print_stat output format - write_result, write_results are based on print_result function - Remove diff feature from write_result and write_results functions - Update tutorials - Import reorder - Change docstring
Oh! I really misunderstood this great proposal and this is really the best way! Thank you very much for the idea :) So, now in this PR:
In addition, it has already been done:
I also removed the During testing, an error has occured with installing the latest version of poetry ( |
Remove py3.6, update dependencies, update docs (nornir-automation#35)
A small update based on #35:
|
The workflow does not work correctly with |
update
print_result
function:count
parameter. It's only to limit the amount of output to the terminal without changing the scrollback terminal settings, but at the same time to see some results. I think, it's useful, at least, fornornir_cli
tooldocs/source/tutorials/function_print_result.ipynb
add new
print_stat
function:docs/source/tutorials/function_print_stat.ipynb
with examplesadd new
write_result
function:write_result
returns diff between previous file state and new file state (str)docs/source/tutorials/function_write_result.ipynb
with examplesadd new
write_results
function:write_results
returns list of tuples with hostname + diff between previous file state and new file statedocs/source/tutorials/function_write_results.ipynb
This PR is instead of closed PR: #15 #16 #17 #18