Skip to content

download_file_from_github

Downloads a file from a given URL and saves it to a destination path.

Parameters:

Name Type Description Default
url_link str

The URL of the file to download.

required
destination_path str

The path where the file will be saved.

required

Returns:

Type Description
None

This method does not return any values.

Source code in tinybig/util/utility.py
def download_file_from_github(url_link: str, destination_path: str):
    """
    Downloads a file from a given URL and saves it to a destination path.

    Parameters
    ----------
    url_link : str
        The URL of the file to download.
    destination_path : str
        The path where the file will be saved.

    Returns
    -------
    None
        This method does not return any values.
    """
    create_directory_if_not_exists(destination_path)

    response = requests.get(url_link, stream=True)
    if response.status_code == 200:
        with open(destination_path, 'wb') as file:
            for chunk in response.iter_content(1024):  # Download in chunks
                file.write(chunk)
        print(f"File downloaded successfully: {destination_path}")
    else:
        print(f"Failed to download file. Status code: {response.status_code}")