python/ray/_private/runtime_env/packaging.py
def remove_dir_from_filepaths(base_dir: str, rdir: str):
    """
    base_dir: String path of the directory containing rdir
    rdir: String path of directory relative to base_dir whose contents should
          be moved to its base_dir, its parent directory

    Removes rdir from the filepaths of all files and directories inside it.
    In other words, moves all the files inside rdir to the directory that
    contains rdir. Assumes base_dir's contents and rdir's contents have no
    name conflicts.
    """

    # Move rdir to a temporary directory, so its contents can be moved to
    # base_dir without any name conflicts
    with TemporaryDirectory() as tmp_dir:

        # shutil.move() is used instead of os.rename() in case rdir and tmp_dir
        # are located on separate file systems
        shutil.move(os.path.join(base_dir, rdir), os.path.join(tmp_dir, rdir))

        # Shift children out of rdir and into base_dir
        rdir_children = os.listdir(os.path.join(tmp_dir, rdir))
        for child in rdir_children:
            shutil.move(
                os.path.join(tmp_dir, rdir, child), os.path.join(base_dir, child)
            )

    base_dir: String path of the directory containing rdir
    rdir: String path of directory relative to base_dir whose contents should
          be moved to its base_dir, its parent directory

    Removes rdir from the filepaths of all files and directories inside it.
    In other words, moves all the files inside rdir to the directory that
    contains rdir. Assumes base_dir's contents and rdir's contents have no
    name conflicts.
    
String path of the directory containing rdir
rdir: String path of directory relative to base_dir whose contents should
be moved to its base_dir, its parent directory

Removes rdir from the filepaths of all files and directories inside it.
In other words, moves all the files inside rdir to the directory that
contains rdir. Assumes base_dir's contents and rdir's contents have no
name conflicts.
String path of the directory containing rdir rdir : String path of directory relative to base_dir whose contents should be moved to its base_dir its parent directory Removes rdir from the filepaths of all files and directories inside it . In other words moves all the files inside rdir to the directory that contains rdir . Assumes base_dir ' s contents and rdir ' s contents have no name conflicts .
def remove_dir_from_filepaths(base_dir: str, rdir: str):
    with TemporaryDirectory() as tmp_dir:
        shutil.move(os.path.join(base_dir, rdir), os.path.join(tmp_dir, rdir))
        rdir_children = os.listdir(os.path.join(tmp_dir, rdir))
        for child in rdir_children:
            shutil.move(
                os.path.join(tmp_dir, rdir, child), os.path.join(base_dir, child)
            )
def remove_dir_from_filepaths ( base_dir : str , rdir : str ) : with TemporaryDirectory ( ) as tmp_dir : shutil . move ( os . path . join ( base_dir , rdir ) , os . path . join ( tmp_dir , rdir ) ) rdir_children = os . listdir ( os . path . join ( tmp_dir , rdir ) ) for child in rdir_children : shutil . move ( os . path . join ( tmp_dir , rdir , child ) , os . path . join ( base_dir , child ) )
base_dir: String path of the directory containing rdir
rdir: String path of directory relative to base_dir whose contents should
be moved to its base_dir, its parent directory
base_dir : String path of the directory containing rdir rdir : String path of directory relative to base_dir whose contents should be moved to its base_dir its parent directory
"""
    base_dir: String path of the directory containing rdir
    rdir: String path of directory relative to base_dir whose contents should
          be moved to its base_dir, its parent directory

    Removes rdir from the filepaths of all files and directories inside it.
    In other words, moves all the files inside rdir to the directory that
    contains rdir. Assumes base_dir's contents and rdir's contents have no
    name conflicts.
    """ # Move rdir to a temporary directory, so its contents can be moved to # base_dir without any name conflicts # shutil.move() is used instead of os.rename() in case rdir and tmp_dir # are located on separate file systems # Shift children out of rdir and into base_dir
base_dir
str
rdir
str