Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@

# upgrade to black 20.8b1
6fd6fdb381fe3f347627fd517a8f2dba7b0a7029

# upgrade to black 23.1, longer lines (100)
7fe8c0739b0515d00daabc7db87bc5fad926d345
3 changes: 3 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- py-ver-major: 3
py-ver-minor: 6
step: mypy
- py-ver-major: 3
py-ver-minor: 6
step: lint

env:
py-semver: ${{ format('{0}.{1}', matrix.py-ver-major, matrix.py-ver-minor) }}
Expand Down
13 changes: 7 additions & 6 deletions cwltool.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ RUN apk add --no-cache git gcc python3-dev libxml2-dev libxslt-dev libc-dev linu

WORKDIR /cwltool
COPY . .

RUN pip install toml -rmypy-requirements.txt -rrequirements.txt
RUN CWLTOOL_USE_MYPYC=1 MYPYPATH=mypy-stubs pip wheel --no-binary schema-salad --wheel-dir=/wheels .[deps]
RUN CWLTOOL_USE_MYPYC=1 MYPYPATH=mypy-stubs pip wheel --no-binary schema-salad \
--wheel-dir=/wheels .[deps] # --verbose
RUN rm /wheels/schema_salad*
RUN pip install black
RUN pip install "black~=22.0"
# galaxy-util 22.1.2 depends on packaging<22, but black 23.x needs packaging>22
RUN SCHEMA_SALAD_USE_MYPYC=1 MYPYPATH=mypy-stubs pip wheel --no-binary schema-salad \
$(grep schema.salad requirements.txt) black --wheel-dir=/wheels
RUN pip install --force-reinstall --no-index --no-warn-script-location --root=/pythonroot/ /wheels/*.whl
$(grep schema.salad requirements.txt) "black~=22.0" --wheel-dir=/wheels # --verbose
RUN pip install --force-reinstall --no-index --no-warn-script-location \
--root=/pythonroot/ /wheels/*.whl
# --force-reinstall to install our new mypyc compiled schema-salad package

FROM python:3.11-alpine as module
Expand Down
41 changes: 11 additions & 30 deletions cwltool/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ def arg_parser() -> argparse.ArgumentParser:
help="Path prefix for temporary directories. If --tmpdir-prefix is not "
"provided, then the prefix for temporary directories is influenced by "
"the value of the TMPDIR, TEMP, or TMP environment variables. Taking "
"those into consideration, the current default is {}.".format(
DEFAULT_TMP_PREFIX
),
"those into consideration, the current default is {}.".format(DEFAULT_TMP_PREFIX),
default=DEFAULT_TMP_PREFIX,
)

Expand Down Expand Up @@ -318,12 +316,8 @@ def arg_parser() -> argparse.ArgumentParser:
action="store_true",
help="Combine components into single document and print.",
)
printgroup.add_argument(
"--version", action="store_true", help="Print version and exit"
)
printgroup.add_argument(
"--validate", action="store_true", help="Validate CWL document only."
)
printgroup.add_argument("--version", action="store_true", help="Print version and exit")
printgroup.add_argument("--validate", action="store_true", help="Validate CWL document only.")
printgroup.add_argument(
"--print-supported-versions",
action="store_true",
Expand Down Expand Up @@ -384,12 +378,8 @@ def arg_parser() -> argparse.ArgumentParser:

volumegroup = parser.add_mutually_exclusive_group()
volumegroup.add_argument("--verbose", action="store_true", help="Default logging")
volumegroup.add_argument(
"--quiet", action="store_true", help="Only print warnings and errors."
)
volumegroup.add_argument(
"--debug", action="store_true", help="Print even more logging"
)
volumegroup.add_argument("--quiet", action="store_true", help="Only print warnings and errors.")
volumegroup.add_argument("--debug", action="store_true", help="Print even more logging")

parser.add_argument(
"--write-summary",
Expand Down Expand Up @@ -494,12 +484,9 @@ def arg_parser() -> argparse.ArgumentParser:
"Default root directory used by dependency resolvers configuration."
)
use_biocontainers_help = (
"Use biocontainers for tools without an "
"explicitly annotated Docker container."
)
conda_dependencies = (
"Short cut to use Conda to resolve 'SoftwareRequirement' packages."
"Use biocontainers for tools without an " "explicitly annotated Docker container."
)
conda_dependencies = "Short cut to use Conda to resolve 'SoftwareRequirement' packages."

parser.add_argument(
"--beta-dependency-resolvers-configuration",
Expand All @@ -522,9 +509,7 @@ def arg_parser() -> argparse.ArgumentParser:
action="store_true",
)

parser.add_argument(
"--tool-help", action="store_true", help="Print command line help for tool"
)
parser.add_argument("--tool-help", action="store_true", help="Print command line help for tool")

parser.add_argument(
"--relative-deps",
Expand All @@ -537,8 +522,7 @@ def arg_parser() -> argparse.ArgumentParser:
parser.add_argument(
"--enable-dev",
action="store_true",
help="Enable loading and running unofficial development versions of "
"the CWL standards.",
help="Enable loading and running unofficial development versions of " "the CWL standards.",
default=False,
)

Expand Down Expand Up @@ -647,8 +631,7 @@ def arg_parser() -> argparse.ArgumentParser:
"--relax-path-checks",
action="store_true",
default=False,
help="Relax requirements on path names to permit "
"spaces and hash characters.",
help="Relax requirements on path names to permit " "spaces and hash characters.",
dest="relax_path_checks",
)

Expand Down Expand Up @@ -933,9 +916,7 @@ def add_argument(
fieldtype,
records,
fielddescription,
default=default.get(shortname(field["name"]), None)
if default
else None,
default=default.get(shortname(field["name"]), None) if default else None,
input_required=required,
)
return
Expand Down
51 changes: 13 additions & 38 deletions cwltool/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,7 @@ def bind_input(
bindings: List[MutableMapping[str, Union[str, List[int]]]] = []
binding: Union[MutableMapping[str, Union[str, List[int]]], CommentedMap] = {}
value_from_expression = False
if "inputBinding" in schema and isinstance(
schema["inputBinding"], MutableMapping
):
if "inputBinding" in schema and isinstance(schema["inputBinding"], MutableMapping):
binding = CommentedMap(schema["inputBinding"].items())

bp = list(aslist(lead_pos))
Expand Down Expand Up @@ -303,8 +301,7 @@ def bind_input(
else:
schema["type"] = "record"
schema["fields"] = [
{"name": field_name, "type": "Any"}
for field_name in datum.keys()
{"name": field_name, "type": "Any"} for field_name in datum.keys()
]
elif isinstance(datum, list):
schema["type"] = "array"
Expand Down Expand Up @@ -378,14 +375,10 @@ def _capture_files(f: CWLObjectType) -> CWLObjectType:
debug,
):
try:
with self.fs_access.open(
cast(str, datum["location"]), "rb"
) as f2:
with self.fs_access.open(cast(str, datum["location"]), "rb") as f2:
datum["contents"] = content_limit_respected_read(f2)
except Exception as e:
raise Exception(
"Reading {}\n{}".format(datum["location"], e)
) from e
raise Exception("Reading {}\n{}".format(datum["location"], e)) from e

if "secondaryFiles" in schema:
if "secondaryFiles" not in datum:
Expand All @@ -398,13 +391,8 @@ def _capture_files(f: CWLObjectType) -> CWLObjectType:

for num, sf_entry in enumerate(sf_schema):
if "required" in sf_entry and sf_entry["required"] is not None:
required_result = self.do_eval(
sf_entry["required"], context=datum
)
if not (
isinstance(required_result, bool)
or required_result is None
):
required_result = self.do_eval(sf_entry["required"], context=datum)
if not (isinstance(required_result, bool) or required_result is None):
if sf_schema == schema["secondaryFiles"]:
sf_item: Any = sf_schema[num]
else:
Expand All @@ -425,9 +413,7 @@ def _capture_files(f: CWLObjectType) -> CWLObjectType:
if "$(" in sf_entry["pattern"] or "${" in sf_entry["pattern"]:
sfpath = self.do_eval(sf_entry["pattern"], context=datum)
else:
sfpath = substitute(
cast(str, datum["basename"]), sf_entry["pattern"]
)
sfpath = substitute(cast(str, datum["basename"]), sf_entry["pattern"])

for sfname in aslist(sfpath):
if not sfname:
Expand All @@ -438,8 +424,7 @@ def _capture_files(f: CWLObjectType) -> CWLObjectType:
d_location = cast(str, datum["location"])
if "/" in d_location:
sf_location = (
d_location[0 : d_location.rindex("/") + 1]
+ sfname
d_location[0 : d_location.rindex("/") + 1] + sfname
)
else:
sf_location = d_location + sfname
Expand All @@ -462,9 +447,7 @@ def _capture_files(f: CWLObjectType) -> CWLObjectType:
datum["secondaryFiles"],
):
if not d.get("basename"):
d["basename"] = d["location"][
d["location"].rindex("/") + 1 :
]
d["basename"] = d["location"][d["location"].rindex("/") + 1 :]
if d["basename"] == sfbasename:
found = True

Expand All @@ -488,9 +471,7 @@ def addsf(
),
sfname,
)
elif discover_secondaryFiles and self.fs_access.exists(
sf_location
):
elif discover_secondaryFiles and self.fs_access.exists(sf_location):
addsf(
cast(
MutableSequence[CWLObjectType],
Expand Down Expand Up @@ -550,9 +531,7 @@ def addsf(
).makeError(message)
evaluated_format = cast(List[str], eval_format)
else:
raise SourceLine(
schema, "format", WorkflowException, debug
).makeError(
raise SourceLine(schema, "format", WorkflowException, debug).makeError(
"An expression in the 'format' field must "
"evaluate to a string, or list of strings. "
"However the type of the expression result was "
Expand Down Expand Up @@ -642,9 +621,7 @@ def generate_arg(self, binding: CWLObjectType) -> List[str]:
WorkflowException,
debug,
):
raise WorkflowException(
"'separate' option can not be specified without prefix"
)
raise WorkflowException("'separate' option can not be specified without prefix")

argl: MutableSequence[CWLOutputType] = []
if isinstance(value, MutableSequence):
Expand All @@ -653,9 +630,7 @@ def generate_arg(self, binding: CWLObjectType) -> List[str]:
argl = [itemSeparator.join([self.tostr(v) for v in value])]
elif binding.get("valueFrom"):
value = [self.tostr(v) for v in value]
return cast(List[str], ([prefix] if prefix else [])) + cast(
List[str], value
)
return cast(List[str], ([prefix] if prefix else [])) + cast(List[str], value)
elif prefix and value:
return [prefix]
else:
Expand Down
Loading