Skip to content

Commit 9ebb8d5

Browse files
committed
Merge remote-tracking branch 'refs/remotes/upstream/main' into on-error-abort
# Conflicts: # cwltool/context.py
2 parents f5bb832 + 74a08ca commit 9ebb8d5

File tree

102 files changed

+804
-1083
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+804
-1083
lines changed

.github/workflows/ci-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
strategy:
3333
matrix:
3434
py-ver-major: [3]
35-
py-ver-minor: [8, 9, 10, 11, 12]
35+
py-ver-minor: [9, 10, 11, 12, 13]
3636
step: [lint, unit, bandit, mypy]
3737

3838
env:
@@ -165,6 +165,7 @@ jobs:
165165
runs-on: ubuntu-22.04
166166

167167
strategy:
168+
fail-fast: false
168169
matrix:
169170
cwl-version: [v1.0, v1.1, v1.2]
170171
container: [docker, singularity, podman]

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Generated during tests
22
pytestdebug.log
33
tmp/
4+
*.sif
5+
involucro
46

57
# Python temps
68
__pycache__/
@@ -59,4 +61,3 @@ cwltool/_version.py
5961
cwltool_deps
6062
docs/_build/
6163
docs/autoapi/
62-

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ MODULE=cwltool
2424

2525
# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
2626
# `[[` conditional expressions.
27-
PYSOURCES=$(wildcard ${MODULE}/**.py cwltool/cwlprov/*.py tests/*.py) setup.py
27+
PYSOURCES=$(wildcard ${MODULE}/**.py cwltool/cwlprov/*.py tests/*.py tests/cwl-conformance/*.py) setup.py
2828
DEVPKGS=diff_cover pylint pep257 pydocstyle 'tox<4' tox-pyenv auto-walrus \
2929
isort wheel autoflake pyupgrade bandit -rlint-requirements.txt\
3030
-rtest-requirements.txt -rmypy-requirements.txt -rdocs/requirements.txt
@@ -190,7 +190,7 @@ shellcheck: FORCE
190190
cwltool-in-docker.sh
191191

192192
pyupgrade: $(PYSOURCES)
193-
pyupgrade --exit-zero-even-if-changed --py38-plus $^
193+
pyupgrade --exit-zero-even-if-changed --py39-plus $^
194194
auto-walrus $^
195195

196196
release-test: FORCE

cwltool/argparser.py

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,8 @@
33
import argparse
44
import os
55
import urllib
6-
from typing import (
7-
Any,
8-
Callable,
9-
Dict,
10-
List,
11-
MutableMapping,
12-
MutableSequence,
13-
Optional,
14-
Sequence,
15-
Type,
16-
Union,
17-
cast,
18-
)
6+
from collections.abc import MutableMapping, MutableSequence, Sequence
7+
from typing import Any, Callable, Optional, Union, cast
198

209
from .loghandler import _logger
2110
from .process import Process, shortname
@@ -719,7 +708,7 @@ def arg_parser() -> argparse.ArgumentParser:
719708
return parser
720709

721710

722-
def get_default_args() -> Dict[str, Any]:
711+
def get_default_args() -> dict[str, Any]:
723712
"""Get default values of cwltool's command line options."""
724713
ap = arg_parser()
725714
args = ap.parse_args([])
@@ -733,7 +722,7 @@ class FSAction(argparse.Action):
733722

734723
def __init__(
735724
self,
736-
option_strings: List[str],
725+
option_strings: list[str],
737726
dest: str,
738727
nargs: Any = None,
739728
urljoin: Callable[[str, str], str] = urllib.parse.urljoin,
@@ -771,7 +760,7 @@ class FSAppendAction(argparse.Action):
771760

772761
def __init__(
773762
self,
774-
option_strings: List[str],
763+
option_strings: list[str],
775764
dest: str,
776765
nargs: Any = None,
777766
urljoin: Callable[[str, str], str] = urllib.parse.urljoin,
@@ -828,7 +817,7 @@ class AppendAction(argparse.Action):
828817

829818
def __init__(
830819
self,
831-
option_strings: List[str],
820+
option_strings: list[str],
832821
dest: str,
833822
nargs: Any = None,
834823
**kwargs: Any,
@@ -860,7 +849,7 @@ def add_argument(
860849
toolparser: argparse.ArgumentParser,
861850
name: str,
862851
inptype: Any,
863-
records: List[str],
852+
records: list[str],
864853
description: str = "",
865854
default: Any = None,
866855
input_required: bool = True,
@@ -889,9 +878,9 @@ def add_argument(
889878
return None
890879

891880
ahelp = description.replace("%", "%%")
892-
action: Optional[Union[Type[argparse.Action], str]] = None
881+
action: Optional[Union[type[argparse.Action], str]] = None
893882
atype: Optional[Any] = None
894-
typekw: Dict[str, Any] = {}
883+
typekw: dict[str, Any] = {}
895884

896885
if inptype == "File":
897886
action = FileAction
@@ -904,6 +893,11 @@ def add_argument(
904893
action = DirectoryAppendAction
905894
else:
906895
action = AppendAction
896+
items = inptype["items"]
897+
if items == "int" or items == "long":
898+
atype = int
899+
elif items == "double" or items == "float":
900+
atype = float
907901
elif isinstance(inptype, MutableMapping) and inptype["type"] == "enum":
908902
atype = str
909903
elif isinstance(inptype, MutableMapping) and inptype["type"] == "record":
@@ -958,8 +952,8 @@ def add_argument(
958952
def generate_parser(
959953
toolparser: argparse.ArgumentParser,
960954
tool: Process,
961-
namemap: Dict[str, str],
962-
records: List[str],
955+
namemap: dict[str, str],
956+
records: list[str],
963957
input_required: bool = True,
964958
urljoin: Callable[[str, str], str] = urllib.parse.urljoin,
965959
base_uri: str = "",

cwltool/builder.py

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,9 @@
33
import copy
44
import logging
55
import math
6+
from collections.abc import MutableMapping, MutableSequence
67
from decimal import Decimal
7-
from typing import (
8-
IO,
9-
TYPE_CHECKING,
10-
Any,
11-
Callable,
12-
Dict,
13-
List,
14-
MutableMapping,
15-
MutableSequence,
16-
Optional,
17-
Type,
18-
Union,
19-
cast,
20-
)
8+
from typing import IO, TYPE_CHECKING, Any, Callable, Optional, Union, cast
219

2210
from cwl_utils import expression
2311
from cwl_utils.file_formats import check_format
@@ -55,7 +43,7 @@
5543
)
5644
from .pathmapper import PathMapper
5745

58-
INPUT_OBJ_VOCAB: Dict[str, str] = {
46+
INPUT_OBJ_VOCAB: dict[str, str] = {
5947
"Any": "https://w3id.org/cwl/salad#Any",
6048
"File": "https://w3id.org/cwl/cwl#File",
6149
"Directory": "https://w3id.org/cwl/cwl#Directory",
@@ -107,16 +95,16 @@ class Builder(HasReqsHints):
10795
def __init__(
10896
self,
10997
job: CWLObjectType,
110-
files: List[CWLObjectType],
111-
bindings: List[CWLObjectType],
98+
files: list[CWLObjectType],
99+
bindings: list[CWLObjectType],
112100
schemaDefs: MutableMapping[str, CWLObjectType],
113101
names: Names,
114-
requirements: List[CWLObjectType],
115-
hints: List[CWLObjectType],
116-
resources: Dict[str, Union[int, float]],
102+
requirements: list[CWLObjectType],
103+
hints: list[CWLObjectType],
104+
resources: dict[str, Union[int, float]],
117105
mutation_manager: Optional[MutationManager],
118106
formatgraph: Optional[Graph],
119-
make_fs_access: Type[StdFsAccess],
107+
make_fs_access: type[StdFsAccess],
120108
fs_access: StdFsAccess,
121109
job_script_provider: Optional[DependenciesConfiguration],
122110
timeout: float,
@@ -172,19 +160,20 @@ def __init__(
172160
self.find_default_container: Optional[Callable[[], str]] = None
173161
self.container_engine = container_engine
174162

175-
def build_job_script(self, commands: List[str]) -> Optional[str]:
163+
def build_job_script(self, commands: list[str]) -> Optional[str]:
164+
"""Use the job_script_provider to turn the commands into a job script."""
176165
if self.job_script_provider is not None:
177166
return self.job_script_provider.build_job_script(self, commands)
178167
return None
179168

180169
def bind_input(
181170
self,
182171
schema: CWLObjectType,
183-
datum: Union[CWLObjectType, List[CWLObjectType]],
172+
datum: Union[CWLObjectType, list[CWLObjectType]],
184173
discover_secondaryFiles: bool,
185-
lead_pos: Optional[Union[int, List[int]]] = None,
186-
tail_pos: Optional[Union[str, List[int]]] = None,
187-
) -> List[MutableMapping[str, Union[str, List[int]]]]:
174+
lead_pos: Optional[Union[int, list[int]]] = None,
175+
tail_pos: Optional[Union[str, list[int]]] = None,
176+
) -> list[MutableMapping[str, Union[str, list[int]]]]:
188177
"""
189178
Bind an input object to the command line.
190179
@@ -200,8 +189,8 @@ def bind_input(
200189
if lead_pos is None:
201190
lead_pos = []
202191

203-
bindings: List[MutableMapping[str, Union[str, List[int]]]] = []
204-
binding: Union[MutableMapping[str, Union[str, List[int]]], CommentedMap] = {}
192+
bindings: list[MutableMapping[str, Union[str, list[int]]]] = []
193+
binding: Union[MutableMapping[str, Union[str, list[int]]], CommentedMap] = {}
205194
value_from_expression = False
206195
if "inputBinding" in schema and isinstance(schema["inputBinding"], MutableMapping):
207196
binding = CommentedMap(schema["inputBinding"].items())
@@ -282,7 +271,7 @@ def bind_input(
282271
and "itemSeparator" not in binding
283272
):
284273
st["inputBinding"] = {}
285-
for k in ("secondaryFiles", "format", "streamable"):
274+
for k in ("secondaryFiles", "format", "streamable", "loadContents"):
286275
if k in schema:
287276
st[k] = schema[k]
288277
if value_from_expression:
@@ -324,7 +313,7 @@ def bind_input(
324313

325314
if schema["type"] == "record":
326315
datum = cast(CWLObjectType, datum)
327-
for f in cast(List[CWLObjectType], schema["fields"]):
316+
for f in cast(list[CWLObjectType], schema["fields"]):
328317
name = cast(str, f["name"])
329318
if name in datum and datum[name] is not None:
330319
bindings.extend(
@@ -349,7 +338,7 @@ def bind_input(
349338
"type": schema["items"],
350339
"inputBinding": b2,
351340
}
352-
for k in ("secondaryFiles", "format", "streamable"):
341+
for k in ("secondaryFiles", "format", "streamable", "loadContents"):
353342
if k in schema:
354343
itemschema[k] = schema[k]
355344
bindings.extend(
@@ -372,7 +361,7 @@ def _capture_files(f: CWLObjectType) -> CWLObjectType:
372361
self.files.append(datum)
373362

374363
loadContents_sourceline: Union[
375-
None, MutableMapping[str, Union[str, List[int]]], CWLObjectType
364+
None, MutableMapping[str, Union[str, list[int]]], CWLObjectType
376365
] = None
377366
if binding and binding.get("loadContents"):
378367
loadContents_sourceline = binding
@@ -513,7 +502,7 @@ def addsf(
513502
if "format" in schema:
514503
eval_format: Any = self.do_eval(schema["format"])
515504
if isinstance(eval_format, str):
516-
evaluated_format: Union[str, List[str]] = eval_format
505+
evaluated_format: Union[str, list[str]] = eval_format
517506
elif isinstance(eval_format, MutableSequence):
518507
for index, entry in enumerate(eval_format):
519508
message = None
@@ -541,7 +530,7 @@ def addsf(
541530
raise SourceLine(
542531
schema["format"], index, WorkflowException, debug
543532
).makeError(message)
544-
evaluated_format = cast(List[str], eval_format)
533+
evaluated_format = cast(list[str], eval_format)
545534
else:
546535
raise SourceLine(schema, "format", WorkflowException, debug).makeError(
547536
"An expression in the 'format' field must "
@@ -586,8 +575,8 @@ def addsf(
586575
# Position to front of the sort key
587576
if binding:
588577
for bi in bindings:
589-
bi["position"] = cast(List[int], binding["position"]) + cast(
590-
List[int], bi["position"]
578+
bi["position"] = cast(list[int], binding["position"]) + cast(
579+
list[int], bi["position"]
591580
)
592581
bindings.append(binding)
593582

@@ -618,7 +607,8 @@ def tostr(self, value: Union[MutableMapping[str, str], Any]) -> str:
618607
else:
619608
return str(value)
620609

621-
def generate_arg(self, binding: CWLObjectType) -> List[str]:
610+
def generate_arg(self, binding: CWLObjectType) -> list[str]:
611+
"""Convert an input binding to a list of command line arguments."""
622612
value = binding.get("datum")
623613
debug = _logger.isEnabledFor(logging.DEBUG)
624614
if "valueFrom" in binding:
@@ -648,7 +638,7 @@ def generate_arg(self, binding: CWLObjectType) -> List[str]:
648638
argl = [itemSeparator.join([self.tostr(v) for v in value])]
649639
elif binding.get("valueFrom"):
650640
value = [self.tostr(v) for v in value]
651-
return cast(List[str], ([prefix] if prefix else [])) + cast(List[str], value)
641+
return cast(list[str], ([prefix] if prefix else [])) + cast(list[str], value)
652642
elif prefix and value:
653643
return [prefix]
654644
else:

0 commit comments

Comments
 (0)