def __init__(self, name=None, ingredients=(), interactive=False, base_dir=None): """ Create a new experiment with the given name and optional ingredients. Parameters ---------- name : str, optional Optional name of this experiment, defaults to the filename. (Required in interactive mode) ingredients : list[sacred.Ingredient], optional A list of ingredients to be used with this experiment. interactive : bool, optional If set to True will allow the experiment to be run in interactive mode (e.g. IPython or Jupyter notebooks). However, this mode is discouraged since it won't allow storing the source-code or reliable reproduction of the runs. base_dir : str, optional Optional full path to the base directory of this experiment. This will set the scope for automatic source file discovery. """ caller_globals = inspect.stack()[1][0].f_globals if name is None: if interactive: raise RuntimeError('name is required in interactive mode.') mainfile = caller_globals.get('__file__') if mainfile is None: raise RuntimeError('No main-file found. Are you running in ' 'interactive mode? If so please provide a ' 'name and set interactive=True.') name = os.path.basename(mainfile) if name.endswith('.py'): name = name[:-3] elif name.endswith('.pyc'): name = name[:-4] super(Experiment, self).__init__(path=name, ingredients=ingredients, interactive=interactive, base_dir=base_dir, _caller_globals=caller_globals) self.default_command = None self.command(print_config, unobserved=True) self.command(print_dependencies, unobserved=True) self.command(save_config, unobserved=True) self.command(print_named_configs(self), unobserved=True) self.observers = [] self.current_run = None self.captured_out_filter = None """Filter function to be applied to captured output of a run""" self.option_hooks = [] self.mutex = Lock()
def __init__(self, name=None, ingredients=(), interactive=False, base_dir=None): """ Create a new experiment with the given name and optional ingredients. Parameters ---------- name : str, optional Optional name of this experiment, defaults to the filename. (Required in interactive mode) ingredients : list[sacred.Ingredient], optional A list of ingredients to be used with this experiment. interactive : bool, optional If set to True will allow the experiment to be run in interactive mode (e.g. IPython or Jupyter notebooks). However, this mode is discouraged since it won't allow storing the source-code or reliable reproduction of the runs. base_dir : str, optional Optional full path to the base directory of this experiment. This will set the scope for automatic source file discovery. """ caller_globals = inspect.stack()[1][0].f_globals if name is None: if interactive: raise RuntimeError('name is required in interactive mode.') mainfile = caller_globals.get('__file__') if mainfile is None: raise RuntimeError('No main-file found. Are you running in ' 'interactive mode? If so please provide a ' 'name and set interactive=True.') name = os.path.basename(mainfile) if name.endswith('.py'): name = name[:-3] elif name.endswith('.pyc'): name = name[:-4] super(Experiment, self).__init__(path=name, ingredients=ingredients, interactive=interactive, base_dir=base_dir, _caller_globals=caller_globals) self.default_command = None self.command(print_config, unobserved=True) self.command(print_dependencies, unobserved=True) self.command(save_config, unobserved=True) self.command(print_named_configs(self), unobserved=True) self.observers = [] self.current_run = None self.captured_out_filter = None """Filter function to be applied to captured output of a run""" self.option_hooks = []
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, ): """ Create a new experiment with the given name and optional ingredients. Parameters ---------- name Optional name of this experiment, defaults to the filename. (Required in interactive mode) ingredients : list[sacred.Ingredient], optional A list of ingredients to be used with this experiment. interactive If set to True will allow the experiment to be run in interactive mode (e.g. IPython or Jupyter notebooks). However, this mode is discouraged since it won't allow storing the source-code or reliable reproduction of the runs. base_dir Optional full path to the base directory of this experiment. This will set the scope for automatic source file discovery. additional_host_info Optional dictionary containing as keys the names of the pieces of host info you want to collect, and as values the functions collecting those pieces of information. """ self.additional_host_info = additional_host_info or [] check_additional_host_info(self.additional_host_info) self.additional_cli_options = additional_cli_options or [] caller_globals = inspect.stack()[1][0].f_globals if name is None: if interactive: raise RuntimeError("name is required in interactive mode.") mainfile = caller_globals.get("__file__") if mainfile is None: raise RuntimeError("No main-file found. Are you running in " "interactive mode? If so please provide a " "name and set interactive=True.") name = os.path.basename(mainfile) if name.endswith(".py"): name = name[:-3] elif name.endswith(".pyc"): name = name[:-4] super().__init__( path=name, ingredients=ingredients, interactive=interactive, base_dir=base_dir, _caller_globals=caller_globals, ) self.default_command = None self.command(print_config, unobserved=True) self.command(print_dependencies, unobserved=True) self.command(save_config, unobserved=True) self.command(print_named_configs(self), unobserved=True) self.observers = [] self.current_run = None self.captured_out_filter = None """Filter function to be applied to captured output of a run""" self.option_hooks = []