From 4b24d61e74ad2cb1ef271ccb59717f82324f4f60 Mon Sep 17 00:00:00 2001 From: TheoLisin Date: Tue, 7 Nov 2023 15:51:17 +0000 Subject: [PATCH] added logger to whatcher --- train/src/main.py | 1 + train/src/metrics_watcher.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/train/src/main.py b/train/src/main.py index 87795a8..da839a1 100644 --- a/train/src/main.py +++ b/train/src/main.py @@ -1104,6 +1104,7 @@ def on_results_file_changed(filepath, pbar): watch_file, on_results_file_changed, progress_bar_epochs(message="Epochs:", total=n_epochs_input.get_value()), + logger=sly.logger, ) # train model and upload best checkpoints to team files device = 0 if torch.cuda.is_available() else "cpu" diff --git a/train/src/metrics_watcher.py b/train/src/metrics_watcher.py index b8ece66..896ef0a 100644 --- a/train/src/metrics_watcher.py +++ b/train/src/metrics_watcher.py @@ -15,6 +15,7 @@ def __init__(self, watch_file, call_func_on_change=None, *args, **kwargs): self.call_func_on_change = call_func_on_change self.args = args self.kwargs = kwargs + self.logger = kwargs.get("logger", None) # Look for changes def look(self): @@ -28,10 +29,15 @@ def look(self): # Keep watching in a loop def watch(self): + from time import sleep + while self.running: try: # Look for changes self.look() + sleep(1) + if self.logger is not None: + self.logger.debug("Watcher is still looking") except KeyboardInterrupt: print("\nDone") break