cwltool.utils
Shared functions and other definitions.
Attributes
Typical raw dictionary found in lightly parsed CWL. |
|
Classes
InitialWorkDirRequirement.listing item. |
|
Workflow state item. |
|
Base class for get_requirement(). |
Functions
Version of CWLtool used to execute the workflow. |
|
|
Wrap any non-MutableSequence/list in a list. |
|
|
|
Compare in the same manner as Python2. |
|
Convert any present byte string to unicode string, inplace. |
|
Apply a function to with "class" in cls. |
|
Apply a function to mapping with 'field'. |
Return the random directory name chosen to use for tool / workflow output. |
|
|
|
|
|
|
Apply an update function to each File object in the object rec. |
|
Apply an update function to each Directory object in the object rec. |
|
Remove duplicate entries from a CWL Directory 'listing'. |
|
Expand, recursively, any 'listing' fields in a Directory. |
|
Remove 'listing' field from Directory objects that are file references. |
|
Download a remote file, possibly using a locally cached copy. |
|
Ensure that 'path' is writable. |
|
Attempt to change permissions to ensure that a path is not writable. |
|
Add missing `location`s and `basename`s to CWL File and Directory objects. |
|
|
|
|
|
Create a temporary directory that respects the given tmpdir_prefix. |
Module Contents
- cwltool.utils.CONTENT_LIMIT = 65536
- cwltool.utils.DEFAULT_TMP_PREFIX
- cwltool.utils.processes_to_kill: Deque[subprocess.Popen[str]]
Typical raw dictionary found in lightly parsed CWL.
- type cwltool.utils.JobsType = 'CommandLineJob' | 'JobBase' | 'WorkflowJob' | 'ExpressionJob' | 'CallbackJob'
- type cwltool.utils.ScatterOutputCallbackType = Callable[[ScatterDestinationsType | None, str], None]
- type cwltool.utils.JSONType = dict[str, 'JSONType'] | list['JSONType'] | str | int | float | bool | None
- class cwltool.utils.DirentType
Bases:
TypedDict
InitialWorkDirRequirement.listing item.
- class cwltool.utils.WorkflowStateItem
Bases:
NamedTuple
Workflow state item.
- parameter: cwl_utils.types.CWLObjectType
- type cwltool.utils.StepType = CWLObjectType
- cwltool.utils.LoadListingType
- cwltool.utils.aslist(thing)
Wrap any non-MutableSequence/list in a list.
- Parameters:
thing (Any)
- Return type:
- cwltool.utils.cmp_like_py2(dict1, dict2)
Compare in the same manner as Python2.
Comparison function to be used in sorting as python3 doesn’t allow sorting of different types like str() and int(). This function re-creates sorting nature in py2 of heterogeneous list of int and str
- cwltool.utils.bytes2str_in_dicts(inp)
Convert any present byte string to unicode string, inplace.
input is a dict of nested dicts and lists
- Parameters:
inp (collections.abc.MutableMapping[str, Any] | collections.abc.MutableSequence[Any] | Any)
- Return type:
str | collections.abc.MutableSequence[Any] | collections.abc.MutableMapping[str, Any]
- cwltool.utils.visit_class(rec, cls, op)
Apply a function to with “class” in cls.
- Parameters:
rec (Any)
cls (collections.abc.Iterable[Any])
op (collections.abc.Callable[Ellipsis, Any])
- Return type:
None
- cwltool.utils.visit_field(rec, field, op)
Apply a function to mapping with ‘field’.
- Parameters:
rec (Any)
field (str)
op (collections.abc.Callable[Ellipsis, Any])
- Return type:
None
- cwltool.utils.random_outdir()
Return the random directory name chosen to use for tool / workflow output.
- Return type:
- Parameters:
fd (IO[Any])
- Return type:
None
- cwltool.utils.upgrade_lock(fd)
- Parameters:
fd (IO[Any])
- Return type:
None
- cwltool.utils.adjustFileObjs(rec, op)
Apply an update function to each File object in the object rec.
- Parameters:
rec (Any)
op (Union[collections.abc.Callable[Ellipsis, Any], partial[Any]])
- Return type:
None
- cwltool.utils.adjustDirObjs(rec, op)
Apply an update function to each Directory object in the object rec.
- Parameters:
rec (Any)
op (Union[collections.abc.Callable[Ellipsis, Any], partial[Any]])
- Return type:
None
- cwltool.utils.dedup(listing)
Remove duplicate entries from a CWL Directory ‘listing’.
- Parameters:
listing (collections.abc.MutableSequence[cwl_utils.types.CWLFileType | cwl_utils.types.CWLDirectoryType])
- Return type:
collections.abc.MutableSequence[cwl_utils.types.CWLFileType | cwl_utils.types.CWLDirectoryType]
- cwltool.utils.get_listing(fs_access, rec, recursive=True)
Expand, recursively, any ‘listing’ fields in a Directory.
- Parameters:
fs_access (cwltool.stdfsaccess.StdFsAccess)
rec (cwl_utils.types.CWLObjectType | cwl_utils.types.CWLDirectoryType)
recursive (bool)
- Return type:
None
- cwltool.utils.trim_listing(obj)
Remove ‘listing’ field from Directory objects that are file references.
It redundant and potentially expensive to pass fully enumerated Directory objects around if not explicitly needed, so delete the ‘listing’ field when it is safe to do so.
- cwltool.utils.downloadHttpFile(httpurl)
Download a remote file, possibly using a locally cached copy.
Returns a tuple: - the local path for the downloaded file - the Last-Modified timestamp if received from the remote server.
- Parameters:
httpurl (str)
- Return type:
tuple[str, datetime.datetime | None]
- cwltool.utils.ensure_writable(path, include_root=False)
Ensure that ‘path’ is writable.
If ‘path’ is a directory, then all files and directories under ‘path’ are made writable, recursively. If ‘path’ is a file or if ‘include_root’ is True, then ‘path’ itself is made writable.
- cwltool.utils.ensure_non_writable(path)
Attempt to change permissions to ensure that a path is not writable.
- Parameters:
path (str)
- Return type:
None
- cwltool.utils.normalizeFilesDirs(job)
Add missing `location`s and `basename`s to CWL File and Directory objects.
- Raises:
ValidationException – if anonymous objects are missing required fields, or if the location ends in ‘/’ but the object isn’t a directory
- Parameters:
job (collections.abc.Sequence[cwl_utils.types.CWLObjectType | cwl_utils.types.CWLOutputType | None] | cwl_utils.types.CWLObjectType | cwl_utils.types.CWLOutputType | None)
- Return type:
None
- cwltool.utils.create_tmp_dir(tmpdir_prefix)
Create a temporary directory that respects the given tmpdir_prefix.
- class cwltool.utils.HasReqsHints
Base class for get_requirement().