# Path: sacred/config/config_scope.py
# class ConfigScope:
#     def __init__(self, func):
#         self.args, vararg_name, kw_wildcard, _, kwargs = get_argspec(func)
#         assert vararg_name is None, "*args not allowed for ConfigScope functions"
#         assert kw_wildcard is None, "**kwargs not allowed for ConfigScope functions"
#         assert not kwargs, "default values are not allowed for ConfigScope functions"
# 
#         self._func = func
#         self._body_code = get_function_body_code(func)
#         self._var_docs = get_config_comments(func)
#         self.__doc__ = self._func.__doc__
# 
#     def __call__(self, fixed=None, preset=None, fallback=None):
#         """
#         Evaluate this ConfigScope.
# 
#         This will evaluate the function body and fill the relevant local
#         variables into entries into keys in this dictionary.
# 
#         :param fixed: Dictionary of entries that should stay fixed during the
#                       evaluation. All of them will be part of the final config.
#         :type fixed: dict
#         :param preset: Dictionary of preset values that will be available
#                        during the evaluation (if they are declared in the
#                        function argument list). All of them will be part of the
#                        final config.
#         :type preset: dict
#         :param fallback: Dictionary of fallback values that will be available
#                          during the evaluation (if they are declared in the
#                          function argument list). They will NOT be part of the
#                          final config.
#         :type fallback: dict
#         :return: self
#         :rtype: ConfigScope
#         """
#         cfg_locals = dogmatize(fixed or {})
#         fallback = fallback or {}
#         preset = preset or {}
#         fallback_view = {}
# 
#         available_entries = set(preset.keys()) | set(fallback.keys())
# 
#         for arg in self.args:
#             if arg not in available_entries:
#                 raise KeyError(
#                     "'{}' not in preset for ConfigScope. "
#                     "Available options are: {}".format(arg, available_entries)
#                 )
#             if arg in preset:
#                 cfg_locals[arg] = preset[arg]
#             else:  # arg in fallback
#                 fallback_view[arg] = fallback[arg]
# 
#         cfg_locals.fallback = fallback_view
# 
#         with ConfigError.track(cfg_locals):
#             eval(self._body_code, copy(self._func.__globals__), cfg_locals)
# 
#         added = cfg_locals.revelation()
#         config_summary = ConfigSummary(
#             added,
#             cfg_locals.modified,
#             cfg_locals.typechanges,
#             cfg_locals.fallback_writes,
#             docs=self._var_docs,
#         )
#         # fill in the unused presets
#         recursive_fill_in(cfg_locals, preset)
# 
#         for key, value in cfg_locals.items():
#             try:
#                 config_summary[key] = normalize_or_die(value)
#             except ValueError:
#                 pass
#         return config_summary
# 
# Path: sacred/experiment.py
# class Experiment(Ingredient):
#     def __init__(
#         self,
#         name: Optional[str] = None,
#         ingredients: Sequence[Ingredient] = (),
#         interactive: bool = False,
#         base_dir: Optional[PathType] = None,
#         additional_host_info: Optional[List[HostInfoGetter]] = None,
#         additional_cli_options: Optional[Sequence[CLIOption]] = None,
#         save_git_info: bool = True,
#     ):
#     def main(self, function):
#     def automain(self, function):
#     def option_hook(self, function):
#     def get_usage(self, program_name=None):
#     def run(
#         self,
#         command_name: Optional[str] = None,
#         config_updates: Optional[dict] = None,
#         named_configs: Sequence[str] = (),
#         info: Optional[dict] = None,
#         meta_info: Optional[dict] = None,
#         options: Optional[dict] = None,
#     ) -> Run:
#     def run_commandline(self, argv=None) -> Optional[Run]:
#     def open_resource(self, filename: PathType, mode: str = "r"):
#     def add_resource(self, filename: PathType) -> None:
#     def add_artifact(
#         self,
#         filename: PathType,
#         name: Optional[str] = None,
#         metadata: Optional[dict] = None,
#         content_type: Optional[str] = None,
#     ) -> None:
#     def info(self) -> dict:
#     def log_scalar(self, name: str, value: float, step: Optional[int] = None) -> None:
#     def post_process_name(self, name, ingredient):
#     def get_default_options(self) -> dict:
#     def _create_run(
#         self,
#         command_name=None,
#         config_updates=None,
#         named_configs=(),
#         info=None,
#         meta_info=None,
#         options=None,
#     ):
#     def _check_command(self, cmd_name):
#     def _handle_help(self, args, usage):
# def gather_command_line_options(filter_disabled=None):
# DEFAULT_COMMAND_LINE_OPTIONS = [
#     s3_option,
#     commandline_options.pdb_option,
#     commandline_options.debug_option,
#     file_storage_option,
#     commandline_options.loglevel_option,
#     mongo_db_option,
#     sql_option,
#     commandline_options.capture_option,
#     commandline_options.help_option,
#     commandline_options.print_config_option,
#     commandline_options.name_option,
#     commandline_options.id_option,
#     commandline_options.priority_option,
#     commandline_options.unobserved_option,
#     commandline_options.beat_interval_option,
#     commandline_options.queue_option,
#     commandline_options.force_option,
#     commandline_options.comment_option,
#     commandline_options.enforce_clean_option,
#     tiny_db_option,
# ]


from sacred.config.config_scope import ConfigScope
from sacred.experiment import Experiment, Ingredient
#!/usr/bin/env python
# coding=utf-8



def test_ingredient_config():
    m = Ingredient("somemod")

    @m.config
    def cfg():
        a = 5
        b = "foo"

    assert len(m.configurations) == 1
    cfg = m.configurations[0]

# Path: sacred/config/config_scope.py
# class ConfigScope:
#     def __init__(self, func):
#         self.args, vararg_name, kw_wildcard, _, kwargs = get_argspec(func)
#         assert vararg_name is None, "*args not allowed for ConfigScope functions"
#         assert kw_wildcard is None, "**kwargs not allowed for ConfigScope functions"
#         assert not kwargs, "default values are not allowed for ConfigScope functions"
# 
#         self._func = func
#         self._body_code = get_function_body_code(func)
#         self._var_docs = get_config_comments(func)
#         self.__doc__ = self._func.__doc__
# 
#     def __call__(self, fixed=None, preset=None, fallback=None):
#         """
#         Evaluate this ConfigScope.
# 
#         This will evaluate the function body and fill the relevant local
#         variables into entries into keys in this dictionary.
# 
#         :param fixed: Dictionary of entries that should stay fixed during the
#                       evaluation. All of them will be part of the final config.
#         :type fixed: dict
#         :param preset: Dictionary of preset values that will be available
#                        during the evaluation (if they are declared in the
#                        function argument list). All of them will be part of the
#                        final config.
#         :type preset: dict
#         :param fallback: Dictionary of fallback values that will be available
#                          during the evaluation (if they are declared in the
#                          function argument list). They will NOT be part of the
#                          final config.
#         :type fallback: dict
#         :return: self
#         :rtype: ConfigScope
#         """
#         cfg_locals = dogmatize(fixed or {})
#         fallback = fallback or {}
#         preset = preset or {}
#         fallback_view = {}
# 
#         available_entries = set(preset.keys()) | set(fallback.keys())
# 
#         for arg in self.args:
#             if arg not in available_entries:
#                 raise KeyError(
#                     "'{}' not in preset for ConfigScope. "
#                     "Available options are: {}".format(arg, available_entries)
#                 )
#             if arg in preset:
#                 cfg_locals[arg] = preset[arg]
#             else:  # arg in fallback
#                 fallback_view[arg] = fallback[arg]
# 
#         cfg_locals.fallback = fallback_view
# 
#         with ConfigError.track(cfg_locals):
#             eval(self._body_code, copy(self._func.__globals__), cfg_locals)
# 
#         added = cfg_locals.revelation()
#         config_summary = ConfigSummary(
#             added,
#             cfg_locals.modified,
#             cfg_locals.typechanges,
#             cfg_locals.fallback_writes,
#             docs=self._var_docs,
#         )
#         # fill in the unused presets
#         recursive_fill_in(cfg_locals, preset)
# 
#         for key, value in cfg_locals.items():
#             try:
#                 config_summary[key] = normalize_or_die(value)
#             except ValueError:
#                 pass
#         return config_summary
# 
# Path: sacred/experiment.py
# class Experiment(Ingredient):
#     def __init__(
#         self,
#         name: Optional[str] = None,
#         ingredients: Sequence[Ingredient] = (),
#         interactive: bool = False,
#         base_dir: Optional[PathType] = None,
#         additional_host_info: Optional[List[HostInfoGetter]] = None,
#         additional_cli_options: Optional[Sequence[CLIOption]] = None,
#         save_git_info: bool = True,
#     ):
#     def main(self, function):
#     def automain(self, function):
#     def option_hook(self, function):
#     def get_usage(self, program_name=None):
#     def run(
#         self,
#         command_name: Optional[str] = None,
#         config_updates: Optional[dict] = None,
#         named_configs: Sequence[str] = (),
#         info: Optional[dict] = None,
#         meta_info: Optional[dict] = None,
#         options: Optional[dict] = None,
#     ) -> Run:
#     def run_commandline(self, argv=None) -> Optional[Run]:
#     def open_resource(self, filename: PathType, mode: str = "r"):
#     def add_resource(self, filename: PathType) -> None:
#     def add_artifact(
#         self,
#         filename: PathType,
#         name: Optional[str] = None,
#         metadata: Optional[dict] = None,
#         content_type: Optional[str] = None,
#     ) -> None:
#     def info(self) -> dict:
#     def log_scalar(self, name: str, value: float, step: Optional[int] = None) -> None:
#     def post_process_name(self, name, ingredient):
#     def get_default_options(self) -> dict:
#     def _create_run(
#         self,
#         command_name=None,
#         config_updates=None,
#         named_configs=(),
#         info=None,
#         meta_info=None,
#         options=None,
#     ):
#     def _check_command(self, cmd_name):
#     def _handle_help(self, args, usage):
# def gather_command_line_options(filter_disabled=None):
# DEFAULT_COMMAND_LINE_OPTIONS = [
#     s3_option,
#     commandline_options.pdb_option,
#     commandline_options.debug_option,
#     file_storage_option,
#     commandline_options.loglevel_option,
#     mongo_db_option,
#     sql_option,
#     commandline_options.capture_option,
#     commandline_options.help_option,
#     commandline_options.print_config_option,
#     commandline_options.name_option,
#     commandline_options.id_option,
#     commandline_options.priority_option,
#     commandline_options.unobserved_option,
#     commandline_options.beat_interval_option,
#     commandline_options.queue_option,
#     commandline_options.force_option,
#     commandline_options.comment_option,
#     commandline_options.enforce_clean_option,
#     tiny_db_option,
# ]


# Path: tests/test_modules.py
from sacred.config.config_scope import ConfigScope
from sacred.experiment import Experiment, Ingredient

#!/usr/bin/env python
# coding=utf-8



def test_ingredient_config():
    m = Ingredient("somemod")

    @m.config
    def cfg():
        a = 5
        b = "foo"

    assert len(m.configurations) == 1
    cfg = m.configurations[0]

    assert isinstance(cfg, ConfigScope)