在磁盘上为singularity镜像创建永久缓存。
项目描述
Singularity-permanent-cache创建磁盘上singularity镜像的永久缓存。它以URI作为参数,并返回镜像的位置。它利用文件锁来防止缓存损坏。
它将使用环境变量 SINGULARITY_PERMANENTCACHEDIR 或 SINGULARITY_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-py3-none-any.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 5a51e25446edf2adec3ab953c3e7e1c41f633bab0d4c6148e98c0a72d2699e23 |
|
MD5 | c93f95c6b973f64f8166f0fac04dd4ab |
|
BLAKE2b-256 | 328951c1ff2394e3c2dd77dce3d43affd36196a6d24756bd24fd5eacd77561a6 |