Implement mutators - #56
Open
lottspot wants to merge 1 commit into
Open
Conversation
lottspot
force-pushed
the
feature/mutators
branch
2 times, most recently
from
August 7, 2016 12:19
9e21892 to
9e8ac81
Compare
Collaborator
Author
|
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. |
Collaborator
Author
|
Let's not merge this yet-- I need to resolve lottspot/reclass/issues/4 first |
|
Any news on this feature? |
lottspot
referenced
this pull request
in lottspot/reclass
Feb 8, 2017
Mutators allow the definition of raw python functions to manipulate entities before returning them to the caller. The Mutators implementation obsoletes function interpolation
Collaborator
Author
|
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? |
AndrewPickford
pushed a commit
to AndrewPickford/reclass
that referenced
this pull request
Sep 11, 2018
Merge develop branch to master
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.