Skip to content

Commit beb6af7

Browse files
AlexTatemr-c
authored andcommitted
Reformatting and type hint updates
1 parent 6485cff commit beb6af7

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

cwltool/executors.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,9 @@ def run_jobs(
439439
logger: logging.Logger,
440440
runtime_context: RuntimeContext,
441441
) -> None:
442-
self.taskqueue: TaskQueue = TaskQueue(threading.Lock(), int(math.ceil(self.max_cores)), runtime_context)
442+
self.taskqueue: TaskQueue = TaskQueue(
443+
threading.Lock(), int(math.ceil(self.max_cores)), runtime_context
444+
)
443445
try:
444446
jobiter = process.job(job_order_object, self.output_callback, runtime_context)
445447

cwltool/workflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import os
21
import copy
32
import datetime
43
import functools
54
import logging
5+
import os
66
import random
77
from collections.abc import Mapping, MutableMapping, MutableSequence
88
from typing import Callable, Optional, cast
@@ -454,5 +454,5 @@ def job(
454454
def visit(self, op: Callable[[CommentedMap], None]) -> None:
455455
self.embedded_tool.visit(op)
456456

457-
def __repr__(self):
457+
def __repr__(self) -> str:
458458
return f"<{self.__class__.__name__} [{os.path.basename(self.id)}]>"

cwltool/workflow_job.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def job(
6666

6767
yield from self.step.job(joborder, output_callback, runtimeContext)
6868

69-
def __repr__(self):
69+
def __repr__(self) -> str:
7070
return f"<{self.__class__.__name__} [{self.name}]>"
7171

7272

@@ -92,7 +92,9 @@ def completed(self) -> int:
9292
"""The number of completed internal jobs."""
9393
return len(self._completed)
9494

95-
def receive_scatter_output(self, index: int, runtimeContext: RuntimeContext, jobout: CWLObjectType, processStatus: str) -> None:
95+
def receive_scatter_output(
96+
self, index: int, runtimeContext: RuntimeContext, jobout: CWLObjectType, processStatus: str
97+
) -> None:
9698
"""Record the results of a scatter operation."""
9799
for key, val in jobout.items():
98100
self.dest[key][index] = val
@@ -147,7 +149,10 @@ def parallel_steps(
147149
continue
148150
try:
149151
for j in step:
150-
if runtimeContext.on_error != "continue" and rc.processStatus not in ("success", "skipped"):
152+
if runtimeContext.on_error != "continue" and rc.processStatus not in (
153+
"success",
154+
"skipped",
155+
):
151156
break
152157
if j is not None:
153158
made_progress = True
@@ -260,7 +265,9 @@ def _flat_crossproduct_scatter(
260265
if len(scatter_keys) == 1:
261266
if runtimeContext.postScatterEval is not None:
262267
sjob = runtimeContext.postScatterEval(sjob)
263-
curriedcallback = functools.partial(callback.receive_scatter_output, put, runtimeContext)
268+
curriedcallback = functools.partial(
269+
callback.receive_scatter_output, put, runtimeContext
270+
)
264271
if sjob is not None:
265272
steps.append(process.job(sjob, curriedcallback, runtimeContext))
266273
else:
@@ -808,10 +815,7 @@ def job(
808815
self.made_progress = False
809816

810817
for step in self.steps:
811-
if (
812-
runtimeContext.on_error != "continue"
813-
and self.processStatus != "success"
814-
):
818+
if runtimeContext.on_error != "continue" and self.processStatus != "success":
815819
break
816820

817821
if not step.submitted:
@@ -855,8 +859,10 @@ def job(
855859
# or all outputs have been produced.
856860

857861
def __repr__(self):
862+
def __repr__(self) -> str:
858863
return f"<{self.__class__.__name__} [{self.name}]>"
859864

865+
860866
class WorkflowJobLoopStep:
861867
"""Generated for each step in Workflow.steps() containing a `loop` directive."""
862868

tests/test_parallel.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import math
33
import time
44
from pathlib import Path
5-
from typing import Union
5+
from typing import Union, cast
66

77
from cwltool.context import RuntimeContext
88
from cwltool.executors import MultithreadedJobExecutor
@@ -58,7 +58,7 @@ def selectResources(
5858
# arbitrary test values
5959
sleep_time = 3333 # a "sufficiently large" timeout
6060
n_sleepers = 4
61-
start_time = 0
61+
start_time = 0.0
6262

6363
try:
6464
start_time = time.time()
@@ -68,6 +68,6 @@ def selectResources(
6868
)
6969
except WorkflowStatus as e:
7070
end_time = time.time()
71-
output = e.out["roulette_mask"]
71+
output = cast(dict[str, list[bool]], e.out)["roulette_mask"]
7272
assert len(output) == n_sleepers and sum(output) == 1
73-
assert end_time - start_time < sleep_time
73+
assert end_time - start_time < sleep_time

0 commit comments

Comments
 (0)