Utilizing "multi shot" ability of trees #38
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Motivation and Context
Half the whole point of sequence automation is to actively manage the state of our configured devices such that should they transition to an undesired state they can automatically transition back along defined transition vectors. Up until this point all the work packaged in ActionNodes only ran once, this will keep it living with the life cycle of the program such that when the tree is traversed again and a CheckAndDo node notices a state is out of whack it can fire off the action to deal with it again!
Details
FEAT:
Not multi shot:
BEAMS/beams/tree_config.py
Lines 169 to 179 in a2c883f
Multi shot!:
BEAMS/beams/tree_config.py
Lines 169 to 180 in fb2f291
this works because atexit registers the Worker classes stop_work function during the setup call of the ActionNode:
BEAMS/beams/behavior_tree/ActionNode.py
Lines 45 to 49 in fb2f291
MNT:
Taking advantage of PR #34 which concertized all work this library packages in the Worker class, for ActionNodes augmented by the derived class ActionWorker.
This PR does a little maintenance nitty gritty of cleaning up moving the inter-proccess communication variables to being owned by the ActionNode class as opposed to being defined in the work function which I am considering "super user space".
Before:
BEAMS/beams/behavior_tree/ActionNode.py
Lines 27 to 34 in a50c0dd
Now:
BEAMS/beams/behavior_tree/ActionNode.py
Lines 23 to 33 in 98a646d
This requires that we slightly change the signature of our work functions such that they can take this Event() object defined in the ActionNode class1 and that ActionWorker pass the Event as an additional argument to the add_arg field of Worker. Convenient that we decided to wrap Worker this way... extensible.. josh pats himself on the back.
How Has This Been Tested?
Where Has This Been Documented?
Pre-merge checklist
docs/pre-release-notes.sh
and created a pre-release documentation pageFootnotes
I really want to take advantage of wrappers / functools / inspect to very nicely package the work that gets serialized / specified in tree_config. Have said before but 80% of user needs should be met with jsonic config files. I would like the remaining 20% to be able to very easily / neatly write their own functions I think thats a 10x increase in the capability of this library. I still want to obfuscate IPC concerns from those 20%, I feel like checking that ActionWorker work funcs are correctly defined (signature-ed minimally). I think ENH: Make sure errors in child process bubble up #35 is also very related. ↩