-
Notifications
You must be signed in to change notification settings - Fork 94
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
Implement mutators #56
base: master
Are you sure you want to change the base?
Conversation
9e21892
to
9e8ac81
Compare
I guess it would actually be more accurate to point out that mutators need to be functions, and that arbitrary callables won't work. That's a limitation imposed by inspect.getargspec, which is a crucial piece of deciding whether a mutator should be run. |
Let's not merge this yet-- I need to resolve lottspot/reclass/issues/4 first |
Any news on this feature? |
Mutators allow the definition of raw python functions to manipulate entities before returning them to the caller. The Mutators implementation obsoletes function interpolation
This feature is still very much on my radar to complete. I hope to be able to carve out some time soon to hammer out the remaining issues and wrap this up. |
@lottspot, what is the situation that motivates this feature? |
Merge develop branch to master
This patch introduces a new Mutators data type to entities. This data type is a stack of python callables which perform arbitrary modifications to a populated node or inventory dictionary before it is returned to the caller.
Writing mutators is simple; we simply need to provide a python callable within a module somewhere along PYTHONPATH (cli has been modified in this patch to append inventory_base_uri to sys.path for sane default behavior)
Mutators are then specified in class or node definitions, just as other reclass datatypes.
This configuration would apply the mutator when all of the following conditions are satisfied:
Core will only call _mutate with those arguments within Core.nodeinfo. So from the CLI, this mutator would be applied using
reclass -n mynode
, which would then produce the following output:The purpose of implementing this feature is to offer a way to create dynamic node parameters, primarily as a way to build relationships between nodes or classes based on other parameters.