From 5f6d408ab5979687e6f1f6ce5b5bbbe7de63d428 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Mon, 13 Nov 2023 20:09:43 +0100 Subject: [PATCH] make cleanup --- cwltool/singularity.py | 16 +++++++++------- tests/test_tmpdir.py | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cwltool/singularity.py b/cwltool/singularity.py index 4e5b656627..832d097bbc 100644 --- a/cwltool/singularity.py +++ b/cwltool/singularity.py @@ -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) - image_path = os.path.join(cache_folder,str(dockerRequirement["dockerImageId"])) + image_path = os.path.join(cache_folder, str(dockerRequirement["dockerImageId"])) 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 # 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 = [ diff --git a/tests/test_tmpdir.py b/tests/test_tmpdir.py index 16bd73bb4c..df36e68da7 100644 --- a/tests/test_tmpdir.py +++ b/tests/test_tmpdir.py @@ -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 @@ -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 @@ -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()