跳转到主要内容

在磁盘上为singularity镜像创建永久缓存。

项目描述

Singularity-permanent-cache创建磁盘上singularity镜像的永久缓存。它以URI作为参数,并返回镜像的位置。它利用文件锁来防止缓存损坏。

它将使用环境变量 SINGULARITY_PERMANENTCACHEDIRSINGULARITY_CACHEDIR 来确定缓存的位置。或者,也可以使用命令行上的 -d--cache-dir 标志来设置缓存目录。

singularity-permanent-cache 命令可以在脚本中使用。它考虑到多进程的使用:文件锁将防止多个 singularity-permanent-cache 实例运行时缓存被损坏。它可以在如下脚本中使用:

#!/usr/bin/env bash
set -eu -o pipefail

export SINGULARITY_PERMANENTCACHEDIR=$HOME/.singularity/permanent_cache
MY_IMAGE_URI="docker://debian:buster-slim"
IMAGE_LOCATION=$(singularity-permanent-cache $MY_IMAGE_URI)

cluster_submit "singularity exec $IMAGE_LOCATION echo 'Hello world!'"

Singularity-permanent-cache 如果缓存中尚未存在,将会下载 debian buster slim 镜像。如果它已经在缓存中,则不会下载任何内容。

用法

除了 singularity-permanent-cache 之外,安装包时还会将 spc 添加到 PATH 中作为快捷方式。 singularity-permanent-cache 也可以作为独立的脚本 singularity_permanent_cache.py 使用。

singularity-permant-cache 没有任何依赖项,只需现代 Python 版本(3.5 或更高版本)。

usage: singularity-permanent-cache [-h] [-d CACHE_DIR] [-s SINGULARITY_EXE]
                               [--which-cache] [-v] [-q]
                               <IMAGE>

Creates a permanent cache on disk for singularity images. Returns the location
of the image in the cache. WARNING: This program will never check if a newer
image is available. Make sure unique tags or hashes are used!

positional arguments:
  <IMAGE>               The singularity URI to the image. For example:
                        'docker://debian:buster-slim'

optional arguments:
  -h, --help            show this help message and exit
  -d CACHE_DIR, --cache-dir CACHE_DIR
                        Path to the cache location. Uses the
                        SINGULARITY_PERMANENTCACHEDIR, or SINGULARITY_CACHEDIR
                        environment variable by default.
  -s SINGULARITY_EXE, --singularity-exe SINGULARITY_EXE
                        Path to singularity executable.
  --which-cache         Show which cache the program will use and exit.
  -v, --verbose         Increase log verbosity. Can be used multiple times.
  -q, --quiet           Decrease log verbosity. Can be used multiple times.

致谢

非常感谢 @TMiguelT、@illusional 和 @vsoch 对 Cromwell 的这个 PR 的建设性反馈,这促使开发了此程序。

文件锁实现基于 py-filelock。非常感谢 @benediktschmitt 及其贡献者,他们使此文件锁示例成为公共领域。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装包 的信息。

源分布

singularity-permanent-cache-1.0.0a0.tar.gz (7.7 kB 查看哈希值)

上传时间

构建分布

singularity_permanent_cache-1.0.0a0-py3-none-any.whl (9.4 kB 查看哈希值)

上传时间 Python 3

支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误记录StatusPageStatusPage状态页面