Skip to content

Commit 447ba37

Browse files
author
Peter Amstutz
committed
MyPy fixes.
1 parent c3f0698 commit 447ba37

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

cwltool/context.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(self, kwargs=None):
101101
self.docker_stagedir = "" # type: Text
102102
self.js_console = False # type: bool
103103
self.job_script_provider = None # type: Optional[DependenciesConfiguration]
104-
self.select_resources = None # type: Optional[Callable[[Dict[Text, int]], Dict[Text, int]]]
104+
self.select_resources = None # type: Optional[Callable[[Dict[Text, int], RuntimeContext], Dict[Text, int]]]
105105
self.eval_timeout = 20 # type: float
106106
self.postScatterEval = None # type: Optional[Callable[[Dict[Text, Any]], Dict[Text, Any]]]
107107
self.on_error = "stop" # type: Text
@@ -110,7 +110,7 @@ def __init__(self, kwargs=None):
110110
self.cidfile_dir = None
111111
self.cidfile_prefix = None
112112

113-
self.workflow_eval_lock = None # type: threading.Condition
113+
self.workflow_eval_lock = None # type: Optional[threading.Condition]
114114

115115
super(RuntimeContext, self).__init__(kwargs)
116116

cwltool/executors.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __init__(self): # type: () -> None
140140
super(MultithreadedJobExecutor, self).__init__()
141141
self.threads = set() # type: Set[threading.Thread]
142142
self.exceptions = [] # type: List[WorkflowException]
143-
self.pending_jobs = []
143+
self.pending_jobs = [] # type: List[JobBase]
144144

145145
self.max_ram = psutil.virtual_memory().total / 2**20
146146
self.max_cores = psutil.cpu_count()
@@ -207,9 +207,10 @@ def runner():
207207
self.allocated_cores += job.builder.resources["cores"]
208208
thread.start()
209209

210-
def wait_for_next_completion(self, runtimeContext): # type: () -> None
210+
def wait_for_next_completion(self, runtimeContext): # type: (RuntimeContext) -> None
211211
""" Wait for jobs to finish. """
212-
runtimeContext.workflow_eval_lock.wait()
212+
if runtimeContext.workflow_eval_lock is not None:
213+
runtimeContext.workflow_eval_lock.wait()
213214
if self.exceptions:
214215
raise self.exceptions[0]
215216

@@ -222,6 +223,9 @@ def run_jobs(self,
222223

223224
jobiter = process.job(job_order_object, self.output_callback, runtimeContext)
224225

226+
if runtimeContext.workflow_eval_lock is None:
227+
raise WorkflowException("runtimeContext.workflow_eval_lock must not be None")
228+
225229
runtimeContext.workflow_eval_lock.acquire()
226230
for job in jobiter:
227231
if job is not None:

cwltool/job.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,9 @@ def _execute(self,
324324
host_outdir, p.target[len(container_outdir)+1:])
325325
os.remove(host_outdir_tgt)
326326

327+
if runtimeContext.workflow_eval_lock is None:
328+
raise WorkflowException("runtimeContext.workflow_eval_lock must not be None")
329+
327330
with runtimeContext.workflow_eval_lock:
328331
self.output_callback(outputs, processStatus)
329332

0 commit comments

Comments
 (0)