Skip to content

Commit a956766

Browse files
committed
add more docs
1 parent 05af6c1 commit a956766

13 files changed

+34
-6
lines changed

cwltool/builder.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def __init__(
161161
self.container_engine = container_engine
162162

163163
def build_job_script(self, commands: list[str]) -> Optional[str]:
164+
"""Use the job_script_provider to turn the commands into a job script."""
164165
if self.job_script_provider is not None:
165166
return self.job_script_provider.build_job_script(self, commands)
166167
return None
@@ -607,6 +608,7 @@ def tostr(self, value: Union[MutableMapping[str, str], Any]) -> str:
607608
return str(value)
608609

609610
def generate_arg(self, binding: CWLObjectType) -> list[str]:
611+
"""Convert an input binding to a list of command line arguments."""
610612
value = binding.get("datum")
611613
debug = _logger.isEnabledFor(logging.DEBUG)
612614
if "valueFrom" in binding:

cwltool/checker.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def _rec_fields(rec: MutableMapping[str, Any]) -> MutableMapping[str, Any]:
156156

157157

158158
def missing_subset(fullset: list[Any], subset: list[Any]) -> list[Any]:
159+
"""Calculate the items missing from the fullset given the subset."""
159160
missing = []
160161
for i in subset:
161162
if i not in fullset:
@@ -498,6 +499,7 @@ def get_step_id(field_id: str) -> str:
498499

499500

500501
def is_conditional_step(param_to_step: dict[str, CWLObjectType], parm_id: str) -> bool:
502+
"""Return True if the step given by the parm_id is a conditional step."""
501503
if (source_step := param_to_step.get(parm_id)) is not None:
502504
if source_step.get("when") is not None:
503505
return True

cwltool/command_line_tool.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ def job(
228228

229229

230230
def remove_path(f: CWLObjectType) -> None:
231+
"""Remove any 'path' property, if present."""
231232
if "path" in f:
232233
del f["path"]
233234

@@ -404,6 +405,7 @@ def __init__(self, toolpath_object: CommentedMap, loadingContext: LoadingContext
404405
)
405406

406407
def make_job_runner(self, runtimeContext: RuntimeContext) -> type[JobBase]:
408+
"""Return the correct CommandLineJob class given the container settings."""
407409
dockerReq, dockerRequired = self.get_requirement("DockerRequirement")
408410
mpiReq, mpiRequired = self.get_requirement(MPIRequirementName)
409411

cwltool/cwlprov/provenance_profile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ def record_process_end(
281281
self.document.wasEndedBy(process_run_id, None, self.workflow_run_uri, when)
282282

283283
def declare_file(self, value: CWLObjectType) -> tuple[ProvEntity, ProvEntity, str]:
284+
"""Construct a FileEntity for the given CWL File object."""
284285
if value["class"] != "File":
285286
raise ValueError("Must have class:File: %s" % value)
286287
# Need to determine file hash aka RO filename

cwltool/flatten.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
from typing import Any, Callable, cast
1+
"""
2+
Our version of the popular flatten() method.
3+
4+
http://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html
5+
"""
26

3-
# http://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html
7+
from typing import Any, Callable, cast
48

59

6-
def flatten(thing, ltypes=(list, tuple)):
7-
# type: (Any, Any) -> List[Any]
10+
def flatten(thing: Any) -> list[Any]:
11+
"""Flatten a list without recursion problems."""
812
if thing is None:
913
return []
14+
ltypes = (list, tuple)
1015
if not isinstance(thing, ltypes):
1116
return [thing]
1217

cwltool/load_tool.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ def resolve_overrides(
626626

627627

628628
def load_overrides(ov: str, base_url: str) -> list[CWLObjectType]:
629+
"""Load and resolve any overrides."""
629630
ovloader = Loader(overrides_ctx)
630631
return resolve_overrides(ovloader.fetch(ov), ov, base_url)
631632

cwltool/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,7 @@ def print_pack(
626626

627627

628628
def supported_cwl_versions(enable_dev: bool) -> list[str]:
629+
"""Return a list of currently supported CWL versions."""
629630
# ALLUPDATES and UPDATES are dicts
630631
if enable_dev:
631632
versions = list(ALLUPDATES)

cwltool/pack.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def find_ids(
5151

5252

5353
def replace_refs(d: Any, rewrite: dict[str, str], stem: str, newstem: str) -> None:
54+
"""Replace references with the actual value."""
5455
if isinstance(d, MutableSequence):
5556
for s, v in enumerate(d):
5657
if isinstance(v, str):

cwltool/pathmapper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,11 @@ def visit(
188188
)
189189

190190
def setup(self, referenced_files: list[CWLObjectType], basedir: str) -> None:
191-
# Go through each file and set the target to its own directory along
192-
# with any secondary files.
191+
"""
192+
For each file, set the target to its own directory.
193+
194+
Also processes secondary files into that same directory.
195+
"""
193196
stagedir = self.stagedir
194197
for fob in referenced_files:
195198
if self.separateDirs:

cwltool/process.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,7 @@ def __str__(self) -> str:
10731073

10741074

10751075
def uniquename(stem: str, names: Optional[set[str]] = None) -> str:
1076+
"""Construct a thread-unique name using the given stem as a prefix."""
10761077
global _names
10771078
if names is None:
10781079
names = _names

0 commit comments

Comments
 (0)