@@ -79,7 +79,7 @@ def kill_all_processes(self):
79
79
try :
80
80
self .parent_worker .finished_signal .emit ()
81
81
except Exception as e :
82
- print (f"Possible expected error during BiaPy's running thread deletion: { e } " )
82
+ self . parent_worker . main_gui . logger . error (f"Possible expected error during BiaPy's running thread deletion: { e } " )
83
83
self .close ()
84
84
85
85
def init_log (self , container_info ):
@@ -93,7 +93,7 @@ def update_gui(self, signal):
93
93
elif signal == 1 :
94
94
self .update_log ()
95
95
else :
96
- print ("Nothing" )
96
+ self . parent_worker . main_gui . logger . info ("Nothing" )
97
97
98
98
def update_log (self ):
99
99
finished_good = False
@@ -116,7 +116,7 @@ def update_cont_state(self, svalue):
116
116
try :
117
117
self .parent_worker .biapy_container .reload ()
118
118
except Exception as e :
119
- print (f"Possible expected error during container status reload(): { e } " )
119
+ self . parent_worker . main_gui . logger . error (f"Possible expected error during container status reload(): { e } " )
120
120
121
121
st = self .parent_worker .biapy_container .status
122
122
if st == "running" :
@@ -208,13 +208,13 @@ def __init__(self, main_gui, config, container_name, worker_id, output_folder, u
208
208
self .break_pulling = False
209
209
210
210
def stop_worker (self ):
211
- print ("Stopping the container . . . " )
211
+ self . main_gui . logger . info ("Stopping the container . . . " )
212
212
if self .biapy_container is not None :
213
213
self .biapy_container .stop (timeout = 1 )
214
214
try :
215
215
self .update_cont_state_signal .emit (1 )
216
216
except Exception as e :
217
- print (f"Possible expected error during BiaPy's running thread deletion: { e } " )
217
+ self . main_gui . logger . error (f"Possible expected error during BiaPy's running thread deletion: { e } " )
218
218
self .gui .run_window .stop_container_bn .setEnabled (False )
219
219
self .gui .run_window .test_progress_label .setEnabled (False )
220
220
self .gui .run_window .test_progress_bar .setEnabled (False )
@@ -223,7 +223,7 @@ def stop_worker(self):
223
223
self .gui .run_window .train_progress_bar .setEnabled (False )
224
224
self .gui .run_window .train_epochs_label .setEnabled (False )
225
225
else :
226
- print ("Container not running yet" )
226
+ self . main_gui . logger . info ("Container not running yet" )
227
227
# To kill pulling process if it is running
228
228
self .break_pulling = True
229
229
@@ -251,7 +251,7 @@ def run(self):
251
251
# Collect the output of the container and update the GUI
252
252
self .total_layers = {}
253
253
for item in self .docker_client .api .pull (self .main_gui .cfg .settings ['biapy_container_name' ], stream = True , decode = True ):
254
- print (item )
254
+ self . main_gui . logger . info (item )
255
255
if item ["status" ] == 'Pulling fs layer' :
256
256
self .total_layers [item ["id" ]+ "_download" ] = 0
257
257
self .total_layers [item ["id" ]+ "_extract" ] = 0
@@ -264,7 +264,7 @@ def run(self):
264
264
self .total_layers [item ["id" ]+ "_extract" ] = 1
265
265
266
266
if self .break_pulling :
267
- print ("Stopping pulling process . . ." )
267
+ self . main_gui . logger . info ("Stopping pulling process . . ." )
268
268
return
269
269
# Update GUI
270
270
steps = np .sum ([int (float (x )* 10 ) for x in self .total_layers .values ()])
@@ -296,7 +296,7 @@ def run(self):
296
296
try :
297
297
temp_cfg = yaml .safe_load (stream )
298
298
except yaml .YAMLError as exc :
299
- print (exc )
299
+ self . main_gui . logger . error (exc )
300
300
301
301
dist_backend = "gloo" if self .windows_os else "nccl"
302
302
command = ["--config" , "/BiaPy_files/input.yaml" , "--result_dir" , "{}" .format (self .output_folder_in_container ),
@@ -418,7 +418,7 @@ def run(self):
418
418
self .test_files = len (sorted (next (os .walk (self .config ['DATA' ]['TEST' ]['PATH' ]))[2 ]))
419
419
self .gui .run_window .test_progress_bar .setMaximum (self .test_files )
420
420
421
- print ("Creating temporal input YAML file" )
421
+ self . main_gui . logger . info ("Creating temporal input YAML file" )
422
422
with open (real_cfg_input , 'w' ) as outfile :
423
423
yaml .dump (temp_cfg , outfile , default_flow_style = False )
424
424
@@ -429,11 +429,11 @@ def run(self):
429
429
430
430
# Run container
431
431
# check_command = [ "python3", "-u", "-c", "'import torch; print(torch.cuda.is_available())'"]
432
- print (f"Command: { command } " )
433
- print (f"Volumes: { volumes } " )
434
- print (f"GPU (IDs): { gpus } " )
435
- print (f"CPUs: { cpu_count } " )
436
- print (f"GUI version: { self .main_gui .cfg .settings ['biapy_gui_version' ]} " )
432
+ self . main_gui . logger . info (f"Command: { command } " )
433
+ self . main_gui . logger . info (f"Volumes: { volumes } " )
434
+ self . main_gui . logger . info (f"GPU (IDs): { gpus } " )
435
+ self . main_gui . logger . info (f"CPUs: { cpu_count } " )
436
+ self . main_gui . logger . info (f"GUI version: { self .main_gui .cfg .settings ['biapy_gui_version' ]} " )
437
437
nofile_limit = docker .types .Ulimit (name = 'nofile' , soft = 10000 , hard = 10000 )
438
438
self .biapy_container = self .docker_client .containers .run (
439
439
self .container_name ,
@@ -449,7 +449,7 @@ def run(self):
449
449
cpu_count = cpu_count ,
450
450
)
451
451
self .process_steps = "running"
452
- print ("Container created!" )
452
+ self . main_gui . logger . info ("Container created!" )
453
453
454
454
# Set the window header
455
455
self .container_info = \
@@ -497,7 +497,7 @@ def run(self):
497
497
for log in self .biapy_container .logs (stream = True ):
498
498
l = log .decode ("utf-8" )
499
499
try :
500
- print (l .encode ("utf-8" ) if self .windows_os else l , end = "" )
500
+ self . main_gui . logger . info (l .encode ("utf-8" ) if self .windows_os else l , end = "" )
501
501
except :
502
502
pass
503
503
try :
@@ -543,7 +543,7 @@ def run(self):
543
543
f .close ()
544
544
except :
545
545
# Print first the traceback (only visible through terminal)
546
- print (traceback .format_exc ())
546
+ self . main_gui . logger . error (traceback .format_exc ())
547
547
548
548
# Try to log the error in the error file
549
549
ferr = open (self .container_stderr_file , "w" )
0 commit comments