sc2_datasets.utils.zip_utils ============================ .. py:module:: sc2_datasets.utils.zip_utils Classes ------- .. autoapisummary:: sc2_datasets.utils.zip_utils.UnpackZipFileArguments Functions --------- .. autoapisummary:: sc2_datasets.utils.zip_utils.unpack_chunk sc2_datasets.utils.zip_utils.unpack_zipfile Module Contents --------------- .. py:class:: UnpackZipFileArguments(chunk_id: int, zip_path: pathlib.Path, filenames: list[str], path_to_extract: pathlib.Path) Helper class for passing arguments to a multi-threaded unpacking function. :param zip_path: Specifies the path to the archive file that will be extracted. :type zip_path: Path :param filenames: Specifies a list of the filenames which are within the archive and will be extracted. :type filenames: list[str] :param path_to_extract: Specifies the path to which the files will be extracted to. :type path_to_extract: Path .. py:attribute:: chunk_id .. py:attribute:: zip_path .. py:attribute:: filenames .. py:attribute:: path_to_extract .. py:function:: unpack_chunk(unpack_arguments: UnpackZipFileArguments) -> None Helper function for unpacking a chunk of files from an archive. :param unpack_arguments: Specifies the arguments required for unpacking a chunk of files. :type unpack_arguments: UnpackZipFileArguments .. py:function:: unpack_zipfile(destination_dir: pathlib.Path, subdir: str, zip_path: pathlib.Path, n_workers: int) -> pathlib.Path Helper function that unpacks the content of .zip archive. :param destination_dir: Specifies the path where the .zip file will be extracted. :type destination_dir: Path :param subdir: Specifies the subdirectory where the content will be extracted. :type subdir: str :param zip_path: Specifies the path to the zip file that will be extracted. :type zip_path: Path :param n_workers: Specifies the number of workers that will be used for unpacking the archive. :type n_workers: int :returns: Returns a path to the extracted content. :rtype: str :raises Exception: Raises an exception if the number of workers is less or equal to zero. .. rubric:: Examples The use of this method is intended to extract a zipfile. You should set every parameter, destination, subdir, zip_path and n_workers. May help you to work with dataset. The parameters should be set as in the example below. >>> from pathlib import Path >>> unpack_zipfile_object = unpack_zipfile( ... destination_dir=Path("./directory/destination_dir").resolve(), ... subdir="./directory/subdir", ... zip_path=Path("./directory/zip_path").resolve, ... n_workers=1) >>> assert isinstance(destination_dir, Path) >>> assert isinstance(subdir, str) >>> assert isinstance(zip_path, Path) >>> assert isinstance(n_workers, int) >>> assert n_workers >= 1