python/ray/_private/runtime_env/packaging.py
def unzip_package(
    package_path: str,
    target_dir: str,
    remove_top_level_directory: bool,
    unlink_zip: bool,
    logger: Optional[logging.Logger] = default_logger,
):
    """
    Unzip the compressed package contained at package_path and store the
    contents in target_dir. If remove_top_level_directory is True, the function
    will automatically remove the top_level_directory and store the contents
    directly in target_dir. If unlink_zip is True, the function will unlink the
    zip file stored at package_path.
    """
    try:
        os.mkdir(target_dir)
    except FileExistsError:
        logger.info(f"Directory at {target_dir} already exists")

    logger.debug(f"Unpacking {package_path} to {target_dir}")

    with ZipFile(str(package_path), "r") as zip_ref:
        zip_ref.extractall(target_dir)
    if remove_top_level_directory:
        top_level_directory = get_top_level_dir_from_compressed_package(package_path)
        if top_level_directory is None:
            raise ValueError(
                "The package at package_path must contain "
                "a single top level directory. Make sure there "
                "are no hidden files at the same level as the "
                "top level directory."
            )

        remove_dir_from_filepaths(target_dir, top_level_directory)

    if unlink_zip:
        Path(package_path).unlink()

    Unzip the compressed package contained at package_path and store the
    contents in target_dir. If remove_top_level_directory is True, the function
    will automatically remove the top_level_directory and store the contents
    directly in target_dir. If unlink_zip is True, the function will unlink the
    zip file stored at package_path.
    
Unzip the compressed package contained at package_path and store the
contents in target_dir. If remove_top_level_directory is True, the function
will automatically remove the top_level_directory and store the contents
directly in target_dir. If unlink_zip is True, the function will unlink the
zip file stored at package_path.
Unzip the compressed package contained at package_path and store the contents in target_dir . If remove_top_level_directory is True the function will automatically remove the top_level_directory and store the contents directly in target_dir . If unlink_zip is True the function will unlink the zip file stored at package_path .
def unzip_package(
    package_path: str,
    target_dir: str,
    remove_top_level_directory: bool,
    unlink_zip: bool,
    logger: Optional[logging.Logger] = default_logger,
):
    try:
        os.mkdir(target_dir)
    except FileExistsError:
        logger.info(f"Directory at {target_dir} already exists")
    logger.debug(f"Unpacking {package_path} to {target_dir}")
    with ZipFile(str(package_path), "r") as zip_ref:
        zip_ref.extractall(target_dir)
    if remove_top_level_directory:
        top_level_directory = get_top_level_dir_from_compressed_package(package_path)
        if top_level_directory is None:
            raise ValueError(
                "The package at package_path must contain "
                "a single top level directory. Make sure there "
                "are no hidden files at the same level as the "
                "top level directory."
            )
        remove_dir_from_filepaths(target_dir, top_level_directory)
    if unlink_zip:
        Path(package_path).unlink()
def unzip_package ( package_path : str , target_dir : str , remove_top_level_directory : bool , unlink_zip : bool , logger : Optional [ logging . Logger ] = default_logger , ) : try : os . mkdir ( target_dir ) except FileExistsError : logger . info ( f"Directory at {target_dir} already exists" ) logger . debug ( f"Unpacking {package_path} to {target_dir}" ) with ZipFile ( str ( package_path ) , "r" ) as zip_ref : zip_ref . extractall ( target_dir ) if remove_top_level_directory : top_level_directory = get_top_level_dir_from_compressed_package ( package_path ) if top_level_directory is None : raise ValueError ( "The package at package_path must contain " "a single top level directory. Make sure there " "are no hidden files at the same level as the " "top level directory." ) remove_dir_from_filepaths ( target_dir , top_level_directory ) if unlink_zip : Path ( package_path ) . unlink ( )
Unzip the compressed package contained at package_path and store the
contents in target_dir.
Unzip the compressed package contained at package_path and store the contents in target_dir .
"""
    Unzip the compressed package contained at package_path and store the
    contents in target_dir. If remove_top_level_directory is True, the function
    will automatically remove the top_level_directory and store the contents
    directly in target_dir. If unlink_zip is True, the function will unlink the
    zip file stored at package_path.
    """
package_path
str
target_dir
str
remove_top_level_directory
bool
unlink_zip
bool
logger
Optional[logging.Logger]