tinker_cookbook.weights.download
tinker_cookbook.weights.download(tinker_path, output_dir, base_url)
Download a checkpoint from Tinker storage to local disk.
Fetches a signed URL via the Tinker SDK, downloads the archive, and extracts it with security validation (rejects symlinks and path traversal).
Parameters:
- tinker_path (str) – Tinker checkpoint path, e.g.
"tinker://<run_id>/sampler_weights/final". - output_dir (str) – Local directory where the checkpoint will be extracted.
- base_url (str | None) – Custom Tinker service URL. If
None(default), uses the default Tinker service endpoint (orTINKER_BASE_URLenvironment variable if set).
Returns: Path to the extracted checkpoint directory.
Raises:
- WeightsDownloadError: If the archive contains unsafe entries.
- urllib.error.URLError: If the download fails.
from tinker_cookbook import weights
# Download from default Tinker service
adapter_dir = weights.download(
tinker_path="tinker://run-id/sampler_weights/final",
output_dir="./adapter",
)
# Download from a custom Tinker deployment
adapter_dir = weights.download(
tinker_path="tinker://run-id/sampler_weights/final",
output_dir="./adapter",
base_url="https://tinker.my-company.com",
)