Skip to content

Commit 429dac4

Browse files
committed
apply suggestions
1 parent 972aa86 commit 429dac4

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

cwltool/job.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ def add_volumes(self, pathmapper, runtime):
364364
docker_windows_path_adjust(vol.target)))
365365

366366
def run(self, pull_image=True, rm_container=True,
367-
record_container_id=False, cidfile_dir="/tmp/",
367+
record_container_id=False, cidfile_dir="",
368368
cidfile_prefix="",
369369
rm_tmpdir=True, move_outputs="move", **kwargs):
370370
# type: (bool, bool, bool, Text, Text, bool, Text, **Any) -> None
@@ -469,21 +469,22 @@ def run(self, pull_image=True, rm_container=True,
469469

470470
# add parameters to docker to write a container ID file
471471
if record_container_id:
472-
if cidfile_dir:
472+
if cidfile_dir != "":
473473
if not os.path.isdir(cidfile_dir):
474474
_logger.error("--cidfile-dir %s error:\n%s", cidfile_dir,
475-
cidfile_dir + " is not a directory or directory doesn't exist, please check it first")
476-
exit(-1)
475+
cidfile_dir + " is not a directory or "
476+
"directory doesn't exist, please check it first")
477+
exit(2)
477478
if not os.path.exists(cidfile_dir):
478479
_logger.error("--cidfile-dir %s error:\n%s", cidfile_dir,
479480
"directory doesn't exist, please create it first")
480-
exit(-1)
481+
exit(2)
481482
else:
482-
cidfile_dir = "/tmp/"
483+
cidfile_dir = os.getcwd()
483484
cidfile_name = datetime.datetime.now().strftime("%Y%m%d%H%M%S-%f")+".cid"
484485
if cidfile_prefix != "":
485486
cidfile_name = str(cidfile_prefix + "-" + cidfile_name)
486-
cidfile_path = cidfile_dir + cidfile_name
487+
cidfile_path = os.path.join(cidfile_dir, cidfile_name)
487488
runtime.append(u"--cidfile=%s" % cidfile_path)
488489

489490
for t, v in self.environment.items():

cwltool/main.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,27 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
8484
default=True, help="Do not delete Docker container used by jobs after they exit",
8585
dest="rm_container")
8686

87-
parser.add_argument("--record-container-id", action="store_true", default=False,
88-
help="If enabled, a file with suffix \".cid\" will be created storing the container ID under CIDFILE_DIR",
89-
dest="record_container_id")
90-
91-
parser.add_argument("--cidfile-dir", type=Text,
92-
help="Directory for storing cidfiles. Default at /tmp/",
93-
default="/tmp/",
87+
group = parser.add_argument_group("options for docker container ID file",
88+
"These options determine whether docker"
89+
"write container ID to a file (cidfile) "
90+
"when a container is created, where it "
91+
"should be placed and how it should be named.")
92+
group.add_argument("--record-container-id", action="store_true",
93+
default=False,
94+
help="If enabled, store the container ID file under the "
95+
"directory specified by --cidfile-dir",
96+
dest="record_container_id")
97+
98+
group.add_argument("--cidfile-dir", type=Text,
99+
help="Directory for storing the container ID file. "
100+
"Default at current directory",
101+
default="",
94102
dest="cidfile_dir")
95103

96-
parser.add_argument("--cidfile-prefix", type=Text,
97-
help="Give a prefix to cidfile. Final file name will be followed by a timestamp. Default empty.",
104+
group.add_argument("--cidfile-prefix", type=Text,
105+
help="Specify a prefix to the container ID file. "
106+
"Final file name will be followed by a timestamp. "
107+
"Default \"\"",
98108
default="",
99109
dest="cidfile_prefix")
100110

@@ -175,7 +185,8 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
175185
exgroup.add_argument("--verbose", action="store_true", help="Default logging")
176186
exgroup.add_argument("--quiet", action="store_true", help="Only print warnings and errors.")
177187
exgroup.add_argument("--debug", action="store_true", help="Print even more logging")
178-
parser.add_argument("--logtstp", action="store_true", help="Print timestamps with logging")
188+
parser.add_argument("--timestamps", action="store_true",
189+
help="Add timestamps to the errors, warnings, and notifications.")
179190

180191
parser.add_argument("--js-console", action="store_true", help="Enable javascript console output")
181192
parser.add_argument("--user-space-docker-cmd",
@@ -789,7 +800,7 @@ def main(argsl=None, # type: List[str]
789800
'cachedir': None,
790801
'quiet': False,
791802
'debug': False,
792-
'logtstp': False,
803+
'timestamps': False,
793804
'js_console': False,
794805
'version': False,
795806
'enable_dev': False,
@@ -818,7 +829,7 @@ def main(argsl=None, # type: List[str]
818829
_logger.setLevel(logging.WARN)
819830
if args.debug:
820831
_logger.setLevel(logging.DEBUG)
821-
if args.logtstp:
832+
if args.timestamps:
822833
formatter = logging.Formatter("[%(asctime)s] %(message)s",
823834
"%Y-%m-%d %H:%M:%S")
824835
stderr_handler.setFormatter(formatter)

0 commit comments

Comments
 (0)