skillfed

cached-path

A file utility for accessing both local and remote files through a unified interface

cached-path v1.8.10 554.7K downloads/30d#6,032 on PyPI47
Permissive 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) Active released

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-path

uv

uv add cached-path

poetry

poetry add cached-path

Installing 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

Intended Audience :: Science/ResearchLicense :: OSI Approved :: Apache Software LicenseProgramming Language :: Python :: 3Topic :: Scientific/Engineering :: Artificial Intelligence

Tags

unified file access local and remotecache remote files locallydownload and cache with single interfaces3 google cloud storage file accesshuggingface model file download
file-cachingcloud-storageml-workflow

More Artificial Intelligence packages