{"id":4533,"library":"fastdownload","title":"Fastdownload","description":"Fastdownload is a Python library designed for easily downloading, verifying, and extracting data archives. It ensures users always have the latest versions of datasets or other files by checking against file size and hash information. The library is a core component of the fastai ecosystem for managing datasets. The current version is 0.0.7, and releases occur as needed for bug fixes and new features.","status":"active","version":"0.0.7","language":"en","source_language":"en","source_url":"https://github.com/fastai/fastdownload/tree/master/","tags":["downloading","data","utility","fastai","archive","extraction"],"install":[{"cmd":"pip install fastdownload","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Provides core utilities and extensions for fastai projects, which fastdownload relies on.","package":"fastcore","optional":false},{"reason":"Used for displaying progress bars during downloads.","package":"fastprogress","optional":false}],"imports":[{"note":"The primary class for managing downloads and extractions.","symbol":"FastDownload","correct":"from fastdownload import FastDownload"},{"note":"While 'from fastdownload import download_url' often works due to internal imports, the canonical path for direct access to the helper function is within `fastdownload.core`.","wrong":"from fastdownload import download_url","symbol":"download_url","correct":"from fastdownload.core import download_url"}],"quickstart":{"code":"import os\nimport tempfile\nimport shutil\nfrom pathlib import Path\nfrom fastdownload import FastDownload\n\n# Create a temporary directory for demonstration\ntmp_dir = Path(tempfile.mkdtemp())\n\ntry:\n    fd = FastDownload(base=tmp_dir)\n    # URL for a small, publicly available archive (e.g., MNIST tiny dataset from fast.ai)\n    test_url = 'https://s3.amazonaws.com/fast-ai-sample/mnist_tiny.tgz'\n    \n    print(f\"Downloading and extracting from {test_url} to {tmp_dir}...\")\n    extracted_path = fd.get(test_url)\n    \n    print(f\"Successfully downloaded and extracted to: {extracted_path}\")\n    print(f\"Contents of the extracted directory: {list(extracted_path.iterdir())}\")\n    \n    # Example of downloading only without extraction\n    print(f\"\\nDownloading only (no extraction) from {test_url} to {tmp_dir / 'archive'}...\")\n    downloaded_file_path = fd.download(test_url)\n    print(f\"Successfully downloaded to: {downloaded_file_path}\")\n\nfinally:\n    # Clean up the temporary directory\n    if tmp_dir.exists():\n        print(f\"\\nCleaning up temporary directory: {tmp_dir}\")\n        shutil.rmtree(tmp_dir)\n","lang":"python","description":"This quickstart demonstrates how to use `FastDownload` to download and extract a remote archive to a temporary directory. It also shows how to download a file without immediate extraction. The `base` parameter is used to direct all downloaded and extracted content to a specified location, overriding the default `~/.fastdownload`."},"warnings":[{"fix":"Initialize `FastDownload` with a `base` parameter pointing to a preferred storage location, e.g., `FastDownload(base=Path('/path/to/my/data'))`.","message":"By default, fastdownload stores archives in `~/.fastdownload/archive` and extracts data to `~/.fastdownload/data`. This can fill up disk space if not managed.","severity":"gotcha","affected_versions":"All versions"},{"fix":"To force a re-download regardless of local state or checks, use `fd.get(url, force=True)` or `fd.download(url, force=True)`.","message":"Fastdownload will automatically verify file sizes and hashes if a `download_checks.py` file is present (typically generated when publishing datasets with fastdownload). If local files don't match, it may re-download.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always verify the package source and use `pip install fastdownload` to ensure you're getting the correct Python library.","message":"There is unrelated adware also named 'Fastdownload' that can cause browser issues. Ensure you are installing the Python library `fastdownload` (by fastai) and not any other software.","severity":"gotcha","affected_versions":"N/A (name collision)"},{"fix":"Choose the method that matches your intended operation: `fd.get(url)` for full download and extraction, `fd.download(url)` for just the archive, or `fd.extract(url)` if the archive is already present.","message":"The `FastDownload` class provides `get`, `download`, and `extract` methods for different behaviors. `get` downloads and extracts, `download` only downloads, and `extract` only extracts (assuming the file is already downloaded). Confusing these can lead to unexpected behavior.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}