Skip to content

Commit 890806a

Browse files
uniquegtetron
authored andcommitted
Added support for Singularity environment variables and , enabling pre-fetching of images when executing workflows with the --singularity flag on an HPC without network access (#695)
1 parent 9564713 commit 890806a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

cwltool/singularity.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,22 @@ def get_image(dockerRequirement, pull_image, dry_run=False):
3737
string=dockerRequirement["dockerPull"]) + ".img"
3838
dockerRequirement["dockerPull"] = "docker://" + dockerRequirement["dockerPull"]
3939

40-
# check to see if the Singularity container is already downloaded
41-
if os.path.isfile(dockerRequirement["dockerImageId"]):
40+
# check if Singularity image is available in $SINGULARITY_CACHEDIR
41+
if "SINGULARITY_CACHEDIR" in os.environ \
42+
and os.path.isfile(os.path.join(os.environ["SINGULARITY_CACHEDIR"], dockerRequirement["dockerImageId"])):
43+
_logger.info("Using local copy of Singularity image found in $SINGULARITY_CACHEDIR")
44+
dockerRequirement["dockerImageId"] = os.path.join(os.environ["SINGULARITY_CACHEDIR"], dockerRequirement["dockerImageId"])
45+
found = True
46+
47+
# check if Singularity image is available in $SINGULARITY_PULLFOLDER
48+
elif "SINGULARITY_PULLFOLDER" in os.environ \
49+
and os.path.isfile(os.path.join(os.environ["SINGULARITY_PULLFOLDER"], dockerRequirement["dockerImageId"])):
50+
_logger.info("Using local copy of Singularity image found in $SINGULARITY_PULLFOLDER")
51+
dockerRequirement["dockerImageId"] = os.path.join(os.environ["SINGULARITY_PULLFOLDER"], dockerRequirement["dockerImageId"])
52+
found = True
53+
54+
# check if Singularity image is available in current working directory
55+
elif os.path.isfile(dockerRequirement["dockerImageId"]):
4256
_logger.info("Using local copy of Singularity image")
4357
found = True
4458

0 commit comments

Comments
 (0)