@@ -128,9 +128,11 @@ def run(self, graph, config, updatehash=False):
128
128
old_progress_stats = None
129
129
old_presub_stats = None
130
130
while not np .all (self .proc_done ) or np .any (self .proc_pending ):
131
- # Check to see if a job is available (jobs without dependencies not run)
132
- # See https://github.com/nipy/nipype/pull/2200#discussion_r141605722
133
- jobs_ready = np .nonzero (~ self .proc_done & (self .depidx .sum (0 ) == 0 ))[1 ]
131
+ loop_start = time ()
132
+ # Check if a job is available (jobs with all dependencies run)
133
+ # https://github.com/nipy/nipype/pull/2200#discussion_r141605722
134
+ jobs_ready = np .nonzero (~ self .proc_done &
135
+ (self .depidx .sum (0 ) == 0 ))[1 ]
134
136
135
137
progress_stats = (len (self .proc_done ),
136
138
np .sum (self .proc_done ^ self .proc_pending ),
@@ -164,7 +166,8 @@ def run(self, graph, config, updatehash=False):
164
166
self ._remove_node_dirs ()
165
167
self ._clear_task (taskid )
166
168
else :
167
- assert self .proc_done [jobid ] and self .proc_pending [jobid ]
169
+ assert self .proc_done [jobid ] and \
170
+ self .proc_pending [jobid ]
168
171
toappend .insert (0 , (taskid , jobid ))
169
172
170
173
if toappend :
@@ -183,7 +186,8 @@ def run(self, graph, config, updatehash=False):
183
186
elif display_stats :
184
187
logger .debug ('Not submitting (max jobs reached)' )
185
188
186
- sleep (poll_sleep_secs )
189
+ sleep_til = loop_start + poll_sleep_secs
190
+ sleep (max (0 , sleep_til - time ()))
187
191
188
192
self ._remove_node_dirs ()
189
193
report_nodes_not_run (notrun )
@@ -271,8 +275,8 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
271
275
if (num_jobs >= self .max_jobs ) or (slots == 0 ):
272
276
break
273
277
274
- # Check to see if a job is available (jobs without dependencies not run)
275
- # See https://github.com/nipy/nipype/pull/2200#discussion_r141605722
278
+ # Check if a job is available (jobs with all dependencies run)
279
+ # https://github.com/nipy/nipype/pull/2200#discussion_r141605722
276
280
jobids = np .nonzero (~ self .proc_done & (self .depidx .sum (0 ) == 0 ))[1 ]
277
281
278
282
if len (jobids ) > 0 :
@@ -325,7 +329,8 @@ def _send_procs_to_workers(self, updatehash=False, graph=None):
325
329
break
326
330
327
331
def _local_hash_check (self , jobid , graph ):
328
- if not str2bool (self .procs [jobid ].config ['execution' ]['local_hash_check' ]):
332
+ if not str2bool (self .procs [jobid ].config ['execution' ][
333
+ 'local_hash_check' ]):
329
334
return False
330
335
331
336
logger .debug ('Checking hash (%d) locally' , jobid )
@@ -397,8 +402,8 @@ def _remove_node_dirs(self):
397
402
"""Removes directories whose outputs have already been used up
398
403
"""
399
404
if str2bool (self ._config ['execution' ]['remove_node_directories' ]):
400
- for idx in np .nonzero (
401
- ( self . refidx . sum ( axis = 1 ) == 0 ). __array__ ())[ 0 ] :
405
+ indices = np .nonzero (( self . refidx . sum ( axis = 1 ) == 0 ). __array__ ())[ 0 ]
406
+ for idx in indices :
402
407
if idx in self .mapnodesubids :
403
408
continue
404
409
if self .proc_done [idx ] and (not self .proc_pending [idx ]):
@@ -513,7 +518,8 @@ class GraphPluginBase(PluginBase):
513
518
514
519
def __init__ (self , plugin_args = None ):
515
520
if plugin_args and plugin_args .get ('status_callback' ):
516
- logger .warning ('status_callback not supported for Graph submission plugins' )
521
+ logger .warning ('status_callback not supported for Graph submission'
522
+ ' plugins' )
517
523
super (GraphPluginBase , self ).__init__ (plugin_args = plugin_args )
518
524
519
525
def run (self , graph , config , updatehash = False ):
0 commit comments