@@ -215,7 +215,7 @@ def __init__(self, o_queue, loader, pattern):
215
215
self .loader = loader
216
216
self .datasize = 0
217
217
218
- @AMSMonitor (record = ["datasize" ])
218
+ @AMSMonitor (array = [ "msgs" ], record = ["datasize" ])
219
219
def __call__ (self ):
220
220
"""
221
221
Busy loop of reading all files matching the pattern and creating
@@ -226,6 +226,7 @@ def __call__(self):
226
226
start = time .time ()
227
227
files = list (glob .glob (self .pattern ))
228
228
for fn in files :
229
+ start_time_fs = time .time_ns ()
229
230
with self .loader (fn ) as fd :
230
231
domain_name , input_data , output_data = fd .load ()
231
232
print ("Domain Name is" , domain_name )
@@ -237,14 +238,28 @@ def __call__(self):
237
238
for j , (i , o ) in enumerate (zip (input_batches , output_batches )):
238
239
self .o_queue .put (QueueMessage (MessageType .Process , DataBlob (i , o , domain_name )))
239
240
self .datasize += input_data .nbytes + output_data .nbytes
241
+
242
+ end_time_fs = time .time_ns ()
243
+ msg = {
244
+ "file" : fn ,
245
+ "domain_name" : domain_name ,
246
+ "row_size" : row_size ,
247
+ "batch_size" : BATCH_SIZE ,
248
+ "rows_per_batch" : rows_per_batch ,
249
+ "num_batches" : num_batches ,
250
+ "size_bytes" : input_data .nbytes + output_data .nbytes ,
251
+ "process_time_ns" : end_time_fs - start_time_fs ,
252
+ }
253
+ # Msgs is the array (list) we push to (managed by AMSMonitor)
254
+ msgs .append (msg )
255
+
240
256
print (f"Sending Delete Message Type { self .__class__ .__name__ } " )
241
257
self .o_queue .put (QueueMessage (MessageType .Delete , fn ))
242
258
self .o_queue .put (QueueMessage (MessageType .Terminate , None ))
243
259
244
260
end = time .time ()
245
261
print (f"Spend { end - start } at { self .__class__ .__name__ } " )
246
262
247
-
248
263
class RMQDomainDataLoaderTask (Task ):
249
264
"""
250
265
A RMQDomainDataLoaderTask consumes 'AMSMessages' from RabbitMQ bundles the data of
@@ -283,8 +298,6 @@ def __init__(
283
298
self .orig_sig_handlers = {}
284
299
self .policy = policy
285
300
286
- # Counter that get incremented when we receive a message
287
- self .internal_msg_cnt = 0
288
301
289
302
# Signals can only be used within the main thread
290
303
if self .policy != "thread" :
@@ -340,12 +353,10 @@ def callback_message(self, ch, basic_deliver, properties, body):
340
353
341
354
self .total_time += (end_time - start_time )
342
355
# TODO: Improve the code to manage potentially multiple messages per AMSMessage
343
- # TODO: Right now the ID is not encoded in the AMSMessage by AMSlib
344
- # If order of messages matters we might have to encode it
345
356
msg = {
346
- "id" : self .internal_msg_cnt ,
347
357
"delivery_tag" : basic_deliver .delivery_tag ,
348
358
"mpi_rank" : msg .mpi_rank ,
359
+ "message_id" : msg .message_id ,
349
360
"domain_name" : domain_name ,
350
361
"num_elements" : msg .num_elements ,
351
362
"input_dim" : msg .input_dim ,
@@ -356,7 +367,6 @@ def callback_message(self, ch, basic_deliver, properties, body):
356
367
}
357
368
# Msgs is the array (list) we push to (managed by AMSMonitor)
358
369
msgs .append (msg )
359
- self .internal_msg_cnt += 1
360
370
361
371
def signal_wrapper (self , name , pid ):
362
372
def handler (signum , frame ):
@@ -621,11 +631,15 @@ def handler(signum, frame):
621
631
# This should only trigger RMQDomainDataLoaderTask
622
632
623
633
# TODO: I don't like this system to shutdown the pipeline on demand
624
- # It's extremely easy to mess thing up with signals.. and it's
634
+ # It's extremely easy to mess things up with signals.. and it's
625
635
# not a robust solution (if a task is not managing correctly SIGINT
626
636
# the pipeline can explode)
627
637
for e in self ._executors :
628
- os .kill (e .pid , signal .SIGINT )
638
+ if e is not None :
639
+ try :
640
+ os .kill (e .pid , signal .SIGINT )
641
+ except Exception as e :
642
+ print (f"Error: { e } " )
629
643
self .release_signals ()
630
644
return handler
631
645
0 commit comments