From 8c3420ea5edd9b4cbbe859a95911781c5659ecc7 Mon Sep 17 00:00:00 2001 From: Anton Khodak Date: Fri, 23 Feb 2018 13:53:06 +0200 Subject: [PATCH] Set TMPDIR on MacOS to be under the shared volume by default --- cwltool/argparser.py | 7 +++++-- cwltool/main.py | 13 +++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/cwltool/argparser.py b/cwltool/argparser.py index 53f2dba28..549497e5e 100644 --- a/cwltool/argparser.py +++ b/cwltool/argparser.py @@ -15,6 +15,9 @@ _logger = logging.getLogger("cwltool") +DEFAULT_TMP_PREFIX = "tmp" + + def arg_parser(): # type: () -> argparse.ArgumentParser parser = argparse.ArgumentParser(description='Reference executor for Common Workflow Language') parser.add_argument("--basedir", type=Text) @@ -71,12 +74,12 @@ def arg_parser(): # type: () -> argparse.ArgumentParser parser.add_argument("--tmpdir-prefix", type=Text, help="Path prefix for temporary directories", - default="tmp") + default=DEFAULT_TMP_PREFIX) exgroup = parser.add_mutually_exclusive_group() exgroup.add_argument("--tmp-outdir-prefix", type=Text, help="Path prefix for intermediate output directories", - default="tmp") + default=DEFAULT_TMP_PREFIX) exgroup.add_argument("--cachedir", type=Text, default="", help="Directory to cache intermediate workflow outputs to avoid recomputing steps.") diff --git a/cwltool/main.py b/cwltool/main.py index 00ffb7310..27dc47c63 100755 --- a/cwltool/main.py +++ b/cwltool/main.py @@ -17,11 +17,12 @@ import ruamel.yaml as yaml import schema_salad.validate as validate import six + from schema_salad.ref_resolver import Loader, file_uri, uri_file_path from schema_salad.sourceline import strip_dup_lineno from . import draft2tool, workflow -from .argparser import arg_parser, generate_parser +from .argparser import arg_parser, generate_parser, DEFAULT_TMP_PREFIX from .cwlrdf import printdot, printrdf from .errors import UnsupportedRequirement, WorkflowException from .executors import SingleJobExecutor, MultithreadedJobExecutor @@ -529,8 +530,16 @@ def main(argsl=None, # type: List[str] if isinstance(tool, int): return tool + # If on MacOS platform, TMPDIR must be set to be under one of the shared volumes in Docker for Mac + # More info: https://dockstore.org/docs/faq + if sys.platform == "darwin": + tmp_prefix = "tmp_outdir_prefix" + default_mac_path = "/private/tmp/docker_tmp" + if getattr(args, tmp_prefix) and getattr(args, tmp_prefix) == DEFAULT_TMP_PREFIX: + setattr(args, tmp_prefix, default_mac_path) + for dirprefix in ("tmpdir_prefix", "tmp_outdir_prefix", "cachedir"): - if getattr(args, dirprefix) and getattr(args, dirprefix) != 'tmp': + if getattr(args, dirprefix) and getattr(args, dirprefix) != DEFAULT_TMP_PREFIX: sl = "/" if getattr(args, dirprefix).endswith("/") or dirprefix == "cachedir" else "" setattr(args, dirprefix, os.path.abspath(getattr(args, dirprefix)) + sl)