Skip to content

Commit e382302

Browse files
committed
more type fixes
1 parent c1879a0 commit e382302

26 files changed

+587
-493
lines changed

cwltool/builder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@
3131
from .errors import WorkflowException
3232
from .loghandler import _logger
3333
from .mutation import MutationManager
34-
from .pathmapper import CONTENT_LIMIT, get_listing, normalizeFilesDirs
3534
from .stdfsaccess import StdFsAccess
3635
from .utils import (
36+
CONTENT_LIMIT,
3737
CWLObjectType,
3838
CWLOutputType,
3939
aslist,
4040
docker_windows_path_adjust,
41+
get_listing,
42+
normalizeFilesDirs,
4143
onWindows,
4244
visit_class,
4345
)

cwltool/command_line_tool.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,7 @@
4646
from .job import CommandLineJob, JobBase
4747
from .loghandler import _logger
4848
from .mutation import MutationManager
49-
from .pathmapper import (
50-
PathMapper,
51-
adjustDirObjs,
52-
adjustFileObjs,
53-
get_listing,
54-
normalizeFilesDirs,
55-
trim_listing,
56-
)
49+
from .pathmapper import PathMapper
5750
from .process import (
5851
Process,
5952
_logger_validation_warnings,
@@ -69,12 +62,17 @@
6962
CWLOutputType,
7063
JobsGeneratorType,
7164
OutputCallbackType,
65+
adjustDirObjs,
66+
adjustFileObjs,
7267
aslist,
7368
convert_pathsep_to_unix,
7469
docker_windows_path_adjust,
70+
get_listing,
71+
normalizeFilesDirs,
7572
onWindows,
7673
random_outdir,
7774
shared_file_lock,
75+
trim_listing,
7876
upgrade_lock,
7977
visit_class,
8078
windows_default_container_id,
@@ -628,11 +626,15 @@ def update_status_output_callback(
628626
initialWorkdir["listing"],
629627
):
630628
if isinstance(t, Mapping) and "entry" in t:
631-
entry_exp = builder.do_eval(cast(str, t["entry"]), strip_whitespace=False)
629+
entry_exp = builder.do_eval(
630+
cast(str, t["entry"]), strip_whitespace=False
631+
)
632632
for entry in aslist(entry_exp):
633633
et = {"entry": entry}
634634
if "entryname" in t:
635-
et["entryname"] = builder.do_eval(cast(str, t["entryname"]))
635+
et["entryname"] = builder.do_eval(
636+
cast(str, t["entryname"])
637+
)
636638
else:
637639
et["entryname"] = None
638640
et["writable"] = t.get("writable", False)

cwltool/docker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
from .expression import JSON
2323
from .job import ContainerCommandLineJob
2424
from .loghandler import _logger
25-
from .pathmapper import MapperEnt, PathMapper, ensure_non_writable, ensure_writable
25+
from .pathmapper import MapperEnt, PathMapper
2626
from .utils import (
2727
DEFAULT_TMP_PREFIX,
2828
CWLObjectType,
2929
docker_windows_path_adjust,
30+
ensure_non_writable,
31+
ensure_writable,
3032
onWindows,
3133
)
3234

cwltool/executors.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,3 +427,24 @@ def run_jobs(
427427
self.run_job(None, runtime_context)
428428

429429
runtime_context.workflow_eval_lock.release()
430+
431+
432+
class NoopJobExecutor(JobExecutor):
433+
""" Do nothing executor, for testing purposes only. """
434+
def run_jobs(
435+
self,
436+
process: Process,
437+
job_order_object: Dict[str, Any],
438+
logger: logging.Logger,
439+
runtime_context: RuntimeContext,
440+
) -> None:
441+
pass
442+
443+
def execute(
444+
self,
445+
process: Process,
446+
job_order_object: Dict[str, Any],
447+
runtime_context: RuntimeContext,
448+
logger: Optional[logging.Logger] = None,
449+
) -> Tuple[Union[Optional[CWLObjectType], MutableSequence[CWLObjectType]], str]:
450+
return {}, "success"

cwltool/job.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@
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
4546
from .expression import JSON
4647
from .loghandler import _logger
47-
from .pathmapper import MapperEnt, PathMapper, ensure_non_writable, ensure_writable
48+
from .pathmapper import MapperEnt, PathMapper
4849
from .process import stage_files
4950
from .secrets import SecretStore
5051
from .utils import (
@@ -53,6 +54,8 @@
5354
Directory,
5455
bytes2str_in_dicts,
5556
copytree_with_merge,
57+
ensure_non_writable,
58+
ensure_writable,
5659
onWindows,
5760
processes_to_kill,
5861
)

cwltool/main.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
from .loghandler import _logger, defaultStreamHandler
6666
from .mutation import MutationManager
6767
from .pack import pack
68-
from .pathmapper import adjustDirObjs, normalizeFilesDirs, trim_listing
6968
from .process import (
7069
CWL_IANA,
7170
Process,
@@ -88,8 +87,11 @@
8887
from .update import ALLUPDATES, UPDATES
8988
from .utils import (
9089
DEFAULT_TMP_PREFIX,
90+
adjustDirObjs,
91+
normalizeFilesDirs,
9192
onWindows,
9293
processes_to_kill,
94+
trim_listing,
9395
versionstring,
9496
visit_class,
9597
windows_default_container_id,
@@ -640,11 +642,11 @@ class ProvLogFormatter(logging.Formatter):
640642
def __init__(self): # type: () -> None
641643
super(ProvLogFormatter, self).__init__("[%(asctime)sZ] %(message)s")
642644

643-
def formatTime(self, record, datefmt=None):
644-
# type: (logging.LogRecord, Optional[str]) -> str
645-
record_time = time.gmtime(record.created)
646-
formatted_time = time.strftime("%Y-%m-%dT%H:%M:%S", record_time)
647-
with_msecs = "%s,%03d" % (formatted_time, record.msecs)
645+
def formatTime(
646+
self, record: logging.LogRecord, datefmt: Optional[str] = None
647+
) -> str:
648+
formatted_time = time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(record.created))
649+
with_msecs = "%s,%03f" % (formatted_time, record.msecs)
648650
return with_msecs
649651

650652

0 commit comments

Comments
 (0)