:py:mod:`dags` ============== .. py:module:: dags Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 _version/index.rst dag/index.rst output/index.rst signature/index.rst Package Contents ---------------- Functions ~~~~~~~~~ .. autoapisummary:: dags.concatenate_functions dags.get_ancestors .. py:function:: concatenate_functions(functions, targets=None, return_type='tuple', aggregator=None, enforce_signature=True) Combine functions to one function that generates targets. Functions can depend on the output of other functions as inputs, as long as the dependencies can be described by a directed acyclic graph (DAG). Functions that are not required to produce the targets will simply be ignored. The arguments of the combined function are all arguments of relevant functions that are not themselves function names, in alphabetical order. :param functions: Dict or list of functions. If a list, the function name is inferred from the __name__ attribute of the entries. If a dict, the name of the function is set to the dictionary key. :type functions: dict or list :param targets: Name of the function that produces the target or list of such function names. If the value is `None`, all variables are returned. :type targets: str or list or None :param return_type: One of "tuple", "list", "dict". This is ignored if the targets are a single string or if an aggregator is provided. :type return_type: str :param aggregator: Binary reduction function that is used to aggregate the targets into a single target. :type aggregator: callable or None :param enforce_signature: If True, the signature of the concatenated function is enforced. Otherwise it is only provided for introspection purposes. Enforcing the signature has a small runtime overhead. :type enforce_signature: bool :returns: A function that produces targets when called with suitable arguments. :rtype: function .. py:function:: get_ancestors(functions, targets, include_targets=False) Build a DAG and extract all ancestors of targets. :param functions: Dict or list of functions. If a list, the function name is inferred from the __name__ attribute of the entries. If a dict, with node names as keys or just the values as a tuple for multiple outputs. :type functions: dict or list :param targets: Name of the function that produces the target function. :type targets: str :param include_targets: Whether to include the target as its own ancestor. :type include_targets: bool :returns: The ancestors :rtype: set