-
Notifications
You must be signed in to change notification settings - Fork 234
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
Processors #424
Processors #424
Conversation
@dbarrosop Can you expand a little bit on the meaning of when a |
Ok, added further clarifications to the description. Obviously all of that will be properly documented :) |
This one is ready, if nobody objects I will merge it next week. I will also release a new version of nornir. |
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.
Looks good to me.
A few minor things (I am fine with the current PR though):
- The "Processor" term definitely had me scratching my head for a bit on what this was about and for a while I thought it was more oriented towards a task replacement pattern (instead of what it is).
You frequently used the term "Events" so I wonder if something like "Event Processor" or "Results Processor" might make sense for at least the documentation.
- Should we use an ABC for the Processor class?
"source": [ | ||
"The first thing you probably noticed is that we got all those messages on screen printed for us. That was done by our processor `PrintResult`. You probably also noticed we got the `AggregatedResult` back but we didn't even bother saving it into a variable as we don't needed it here.\n", | ||
"\n", | ||
"Now, let's see if `SaveResultToDict` did something to the dictionary `data`L" |
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.
Extra trailing L
at end of sentence here.
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"As you can see, performing various actions on the results becomes quite easy thanks to the processors. You still get the result back but thanks to this plugins you may not needed them anymore.\n", |
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.
Minor spelling should be "need" instead of "needed".
Nice work! I think it would be nice to also support processors for sub-tasks, currently it's tied to the Nornir object and not for We talked on Slack about maybe moving what's currently the host processors to I'm struggling a bit with the names I think I would like to replace the current names for host_X -> task_X and have the current task_X be something like run_X or execution_X. For sub tasks I think it would be fine to only have the start/complete processors be for the main What are your thoughts? |
@ogenstad Good points. I wonder if we should just map it closer to Nornir concepts/naming i.e. something like nornir_start, nornir_complete, task_start, task_complete (where task here is task object so if you did subtasks you would have multiple of these as you referenced above). |
4fbc271
to
d5a055a
Compare
Subtasks issue fixed. Re naming, I like the current naming, let me explain why. I think the problem is that we are very ambiguous in our language when it comes to nornir, we call everything a task but we need to distinguish between a task (the concept of it, the instructions we want to perform) and an actual run/instance of a task on a given host. So I think we need to clarify that and follow suit. My suggestion is to cal them:
(2) has the problem that we will have to rename some parts of the code, for instance, task signatures will change to:
Thoughts? |
That sounds good to me, my main issue was that the word host was used for what is above described as a task_instance. I think task_instance is much more clear and also works better with sub-tasks. |
I am still worried this naming is going to be confusing. Say for example, we have:
And here
And here by our new terminology we have two Just let me know if I misunderstood this, however. It is definitely possible :-) I think in practice when explaining this to other people...I would pretty much say, This stems in part from the dual
I also don't want to drag on too long so we should probably just decide and move on. |
That's a good point and it basically highlights we need a better definition of task so let me try again taking into consideration the point you just raised:
This leads to the following observation though, to make this consistent with the processors we need to either revert to the previous behavior when we didn't call any processors on subtasks or add a new event specifically for the subtasks. I am going to implement the latter in the meantime but feel free to keep with the discussion, I think the lack of definitions plus the will to make things simpler via utility functions (like task.run) have lead to a few poor decisions that makes things a bit confusing and I'd love to make things clearer so we can decide what we need to change for a nicer API (thinking about nornir 3). |
Ok, check the latest version. Needs some cleaning on the docs side (waiting to confirm we like this), you can see in |
This terminology if fine with me. I will probably end up referring to item 2 as the "primary task" (or some similar adjective to try to make the distinction clearer) as I think there will be quite a bit of confusion on the term "task" (at least until "task instance" and "tai.run()" becomes a more common pattern). |
Processors implement a set of functions that are called at different stages:
This allows you to process those events very easily and do things like:
The idea is that you can have as many processors as you want and all of them will be called.
As an example I re-implmented
print_results
using a processor. As you can see the implementation is a bit cleaner.Another benefit is that because the functions are called when the events happen you don't have to wait until all the hosts are completed to get feedback, you can start processing results as they are made available.