def set_default_config(modules, params=None, yaml=None, filename=None,<EOL>config=None, validate=True):
if params is None:<EOL><INDENT>params = {}<EOL><DEDENT>file_config = {}<EOL>if yaml is None and filename is None and config is None:<EOL><INDENT>if '<STR_LIT>' in params and params['<STR_LIT>'] is not None:<EOL><INDENT>filename = params['<STR_LIT>']<EOL><DEDENT><DEDENT>if yaml is not None or filename is not None or config is not None:<EOL><INDENT>if yaml is not None:<EOL><INDENT>file_config = yaml_mod.load(StringIO(yaml))<EOL><DEDENT>elif filename is not None:<EOL><INDENT>with open(filename, '<STR_LIT:r>') as f:<EOL><INDENT>file_config = yaml_mod.load(f)<EOL><DEDENT><DEDENT>elif config is not None:<EOL><INDENT>file_config = config<EOL><DEDENT><DEDENT>base_config = copy.deepcopy(file_config)<EOL>create_config_tree(base_config, modules)<EOL>fill_in_arguments(base_config, modules, params)<EOL>default_config = assemble_default_config(modules)<EOL>base_config = overlay_config(default_config, base_config)<EOL>def replace_module(config, m):<EOL><INDENT>name = getattr(m, '<STR_LIT>')<EOL>c = config.get(name, {})<EOL>if hasattr(m, '<STR_LIT>'):<EOL><INDENT>return getattr(m, '<STR_LIT>')(c, name)<EOL><DEDENT>return m<EOL><DEDENT>modules = [replace_module(base_config, m) for m in modules]<EOL>base_config = file_config<EOL>create_config_tree(base_config, modules)<EOL>fill_in_arguments(base_config, modules, params)<EOL>do_config_discovery(base_config, modules)<EOL>default_config = assemble_default_config(modules)<EOL>base_config = overlay_config(default_config, file_config)<EOL>fill_in_arguments(base_config, modules, params)<EOL>if validate and len(modules) > <NUM_LIT:0>:<EOL><INDENT>mod = modules[-<NUM_LIT:1>]<EOL>checker = getattr(mod, '<STR_LIT>', None)<EOL>if checker is not None:<EOL><INDENT>with _temporary_config():<EOL><INDENT>set_global_config(base_config)<EOL>checker(base_config[mod.config_name], mod.config_name)<EOL><DEDENT><DEDENT><DEDENT>normalize_config(base_config, modules)<EOL>set_global_config(base_config)<EOL>return base_config<EOL>
Set up global configuration for tests and noninteractive tools.

    `modules` is an iterable of
    :class:`yakonfig.Configurable` objects, or anything
    equivalently typed.  This function iterates through those objects
    to produce a default configuration, reads `yaml` as though it were
    the configuration file, and fills in any values from `params` as
    though they were command-line arguments.  The resulting
    configuration is set as the global configuration.

    :param modules: modules or Configurable instances to use
    :type modules: iterable of :class:`~yakonfig.Configurable`
    :param dict params: dictionary of command-line argument key to values
    :param str yaml: global configuration file
    :param str filename: location of global configuration file
    :param dict config: global configuration object
    :param bool validate: check configuration after creating
    :return: the new global configuration
    :returntype: dict