Skip to content

Commit d6000d3

Browse files
authored
fix cid default bug (#971)
* synchronize default value of cidfile_{dir,prefix}
1 parent 984ad48 commit d6000d3

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

cwltool/argparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
5858
cidgroup.add_argument(
5959
"--cidfile-dir", type=Text, help="Directory for storing the Docker "
6060
"container ID file. The default is the current directory",
61-
default="", dest="cidfile_dir")
61+
default=None, dest="cidfile_dir")
6262

6363
cidgroup.add_argument(
6464
"--cidfile-prefix", type=Text,
6565
help="Specify a prefix to the container ID filename. "
6666
"Final file name will be followed by a timestamp. The default is no prefix.",
67-
default="", dest="cidfile_prefix")
67+
default=None, dest="cidfile_prefix")
6868

6969
parser.add_argument("--tmpdir-prefix", type=Text,
7070
help="Path prefix for temporary directories",

cwltool/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def __init__(self, kwargs=None):
122122
self.on_error = "stop" # type: Text
123123
self.strict_memory_limit = False # type: bool
124124

125-
self.record_container_id = None
125+
self.record_container_id = False
126126
self.cidfile_dir = None
127127
self.cidfile_prefix = None
128128

cwltool/docker.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,9 @@ def create_runtime(self, env, runtimeContext):
338338
runtime.append(u"--env=HOME=%s" % self.builder.outdir)
339339

340340
# add parameters to docker to write a container ID file
341-
if runtimeContext.record_container_id is not None:
341+
if runtimeContext.record_container_id is True:
342342
cidfile_dir = runtimeContext.cidfile_dir
343-
if cidfile_dir != "":
343+
if cidfile_dir is not None:
344344
if not os.path.isdir(cidfile_dir):
345345
_logger.error("--cidfile-dir %s error:\n%s", cidfile_dir,
346346
cidfile_dir + " is not a directory or "
@@ -353,7 +353,7 @@ def create_runtime(self, env, runtimeContext):
353353
else:
354354
cidfile_dir = os.getcwd()
355355
cidfile_name = datetime.datetime.now().strftime("%Y%m%d%H%M%S-%f") + ".cid"
356-
if runtimeContext.cidfile_prefix != "":
356+
if runtimeContext.cidfile_prefix is not None:
357357
cidfile_name = str(runtimeContext.cidfile_prefix + "-" + cidfile_name)
358358
cidfile_path = os.path.join(cidfile_dir, cidfile_name)
359359
runtime.append(u"--cidfile=%s" % cidfile_path)

tests/test_examples.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
from cwltool.resolver import Path
2121
from cwltool.process import CWL_IANA
2222

23-
from .util import (get_data, get_main_output, get_windows_safe_factory, needs_docker,
23+
from .util import (get_data, get_main_output, get_windows_safe_factory,
24+
needs_docker, working_directory,
2425
needs_singularity, temp_dir, windows_needs_docker)
2526

2627

@@ -712,6 +713,18 @@ def test_record_container_id():
712713
assert len(os.listdir(cid_dir)) == 2
713714

714715

716+
@needs_docker
717+
def test_do_not_record_container_id(tmpdir):
718+
with temp_dir('cidr') as cid_dir:
719+
with working_directory(cid_dir):
720+
error_code, _, stderr = get_main_output(
721+
["--outdir", str(tmpdir),
722+
get_data("tests/wf/cache_test_workflow.cwl")])
723+
assert "completed success" in stderr
724+
assert error_code == 0
725+
assert len(os.listdir(cid_dir)) == 0
726+
727+
715728
@needs_docker
716729
def test_wf_without_container():
717730
test_file = "hello-workflow.cwl"

0 commit comments

Comments
 (0)