Skip to content

Commit d236eff

Browse files
committed
the tests pass!
1 parent 182a68c commit d236eff

20 files changed

+83
-72
lines changed

cwltool/command_line_tool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def run(
277277
getdefault(runtimeContext.compute_checksum, True),
278278
),
279279
"success",
280-
)
280+
)
281281

282282

283283
def check_adjust(builder: Builder, file_o: CWLObjectType) -> CWLObjectType:

cwltool/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __init__(self, kwargs: Optional[Dict[str, Any]] = None) -> None:
118118
self.basedir = "" # type: str
119119
self.toplevel = False # type: bool
120120
self.mutation_manager = None # type: Optional[MutationManager]
121-
self.make_fs_access = StdFsAccess # type: Type[StdFsAccess]
121+
self.make_fs_access = StdFsAccess # type: Callable[[str], StdFsAccess]
122122
self.path_mapper = PathMapper
123123
self.builder = None # type: Optional[Builder]
124124
self.docker_outdir = "" # type: str

cwltool/executors.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@
1818
Set,
1919
Tuple,
2020
Union,
21+
cast,
2122
)
2223

2324
import psutil
2425
from schema_salad.exceptions import ValidationException
2526
from schema_salad.sourceline import SourceLine
2627

27-
from .command_line_tool import CallbackJob
28+
from .command_line_tool import CallbackJob, ExpressionJob
2829
from .context import RuntimeContext, getdefault
2930
from .errors import WorkflowException
3031
from .job import JobBase
@@ -63,19 +64,19 @@ def output_callback(
6364
def run_jobs(
6465
self,
6566
process: Process,
66-
job_order_object: Dict[str, Any],
67+
job_order_object: CWLObjectType,
6768
logger: logging.Logger,
6869
runtime_context: RuntimeContext,
6970
) -> None:
7071
"""Execute the jobs for the given Process."""
7172

7273
def execute(
7374
self,
74-
process, # type: Process
75-
job_order_object, # type: Dict[str, Any]
76-
runtime_context, # type: RuntimeContext
77-
logger=_logger, # type: logging.Logger
78-
): # type: (...) -> Tuple[Union[Optional[CWLObjectType], MutableSequence[CWLObjectType]], str]
75+
process: Process,
76+
job_order_object: CWLObjectType,
77+
runtime_context: RuntimeContext,
78+
logger: logging.Logger = _logger,
79+
) -> Tuple[Union[Optional[CWLObjectType], MutableSequence[CWLObjectType]], str]:
7980
"""Execute the process."""
8081
if not runtime_context.basedir:
8182
raise WorkflowException("Must provide 'basedir' in runtimeContext")
@@ -102,7 +103,7 @@ def check_for_abstract_op(tool: MutableMapping[str, Any]) -> None:
102103
runtime_context.toplevel = True
103104
runtime_context.workflow_eval_lock = threading.Condition(threading.RLock())
104105

105-
job_reqs = None
106+
job_reqs = None # type: Optional[List[CWLObjectType]]
106107
if "https://w3id.org/cwl/cwl#requirements" in job_order_object:
107108
if (
108109
process.metadata.get("http://commonwl.org/cwltool#original_cwlVersion")
@@ -113,7 +114,10 @@ def check_for_abstract_op(tool: MutableMapping[str, Any]) -> None:
113114
"v1.0. You can adjust to use `cwltool:overrides` instead; or you "
114115
"can set the cwlVersion to v1.1"
115116
)
116-
job_reqs = job_order_object["https://w3id.org/cwl/cwl#requirements"]
117+
job_reqs = cast(
118+
List[CWLObjectType],
119+
job_order_object["https://w3id.org/cwl/cwl#requirements"],
120+
)
117121
elif (
118122
"cwl:defaults" in process.metadata
119123
and "https://w3id.org/cwl/cwl#requirements"
@@ -299,7 +303,7 @@ def select_resources(
299303
return result
300304

301305
def _runner(self, job, runtime_context, TMPDIR_LOCK):
302-
# type: (Union[JobBase, WorkflowJob, CallbackJob], RuntimeContext, threading.Lock) -> None
306+
# type: (Union[JobBase, WorkflowJob, CallbackJob, ExpressionJob], RuntimeContext, threading.Lock) -> None
303307
"""Job running thread."""
304308
try:
305309
_logger.debug(
@@ -435,7 +439,7 @@ class NoopJobExecutor(JobExecutor):
435439
def run_jobs(
436440
self,
437441
process: Process,
438-
job_order_object: Dict[str, Any],
442+
job_order_object: CWLObjectType,
439443
logger: logging.Logger,
440444
runtime_context: RuntimeContext,
441445
) -> None:
@@ -444,7 +448,7 @@ def run_jobs(
444448
def execute(
445449
self,
446450
process: Process,
447-
job_order_object: Dict[str, Any],
451+
job_order_object: CWLObjectType,
448452
runtime_context: RuntimeContext,
449453
logger: Optional[logging.Logger] = None,
450454
) -> Tuple[Union[Optional[CWLObjectType], MutableSequence[CWLObjectType]], str]:

cwltool/job.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@
3434

3535
import psutil
3636
import shellescape
37-
from prov.model import PROV
3837
from schema_salad.sourceline import SourceLine
3938
from schema_salad.utils import json_dump, json_dumps
4039
from typing_extensions import TYPE_CHECKING
4140

41+
from prov.model import PROV
42+
4243
from .builder import Builder, HasReqsHints
4344
from .context import RuntimeContext, getdefault
4445
from .errors import UnsupportedRequirement, WorkflowException
@@ -48,10 +49,10 @@
4849
from .process import stage_files
4950
from .secrets import SecretStore
5051
from .utils import (
51-
OutputCallbackType,
5252
DEFAULT_TMP_PREFIX,
5353
CWLObjectType,
5454
Directory,
55+
OutputCallbackType,
5556
bytes2str_in_dicts,
5657
copytree_with_merge,
5758
ensure_non_writable,
@@ -292,7 +293,7 @@ def _execute(
292293
runtime: List[str],
293294
env: MutableMapping[str, str],
294295
runtimeContext: RuntimeContext,
295-
monitor_function = None # type: Optional[Callable[[subprocess.Popen[str]], None]]
296+
monitor_function=None, # type: Optional[Callable[[subprocess.Popen[str]], None]]
296297
) -> None:
297298

298299
scr = self.get_requirement("ShellCommandRequirement")[0]
@@ -487,9 +488,7 @@ def _execute(
487488
)
488489
shutil.rmtree(self.tmpdir, True)
489490

490-
def process_monitor(
491-
self, sproc
492-
): # type: (subprocess.Popen[str]) -> None
491+
def process_monitor(self, sproc): # type: (subprocess.Popen[str]) -> None
493492
monitor = psutil.Process(sproc.pid)
494493
# Value must be list rather than integer to utilise pass-by-reference in python
495494
memory_usage = [None] # type: MutableSequence[Optional[int]]
@@ -602,16 +601,16 @@ def get_from_requirements(
602601

603602
@abstractmethod
604603
def create_runtime(
605-
self,
606-
env: MutableMapping[str, str],
607-
runtime_context: RuntimeContext,
604+
self, env: MutableMapping[str, str], runtime_context: RuntimeContext,
608605
) -> Tuple[List[str], Optional[str]]:
609606
"""Return the list of commands to run the selected container engine."""
610607
pass
611608

612609
@staticmethod
613610
@abstractmethod
614-
def append_volume(runtime: List[str], source: str, target: str, writable: bool=False) -> None:
611+
def append_volume(
612+
runtime: List[str], source: str, target: str, writable: bool = False
613+
) -> None:
615614
"""Add binding arguments to the runtime list."""
616615
pass
617616

@@ -719,7 +718,7 @@ def run(
719718
self,
720719
runtimeContext: RuntimeContext,
721720
tmpdir_lock: Optional[threading.Lock] = None,
722-
) -> None:
721+
) -> None:
723722
if tmpdir_lock:
724723
with tmpdir_lock:
725724
if not os.path.exists(self.tmpdir):

cwltool/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ def find_deps(
538538
document_loader: Loader,
539539
uri: str,
540540
basedir: Optional[str] = None,
541-
nestdirs: bool =True,
541+
nestdirs: bool = True,
542542
) -> Dict[str, Any]:
543543
"""Find the dependencies of the CWL document."""
544544
deps = {

cwltool/provenance.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from collections import OrderedDict
1414
from getpass import getuser
1515
from io import BytesIO, FileIO, TextIOWrapper, open
16+
from pathlib import Path, PurePath, PurePosixPath
1617
from socket import getfqdn
1718
from types import ModuleType
1819
from typing import (
@@ -32,15 +33,15 @@
3233
cast,
3334
)
3435

35-
import prov.model as provM
36-
from pathlib import Path, PurePath, PurePosixPath
37-
from prov.identifier import Identifier, Namespace
38-
from prov.model import PROV, ProvDocument, ProvEntity
3936
from ruamel import yaml
4037
from schema_salad.sourceline import SourceLine
4138
from schema_salad.utils import json_dumps
4239
from typing_extensions import TYPE_CHECKING
4340

41+
import prov.model as provM
42+
from prov.identifier import Identifier, Namespace
43+
from prov.model import PROV, ProvDocument, ProvEntity
44+
4445
from .context import RuntimeContext
4546
from .errors import WorkflowException
4647
from .loghandler import _logger
@@ -169,19 +170,16 @@ def __init__(self, research_object: "ResearchObject", rel_path: str) -> None:
169170
_logger.debug("[provenance] Creating WritableBagFile at %s.", path)
170171
super(WritableBagFile, self).__init__(path, mode="w")
171172

172-
def write(self, b):
173-
# type: (Union[bytes, str]) -> int
174-
if isinstance(b, bytes):
175-
real_b = b
176-
else:
177-
real_b = b.encode("utf-8")
173+
def write(self, b: Union[bytes, str]) -> int:
174+
real_b = b if isinstance(b, bytes) else b.encode("utf-8")
178175
total = 0
179176
length = len(real_b)
180177
while total < length:
181178
ret = super(WritableBagFile, self).write(real_b)
182179
if ret:
183180
total += ret
184181
for val in self.hashes.values():
182+
# print("Updating hasher %s ", val)
185183
val.update(real_b)
186184
return total
187185

cwltool/resolver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import os
44
import sys
55
import urllib
6+
from pathlib import Path
67
from typing import Any, Optional
78

8-
from pathlib import Path
99
from schema_salad.ref_resolver import Loader
1010

1111
from .loghandler import _logger

cwltool/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import uuid
1515
from functools import partial
1616
from itertools import zip_longest
17+
from pathlib import Path
1718
from tempfile import NamedTemporaryFile
1819
from types import ModuleType
1920
from typing import (
@@ -38,7 +39,6 @@
3839
from cachecontrol import CacheControl
3940
from cachecontrol.caches import FileCache
4041
from mypy_extensions import TypedDict
41-
from pathlib import Path
4242
from schema_salad.exceptions import ValidationException
4343
from schema_salad.ref_resolver import Loader
4444
from typing_extensions import TYPE_CHECKING, Deque

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
# "cwltool/pathmapper.py", # class PathMapper needs to be subclassable
5454
"cwltool/process.py",
5555
"cwltool/procgenerator.py",
56-
"cwltool/provenance.py",
56+
# "cwltool/provenance.py", # WritableBag is having issues
5757
"cwltool/resolver.py",
5858
# "cwltool/sandboxjs.py", # probably not speed critical, tests need to mock components
5959
"cwltool/secrets.py",

tests/test_docker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from distutils import spawn
22

3+
import py.path
4+
35
from cwltool.docker import DockerCommandLineJob
46
from cwltool.main import main
57

68
from .util import get_data, get_main_output, needs_docker, needs_singularity
7-
import py.path
9+
810

911
@needs_docker # type: ignore
1012
def test_docker_workflow(tmpdir: py.path.local) -> None:

tests/test_docker_info.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from .util import get_data, get_main_output, needs_docker
32

43

tests/test_docker_paths_with_colons.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from typing import Any
2+
13
from cwltool.docker import DockerCommandLineJob
24
from cwltool.main import main
35

46
from .util import needs_docker
57

6-
from typing import Any
78

89
def test_docker_append_volume_read_only(mocker: Any) -> None:
910
mocker.patch("os.mkdir")

0 commit comments

Comments
 (0)