Skip to content

Commit

Permalink
make cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Nov 13, 2023
1 parent c0fd698 commit 5f6d408
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions cwltool/singularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,22 @@ def get_image(
cache_folder = os.environ["SINGULARITY_PULLFOLDER"]

if "dockerFile" in dockerRequirement:
if cache_folder is None: # if environment variables were not set
if cache_folder is None: # if environment variables were not set
cache_folder = create_tmp_dir(tmp_outdir_prefix)

Check warning on line 162 in cwltool/singularity.py

View check run for this annotation

Codecov / codecov/patch

cwltool/singularity.py#L162

Added line #L162 was not covered by tests

image_path = os.path.join(cache_folder,str(dockerRequirement["dockerImageId"]))
image_path = os.path.join(cache_folder, str(dockerRequirement["dockerImageId"]))

Check warning on line 164 in cwltool/singularity.py

View check run for this annotation

Codecov / codecov/patch

cwltool/singularity.py#L164

Added line #L164 was not covered by tests
if not os.path.exists(image_path):
# otherwise will prompt user if want to continue if exists
# otherwise will prompt user if want to continue if exists
absolute_path = os.path.abspath(cache_folder)
dockerfile_path = os.path.join(absolute_path, "Dockerfile")
singularityfile_path = dockerfile_path+'.def'
singularityfile_path = dockerfile_path + ".def"
custom_env = os.environ.copy()
custom_env['APPTAINER_TMPDIR'] = absolute_path
custom_env["APPTAINER_TMPDIR"] = absolute_path

Check warning on line 171 in cwltool/singularity.py

View check run for this annotation

Codecov / codecov/patch

cwltool/singularity.py#L167-L171

Added lines #L167 - L171 were not covered by tests
# if you do not set APPTAINER_TMPDIR will crash
# WARNING: 'nodev' mount option set on /tmp, it could be a source of failure during build process
# FATAL: Unable to create build: 'noexec' mount option set on /tmp, temporary root filesystem won't be usable at this location
# WARNING: 'nodev' mount option set on /tmp, it could be a
# source of failure during build process
# FATAL: Unable to create build: 'noexec' mount option set on
# /tmp, temporary root filesystem won't be usable at this location
with open(dockerfile_path, "w") as dfile:
dfile.write(dockerRequirement["dockerFile"])
cmd = [

Check warning on line 179 in cwltool/singularity.py

View check run for this annotation

Codecov / codecov/patch

cwltool/singularity.py#L178-L179

Added lines #L178 - L179 were not covered by tests
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tmpdir.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Test that all temporary directories respect the --tmpdir-prefix and --tmp-outdir-prefix options."""
import re
import shutil
import subprocess
import sys
import shutil
from pathlib import Path
from typing import List, cast

Expand All @@ -15,10 +15,10 @@
from cwltool.command_line_tool import CommandLineTool
from cwltool.context import LoadingContext, RuntimeContext
from cwltool.docker import DockerCommandLineJob
from cwltool.singularity import SingularityCommandLineJob
from cwltool.job import JobBase
from cwltool.main import main
from cwltool.pathmapper import MapperEnt
from cwltool.singularity import SingularityCommandLineJob
from cwltool.stdfsaccess import StdFsAccess
from cwltool.update import INTERNAL_VERSION, ORIGINAL_CWLVERSION
from cwltool.utils import create_tmp_dir
Expand Down Expand Up @@ -170,7 +170,7 @@ def test_dockerfile_tmpdir_prefix(tmp_path: Path, monkeypatch: pytest.MonkeyPatc
def test_dockerfile_singularity_build(monkeypatch: pytest.MonkeyPatch) -> None:
"""Test that SingularityCommandLineJob.get_image builds a Dockerfile with Singularity."""
# cannot use /tmp for the variable APPTAINER_TMPDIR unless have root permissions
# FATAL: Unable to create build: 'noexec' mount option set on /tmp, temporary root filesystem
# FATAL: Unable to create build: 'noexec' mount option set on /tmp, temporary root filesystem
# won't be usable at this location
# Will use current working directory instead
tmp_path = Path.cwd()
Expand Down

0 comments on commit 5f6d408

Please sign in to comment.