Skip to main content

Content-addressed caching middleware for Styx

Project description

styxcache

Content-addressed caching middleware for Styx runners.

Wraps any Styx Runner (docker, podman, singularity, local, ...) and persists tool outputs in a content-addressed cache directory. Subsequent invocations with identical inputs (file contents, parameters, wrapper version, container image digest) skip execution and reuse the cached output tree directly.

Usage

from styxdefs import set_global_runner
from styxdocker import DockerRunner
from styxcache import CachingRunner, CachePolicy
from styxcache.backends import docker_digest_resolver

set_global_runner(
    CachingRunner(
        base=DockerRunner(data_dir="/tmp/styx"),
        cache_dir="/mnt/ci-cache/styx",
        policy=CachePolicy(image_digest=docker_digest_resolver),
    )
)

# Use any Styx wrapper as usual; repeated calls with the same inputs are cached.

How the key is computed

sha256(
    metadata.id,
    metadata.package,
    metadata.name,
    image_digest,
    sorted(env_allowlist_values),
    params_dict_with_input_paths_replaced_by_content_hashes,
)
  • metadata.id — fingerprints the wrapper version; changes when the wrapper changes.
  • image_digest — resolves the container image tag to an immutable digest.
  • params_dict is walked recursively; any value matching a path passed to execution.input_file() is replaced with the blake3 hash of that file (or directory tree, when resolve_parent=True).
  • Input file hashing uses blake3 (fast, cryptographic, parallelizable).

Output location

execution.output_file("out.nii") returns cache_dir/<key>/out.nii directly. The cache directory is the output tree, so downstream consumers of the returned paths read from the cache with no additional materialisation step.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

styxcache-0.2.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

styxcache-0.2.0-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file styxcache-0.2.0.tar.gz.

File metadata

  • Download URL: styxcache-0.2.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for styxcache-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dea81ee9df870fee3bdedade2fafa7156393031847286b0e5830575c71b4d28c
MD5 7f750707166f026debae5c9a7c5eff33
BLAKE2b-256 2f7db550b50144be14478eef5be3d4b90224052e2cf412ccba4addfff6aa577a

See more details on using hashes here.

File details

Details for the file styxcache-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: styxcache-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for styxcache-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c40d5abc56b4b5cdb804e450916f01f625dd707a6a1c6f918eb3f7a02ca5cf6
MD5 51995fc8b72812ae3510503b0af4cefe
BLAKE2b-256 e1fbf09c395fa0f45bb123d0b8806ec0acaf7322cf3ac546398ef3194f57948c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page