backend.payload
Handles payloads from markup files
BasePayload Objects#
class BasePayload(BaseHandler)Handles building the payload for config file(s)
This class builds out the payload from config files of multiple types. It handles various file types and also composition of config files via recursive calls
Attributes:
_loaders- maps of each file extension to the loader class__s3_config- optional S3Config object to handle s3 access
_update_payload#
@staticmethod@abstractmethoddef _update_payload(base_payload, input_classes, ignore_classes, payload)Updates the payload
Checks the parameters defined in the config files against the provided classes and if passable adds them to the payload
Arguments:
base_payload- current payloadinput_classes- class to roll intoignore_classes- list of classes to ignorepayload- total payload
Returns:
payload- updated payload
payload#
def payload(input_classes, ignore_classes, path, cmd_args, deps)Builds the payload from config files
Public exposed call to build the payload and set any command line overrides
Arguments:
input_classes- list of backend classesignore_classes- list of classes to ignorepath- path to config file(s)cmd_args- command line overridesdeps- dictionary of config dependencies
Returns:
payload- dictionary of all mapped parameters
_payload#
def _payload(input_classes, ignore_classes, path, deps, root=False)Private call to construct the payload
Main function call that builds out the payload from config files of multiple types. It handles various file types and also composition of config files via a recursive calls
Arguments:
input_classes- list of backend classesignore_classes- list of classes to ignorepath- path to config file(s)deps- dictionary of config dependencies
Returns:
payload- dictionary of all mapped parameters
_handle_dependencies#
@staticmethoddef _handle_dependencies(deps, path, root)Handles config file dependencies
Checks to see if the config path (full or relative) has already been encountered. Essentially a DFS for graph cycles
Arguments:
deps- dictionary of config dependenciespath- current config pathroot- boolean if root
Returns:
deps- updated dependencies
_handle_includes#
def _handle_includes(base_payload, config_extension, input_classes, ignore_classes, path: Path, payload, deps)Handles config composition
For all of the config tags in the config file this function will recursively call the payload function with the composition path to get the additional payload(s) from the composed file(s) -- checks for file validity or if it is an S3 URI via regex
Arguments:
base_payload- base payload that has a config kwargconfig_extension- file typeinput_classes- defined backend classesignore_classes- list of classes to ignorepath- path to base filepayload- payload pulled from composed filesdeps- dictionary of config dependencies
Returns:
payload- payload update from composed files
_handle_overrides#
def _handle_overrides(payload, ignore_classes, args)Handle command line overrides
Iterate through the command line override values, determine at what level to set them, and set them if possible
Arguments:
payload- current payload dictionaryargs- command line override args
Returns:
payload- updated payload dictionary with override values set
_prune_args#
@staticmethoddef _prune_args(args, ignore_classes)Prunes ignored class names from the cmd line args list to prevent incorrect access
Arguments:
args- current cmd line argsignore_classes- list of class names to ignore
Returns:
dictionary of pruned cmd line args
_handle_payload_override#
@staticmethod@abstractmethoddef _handle_payload_override(payload, key, value)Handles the complex logic needed for List[spock class] overrides
Messy logic that sets overrides for the various different types. The hardest being List[spock class] since str names have to be mapped backed to sys.modules and can be set at either the general or class level.
Arguments:
payload- current payload dictionarykey- current arg keyvalue- value at current arg key
Returns:
payload- modified payload with overrides
AttrPayload Objects#
class AttrPayload(BasePayload)Handles building the payload for attrs backend
This class builds out the payload from config files of multiple types. It handles various file types and also composition of config files via a recursive calls
Attributes:
_loaders- maps of each file extension to the loader class
__init__#
def __init__(s3_config: Optional[_T] = None)Init for AttrPayload
Arguments:
s3_config- optional S3 config object
__call__#
def __call__(*args, **kwargs)Call to allow self chaining
Arguments:
*args: **kwArgs:
Returns:
Payload- instance of self
_handle_payload_override#
@staticmethoddef _handle_payload_override(payload, key, value)Handles the complex logic needed for List[spock class] overrides
Messy logic that sets overrides for the various different types. The hardest being List[spock class] since str names have to be mapped backed to sys.modules and can be set at either the general or class level.
Arguments:
payload- current payload dictionarykey- current arg keyvalue- value at current arg key
Returns:
payload- modified payload with overrides