Skip to main content

Snakemake Storage Plugin: LFS

A Snakemake storage plugin for downloading files from Git LFS (Large File Storage) servers with optional local caching.

Features

  • Git LFS protocol: Fetches objects via the Git LFS Batch API
  • Local repo lookup: Checks a local git repository's LFS store before downloading remotely
  • Local caching: Downloaded objects can be cached to avoid redundant transfers
  • Checksum verification: Verifies SHA-256 integrity (the LFS OID is the SHA-256 digest)
  • Authentication: Supports token-based Basic Auth via environment variable
  • Concurrent download control: Limits simultaneous downloads
  • Progress bars: Shows download progress with tqdm
  • Immutable objects: Returns mtime=0 (LFS objects are content-addressed and never change)
  • Environment variable support: Configure via environment variables for CI/CD

Installation

pip install snakemake-storage-plugin-lfs

URL Format

LFS objects are referenced using the lfs:// scheme:

lfs://{oid}/{path}
  • {oid} — SHA-256 hex digest of the object (64 hex characters)
  • {path} — logical file path used as the local filename

Example:

lfs://3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4/data/natura.tiff

Configuration

Register the plugin in your Snakefile:

storage lfs:
    provider="lfs",
    repo_url="https://github.com/org/repo",  # required

Settings

Setting Default Env var Description
repo_url "" SNAKEMAKE_STORAGE_LFS_REPO_URL Git repository URL used to construct the LFS Batch API endpoint (e.g. https://github.com/org/repo). Required.
token_envvar "" — Name of the environment variable containing the authentication token (used as Basic Auth password with username git).
local_repo "" SNAKEMAKE_STORAGE_LFS_LOCAL_REPO Path to a local git repository. Files are looked up by path in the working tree before downloading remotely. If the file exists but its SHA-256 hash does not match the OID, a WorkflowError is raised (the local repo contains a different version). LFS pointer stubs (not-yet-pulled files) are detected and skipped.
cache "" SNAKEMAKE_STORAGE_LFS_CACHE Path to a cache directory for downloaded objects. Set to a path to enable caching; leave empty to disable.
skip_remote_checks False SNAKEMAKE_STORAGE_LFS_SKIP_REMOTE_CHECKS Skip existence/size checks against the remote LFS server. Useful in CI/CD when inputs are known to exist.
max_concurrent_downloads 3 — Maximum number of simultaneous downloads.

Usage

Use lfs:// URLs directly in your rules:

rule use_lfs_file:
    input:
        storage.lfs(
            "lfs://3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4/data/natura.tiff"
        ),
    output:
        "resources/natura.tiff"
    shell:
        "cp {input} {output}"

The plugin will:

  1. Check the local git repository's LFS store (if local_repo is set)
  2. Check the local cache (if cache is set)
  3. If not found locally, query the LFS Batch API for a download URL
  4. Download the object with a progress bar
  5. Verify the SHA-256 checksum against the OID
  6. Store in the cache (if cache is set)

Authentication

To access private repositories, set token_envvar to the name of an environment variable that holds the token:

storage lfs:
    provider="lfs",
    repo_url="https://github.com/org/private-repo",
    token_envvar="GITHUB_TOKEN",
export GITHUB_TOKEN="ghp_..."
snakemake --cores all

CI/CD Configuration

# GitHub Actions example
- name: Run snakemake workflows
  env:
    SNAKEMAKE_STORAGE_LFS_REPO_URL: "https://github.com/org/repo"
    SNAKEMAKE_STORAGE_LFS_SKIP_REMOTE_CHECKS: "1"
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  run: |
    snakemake --cores all

How LFS Objects Are Located

Priority order in managed_retrieve():

  1. Local repo (local_repo setting): Looks up the file by its path in the working tree ({local_repo}/{lfs_path}). LFS pointer stubs are skipped (with a warning). If the file is present but its SHA-256 does not match the OID, a WorkflowError is raised — the local repo contains a different version of the file.
  2. Cache (cache setting): Checks the configured cache directory.
  3. Remote: Queries the LFS Batch API ({repo_url}.git/info/lfs/objects/batch) and downloads from the returned URL.

License

MIT License

Metadata

Release files for snakemake-storage-plugin-lfs 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snakemake-storage-plugin-lfs 0.2.1
File Size Uploaded
snakemake_storage_plugin_lfs-0.2.1.tar.gz 27.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for snakemake-storage-plugin-lfs 0.2.1
File Interpreter ABI Platform
snakemake_storage_plugin_lfs-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 39.0 kB

Release files / snakemake_storage_plugin_lfs-0.2.1.tar.gz

Download URL snakemake_storage_plugin_lfs-0.2.1.tar.gz
Size 27.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a9870c27f074559f80caee7f1cd02a385a4115896c6f2bfbdf53c9a83388f4c0
BLAKE2b-256 checksum
How to use checksums
37018429ad20a40073ddbf6e66cedf4316fdf73affe036fa5cbc3b43fcb611c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.

Transparency log

Release files / snakemake_storage_plugin_lfs-0.2.1-py3-none-any.whl

Download URL snakemake_storage_plugin_lfs-0.2.1-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4703ef225eb7530a54c74b54da1004c90819fb7c0aeb98c09b1f2d34c544b8ba
BLAKE2b-256 checksum
How to use checksums
f61b050345c09cecd32133aae2d03380a79a293e741ef980c010a0b452404274
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page