def _save_options(opt): if opt.output: out_path = Path(opt.output).parent out_path.mkdir(exist_ok=True, parents=True) save_options_to_config(str(out_path / formats.get_config_filename(__file__)), OrderedDict(sorted(opt.items())) )
def save_config(output_dir: Path, opt: dict, script: str): """ Quick wrapper for save_options_to_config. Args: output_dir (Path): Path to the output directory (does not need to exist) opt (dict): opt-structure to be saved script (str): path/name of the invoking script (becomes name of the .ini) usually ``__file__`` """ output_dir.mkdir(parents=True, exist_ok=True) opt = remove_none_dict_entries(opt) # temporary fix (see docstring) opt = convert_paths_in_dict_to_strings(opt) save_options_to_config(output_dir / formats.get_config_filename(script), dict(sorted(opt.items())) )
def _save_options(opt): if opt.output: os.makedirs(opt.output, exist_ok=True) save_options_to_config(os.path.join(opt.output, formats.get_config_filename(__file__)), OrderedDict(sorted(opt.items())) )
def _save_options_to_config(opt): with suppress(IOError): save_options_to_config(formats.get_config_filename(__file__), OrderedDict(sorted(opt.items())))
def _save_options(opt: DotDict) -> None: if opt.output: os.makedirs(opt.output, exist_ok=True) save_options_to_config( Path(opt.output) / formats.get_config_filename(__file__), OrderedDict(sorted(opt.items())))