cached-path
A file utility for accessing both local and remote files through a unified interface
What it is and what it does
cached-path is a file utility that abstracts away the difference between local paths and remote URLs, letting you treat them uniformly. Pass it a local path, HTTP URL, S3 URI, Google Cloud Storage path, or HuggingFace Hub reference—it checks if the file exists locally, downloads and caches it if remote, and returns the local path. It also supports extracting specific files from tar and zip archives on the fly.
The package is built for AI/ML workflows where models and datasets live in different places (local disk, cloud storage, model hubs) and you want a single code path to handle all of them. It handles authentication via custom headers, manages a configurable cache directory (defaulting to ~/.cache/cached_path/), and uses filelock to coordinate concurrent access.
Use it for:
- Download and cache model weights from HuggingFace Hub in a single call without manual path logic.
- Build data pipelines that work with datasets stored on S3, Google Cloud Storage, or local disk using identical code.
- Extract a specific file from a remote tarball or zipfile and cache it locally without manual archive handling.
- Authenticate to private repositories using bearer tokens and cache the downloaded files automatically.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a unified interface to access local and remote files (HTTP, HTTPS, S3, Google Cloud Storage, HuggingFace Hub) with automatic caching and archive extraction.
Yes. The package solves a real problem in ML/data workflows—unifying file access across local and cloud storage—with low install friction, active maintenance, no known vulnerabilities, and permissive licensing. It's a thin, focused utility that does one thing well and integrates cleanly with common cloud providers and model hubs.
Install
cached-path on PyPI
pip
pip install cached-pathuv
uv add cached-pathpoetry
poetry add cached-pathInstalling cached-path
Before you install
Low install friction with a pure Python wheel. Depends on requests, rich, filelock, boto3, google-cloud-storage, huggingface-hub, and packaging. Actively maintained with recent commits and no archived status.
License in practice
Licensed under Apache 2.0 (permissive), allowing commercial and derivative use with minimal restrictions—just retain license notices and disclose modifications.
Quickstart
pip install cached-path
from cached_path import cached_path
# Download and cache a remote file
local_path = cached_path("https://example.com/model.bin")
# Or access a HuggingFace Hub file
local_path = cached_path("hf://epwalsh/bert-xsmall-dummy/pytorch_model.bin")
# Extract a file from a remote archive
local_path = cached_path("model.tar.gz!weights.th", extract_archive=True)
Requires Python 3.9 or later
Verify before relying
- Whether beaker:// URL support requires optional beaker-py installation or is enabled by default
- Performance characteristics when caching large files or handling concurrent access via filelock
Package facts
| License | Apache License Version 2.0, January 2004 https://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 7 — requests, rich, filelock, boto3, google-cloud-storage, huggingface-hub, packaging |
| Maintenance | actively maintained — 147 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 554,689/month — #6,032 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cached_path-1.8.10-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
truss-transferDownloads and resolves Baseten Pointers (bptr)…
unclear · top 15,000 on PyPI
huggingfaceThis package provides a unified interface to…
permissive · top 15,000 on PyPI
hf-transferAccelerates file transfers to and from the…
unclear · top 5,000 on PyPI
requests-cacheAdds persistent HTTP caching to the requests…
permissive · top 5,000 on PyPI
hfA command-line interface for interacting with…
permissive · top 15,000 on PyPI
cloudpathlibProvides pathlib-style classes for reading,…
permissive · top 1,000 on PyPI
datasetsLoads and preprocesses datasets from the…
permissive · top 1,000 on PyPI
universal-pathlibUniversal Pathlib provides a pathlib.Path-like…
permissive · top 1,000 on PyPI