Skip to content

Commit 3b9cf76

Browse files
committed
update formatting and docstrings
1 parent 53b6874 commit 3b9cf76

18 files changed

+62
-31
lines changed

cwltool/command_line_tool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ def check_valid_locations(fs_access: StdFsAccess, ob: CWLObjectType) -> None:
345345

346346
class ParameterOutputWorkflowException(WorkflowException):
347347
def __init__(self, msg: str, port: CWLObjectType, **kwargs: Any) -> None:
348+
"""Exception for when there was an error collecting output for a parameter."""
348349
super(ParameterOutputWorkflowException, self).__init__(
349350
"Error collecting output for parameter '%s':\n%s"
350351
% (shortname(cast(str, port["id"])), msg),

cwltool/docker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def __init__(
100100
hints: List[CWLObjectType],
101101
name: str,
102102
) -> None:
103+
"""Initialize a command line builder using the Docker software container engine."""
103104
super(DockerCommandLineJob, self).__init__(
104105
builder, joborder, make_path_mapper, requirements, hints, name
105106
)

cwltool/executors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
""" Single and multi-threaded executors."""
2+
"""Single and multi-threaded executors."""
33
import datetime
44
import logging
55
import os
@@ -443,7 +443,7 @@ def run_jobs(
443443

444444

445445
class NoopJobExecutor(JobExecutor):
446-
""" Do nothing executor, for testing purposes only. """
446+
"""Do nothing executor, for testing purposes only."""
447447

448448
def run_jobs(
449449
self,

cwltool/job.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,11 @@ def _execute(
292292
# execution.
293293
if self.mpi_procs:
294294
menv = runtimeContext.mpi_config
295-
mpi_runtime = [menv.runner, menv.nproc_flag, str(self.mpi_procs)] + menv.extra_flags
295+
mpi_runtime = [
296+
menv.runner,
297+
menv.nproc_flag,
298+
str(self.mpi_procs),
299+
] + menv.extra_flags
296300
runtime = mpi_runtime + runtime
297301
menv.pass_through_env_vars(env)
298302
menv.set_env_vars(env)
@@ -927,11 +931,15 @@ def _job_popen(
927931
if stdin_path is not None:
928932
stdin = open(stdin_path, "rb")
929933

930-
stdout = default_stdout if default_stdout is not None else sys.stderr # type: Union[IO[bytes], TextIO]
934+
stdout = (
935+
default_stdout if default_stdout is not None else sys.stderr
936+
) # type: Union[IO[bytes], TextIO]
931937
if stdout_path is not None:
932938
stdout = open(stdout_path, "wb")
933939

934-
stderr = default_stderr if default_stderr is not None else sys.stderr # type: Union[IO[bytes], TextIO]
940+
stderr = (
941+
default_stderr if default_stderr is not None else sys.stderr
942+
) # type: Union[IO[bytes], TextIO]
935943
if stderr_path is not None:
936944
stderr = open(stderr_path, "wb")
937945

@@ -976,13 +984,13 @@ def terminate(): # type: () -> None
976984
if tm is not None:
977985
tm.cancel()
978986

979-
if isinstance(stdin, IOBase) and hasattr(stdin, 'close'):
987+
if isinstance(stdin, IOBase) and hasattr(stdin, "close"):
980988
stdin.close()
981989

982-
if stdout is not sys.stderr and hasattr(stdout, 'close'):
990+
if stdout is not sys.stderr and hasattr(stdout, "close"):
983991
stdout.close()
984992

985-
if stderr is not sys.stderr and hasattr(stderr, 'close'):
993+
if stderr is not sys.stderr and hasattr(stderr, "close"):
986994
stderr.close()
987995

988996
return rcode

cwltool/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
from .workflow import Workflow
102102
from .mpi import MpiConfig
103103

104+
104105
def _terminate_processes() -> None:
105106
"""Kill all spawned processes.
106107
@@ -653,6 +654,7 @@ class ProvLogFormatter(logging.Formatter):
653654
"""Enforce ISO8601 with both T and Z."""
654655

655656
def __init__(self) -> None:
657+
"""Use the default formatter with our custom formatstring."""
656658
super(ProvLogFormatter, self).__init__("[%(asctime)sZ] %(message)s")
657659

658660
def formatTime(

cwltool/mpi.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
MPIRequirementName = "http://commonwl.org/cwltool#MPIRequirement"
1111

12+
1213
class MpiConfig:
1314
def __init__(
1415
self,
@@ -20,8 +21,10 @@ def __init__(
2021
env_pass_regex: List[str] = [],
2122
env_set: Mapping[str, str] = {},
2223
) -> None:
23-
"""Initialize from the argument mapping with the following defaults:
24+
"""
25+
Initialize from the argument mapping.
2426
27+
Defaults are:
2528
runner: "mpirun"
2629
nproc_flag: "-n"
2730
default_nproc: 1
@@ -30,7 +33,8 @@ def __init__(
3033
env_pass_regex: []
3134
env_set: {}
3235
33-
Any unknown keys will result in an exception."""
36+
Any unknown keys will result in an exception.
37+
"""
3438
self.runner = runner
3539
self.nproc_flag = nproc_flag
3640
self.default_nproc = int(default_nproc)
@@ -56,9 +60,7 @@ def load(cls: Type[MpiConfigT], config_file_name: str) -> MpiConfigT:
5660
raise ValueError("Unknown key(s) in MPI configuration: {}".format(unknown))
5761

5862
def pass_through_env_vars(self, env: MutableMapping[str, str]) -> None:
59-
"""Here we take the configured list of environment variables and
60-
simply pass them through to the executed process.
61-
"""
63+
"""Take the configured list of environment variables and pass them to the executed process."""
6264
for var in self.env_pass:
6365
if var in os.environ:
6466
env[var] = os.environ[var]
@@ -70,6 +72,5 @@ def pass_through_env_vars(self, env: MutableMapping[str, str]) -> None:
7072
env[k] = os.environ[k]
7173

7274
def set_env_vars(self, env: MutableMapping[str, str]) -> None:
73-
"""Here we set some variables to the value configured.
74-
"""
75+
"""Set some variables to the value configured."""
7576
env.update(self.env_set)

cwltool/pathmapper.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,4 +229,5 @@ def __contains__(self, key: str) -> bool:
229229
return key in self._pathmap
230230

231231
def __iter__(self) -> Iterator[MapperEnt]:
232+
"""Get iterator for the maps."""
232233
return self._pathmap.values().__iter__()

cwltool/process.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Classes and methods relevant for all CWL Proccess types."""
12
import abc
23
import copy
34
import functools
@@ -266,7 +267,6 @@ def stage_files(
266267
fix_conflicts: bool = False,
267268
) -> None:
268269
"""Link or copy files to their targets. Create them as needed."""
269-
270270
targets = {} # type: Dict[str, MapperEnt]
271271
for key, entry in pathmapper.items():
272272
if "File" not in entry.type:
@@ -864,9 +864,10 @@ def inc(d): # type: (List[int]) -> None
864864
runtime_context.stagedir or tempfile.mkdtemp()
865865
)
866866

867-
cwl_version = cast(str, self.metadata.get(
868-
"http://commonwl.org/cwltool#original_cwlVersion", None
869-
))
867+
cwl_version = cast(
868+
str,
869+
self.metadata.get("http://commonwl.org/cwltool#original_cwlVersion", None),
870+
)
870871
builder = Builder(
871872
job,
872873
files,

cwltool/procgenerator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
class ProcessGeneratorJob(object):
3030
def __init__(self, procgenerator: "ProcessGenerator") -> None:
31+
"""Create a ProccessGenerator Job."""
3132
self.procgenerator = procgenerator
3233
self.jobout = None # type: Optional[CWLObjectType]
3334
self.processStatus = None # type: Optional[str]
@@ -79,6 +80,7 @@ class ProcessGenerator(Process):
7980
def __init__(
8081
self, toolpath_object: CommentedMap, loadingContext: LoadingContext,
8182
) -> None:
83+
"""Create a ProcessGenerator from the given dictionary and context."""
8284
super(ProcessGenerator, self).__init__(toolpath_object, loadingContext)
8385
self.loadingContext = loadingContext # type: LoadingContext
8486
try:

cwltool/singularity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def __init__(
9595
hints: List[CWLObjectType],
9696
name: str,
9797
) -> None:
98+
"""Builder for invoking the Singularty software container engine."""
9899
super(SingularityCommandLineJob, self).__init__(
99100
builder, joborder, make_path_mapper, requirements, hints, name
100101
)

0 commit comments

Comments
 (0)