espnet2.main_funcs.pack_funcs.pack
Less than 1 minute
espnet2.main_funcs.pack_funcs.pack
espnet2.main_funcs.pack_funcs.pack(files: Dict[str, str | Path], yaml_files: Dict[str, str | Path], outpath: str | Path, option: Iterable[str | Path] = ())
Pack files and YAML files into an archive, creating a metadata YAML file.
This function validates the existence of the specified files and directories, transforms their paths to relative or resolved paths, and then creates an archive containing all files along with a metadata file that includes details such as the current timestamp and the versions of Python and any installed packages.
- Parameters:
- files (Dict *[*str , Union *[*str , Path ] ]) – A dictionary mapping keys to file paths that need to be packed.
- yaml_files (Dict *[*str , Union *[*str , Path ] ]) – A dictionary mapping keys to YAML file paths that need to be packed.
- outpath (Union *[*str , Path ]) – The output path for the created archive.
- option (Iterable *[*Union *[*str , Path ] ] , optional) – Additional files or directories to include in the archive. Defaults to an empty tuple.
- Raises:FileNotFoundError – If any of the specified files or directories do not exist.
Examples
>>> pack(
... files={'model': 'model.pth'},
... yaml_files={'config': 'config.yaml'},
... outpath='output.tar',
... option=['extra_file.txt']
... )
Generate: output.tar