Skip to content

Commit

Permalink
add more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Oct 15, 2024
1 parent 05af6c1 commit a956766
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 6 deletions.
2 changes: 2 additions & 0 deletions cwltool/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def __init__(
self.container_engine = container_engine

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

def generate_arg(self, binding: CWLObjectType) -> list[str]:
"""Convert an input binding to a list of command line arguments."""
value = binding.get("datum")
debug = _logger.isEnabledFor(logging.DEBUG)
if "valueFrom" in binding:
Expand Down
2 changes: 2 additions & 0 deletions cwltool/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def _rec_fields(rec: MutableMapping[str, Any]) -> MutableMapping[str, Any]:


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


def is_conditional_step(param_to_step: dict[str, CWLObjectType], parm_id: str) -> bool:
"""Return True if the step given by the parm_id is a conditional step."""
if (source_step := param_to_step.get(parm_id)) is not None:
if source_step.get("when") is not None:
return True
Expand Down
2 changes: 2 additions & 0 deletions cwltool/command_line_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def job(


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

Expand Down Expand Up @@ -404,6 +405,7 @@ def __init__(self, toolpath_object: CommentedMap, loadingContext: LoadingContext
)

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

Expand Down
1 change: 1 addition & 0 deletions cwltool/cwlprov/provenance_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ def record_process_end(
self.document.wasEndedBy(process_run_id, None, self.workflow_run_uri, when)

def declare_file(self, value: CWLObjectType) -> tuple[ProvEntity, ProvEntity, str]:
"""Construct a FileEntity for the given CWL File object."""
if value["class"] != "File":
raise ValueError("Must have class:File: %s" % value)
# Need to determine file hash aka RO filename
Expand Down
13 changes: 9 additions & 4 deletions cwltool/flatten.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
from typing import Any, Callable, cast
"""
Our version of the popular flatten() method.
http://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html
"""

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


def flatten(thing, ltypes=(list, tuple)):
# type: (Any, Any) -> List[Any]
def flatten(thing: Any) -> list[Any]:
"""Flatten a list without recursion problems."""
if thing is None:
return []
ltypes = (list, tuple)
if not isinstance(thing, ltypes):
return [thing]

Expand Down
1 change: 1 addition & 0 deletions cwltool/load_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ def resolve_overrides(


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

Expand Down
1 change: 1 addition & 0 deletions cwltool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ def print_pack(


def supported_cwl_versions(enable_dev: bool) -> list[str]:
"""Return a list of currently supported CWL versions."""
# ALLUPDATES and UPDATES are dicts
if enable_dev:
versions = list(ALLUPDATES)
Expand Down
1 change: 1 addition & 0 deletions cwltool/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def find_ids(


def replace_refs(d: Any, rewrite: dict[str, str], stem: str, newstem: str) -> None:
"""Replace references with the actual value."""
if isinstance(d, MutableSequence):
for s, v in enumerate(d):
if isinstance(v, str):
Expand Down
7 changes: 5 additions & 2 deletions cwltool/pathmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,11 @@ def visit(
)

def setup(self, referenced_files: list[CWLObjectType], basedir: str) -> None:
# Go through each file and set the target to its own directory along
# with any secondary files.
"""
For each file, set the target to its own directory.
Also processes secondary files into that same directory.
"""
stagedir = self.stagedir
for fob in referenced_files:
if self.separateDirs:
Expand Down
1 change: 1 addition & 0 deletions cwltool/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,6 +1073,7 @@ def __str__(self) -> str:


def uniquename(stem: str, names: Optional[set[str]] = None) -> str:
"""Construct a thread-unique name using the given stem as a prefix."""
global _names
if names is None:
names = _names
Expand Down
1 change: 1 addition & 0 deletions cwltool/software_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(self, args: argparse.Namespace) -> None:
os.makedirs(self.tool_dependency_dir)

def build_job_script(self, builder: "Builder", command: list[str]) -> str:
"""Use the galaxy-tool-util library to construct a build script."""
ensure_galaxy_lib_available()
resolution_config_dict = {
"use": self.use_tool_dependencies,
Expand Down
2 changes: 2 additions & 0 deletions cwltool/stdfsaccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def _abs(self, p: str) -> str:
return abspath(p, self.basedir)

def glob(self, pattern: str) -> list[str]:
"""Return a possibly empty list of absolute URI paths that match pathname."""
return [file_uri(str(self._abs(line))) for line in glob.glob(self._abs(pattern))]

def open(self, fn: str, mode: str) -> IO[Any]:
Expand All @@ -50,6 +51,7 @@ def isdir(self, fn: str) -> bool:
return os.path.isdir(self._abs(fn))

def listdir(self, fn: str) -> list[str]:
"""Return a list containing the absolute path URLs of the entries in the directory given by path."""
return [abspath(urllib.parse.quote(entry), fn) for entry in os.listdir(self._abs(fn))]

def join(self, path, *paths): # type: (str, *str) -> str
Expand Down
6 changes: 6 additions & 0 deletions cwltool/subgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def subgraph_visit(


def declare_node(nodes: dict[str, Node], nodeid: str, tp: Optional[str]) -> Node:
"""
Record the given nodeid in the graph.
If the nodeid is already present, but its type is unset, set it.
:returns: The Node tuple (even if already present in the graph).
"""
if nodeid in nodes:
n = nodes[nodeid]
if n.type is None:
Expand Down

0 comments on commit a956766

Please sign in to comment.