Consolidate StatsTracker as LocalWriter; cleaned up functions to write (#88)

* removed stats tracker; consolidate writers into local writer

* basic revamp of stats tracker/writers
This commit is contained in:
evonneng authored and GitHub committed 2022-05-20 08:51:45 -07:00
1 parent 2287eb3455
commit 10d713f84b
9 files changed
+256 -311

No files matched your search

+3 -31
View File
@@ -19,24 +19,12 @@ def decorate_all(decorators: List[Callable]) -> Callable:
return decorate
def check_stats_enabled(func: Callable) -> Callable:
"""Decorator: check if stats tracker is enabled"""
def wrapper(self, *args, **kwargs):
ret = None
if self.config.logging.enable_stats:
ret = func(self, *args, **kwargs)
return ret
return wrapper
def check_profiler_enabled(func: Callable) -> Callable:
"""Decorator: check if profiler is enabled"""
def wrapper(self, *args, **kwargs):
ret = None
if self.config.enable_stats:
if self.config.enable_profiler:
ret = func(self, *args, **kwargs)
return ret
@@ -46,26 +34,10 @@ def check_profiler_enabled(func: Callable) -> Callable:
def check_main_thread(func: Callable) -> Callable:
"""Decorator: check if you are on main thread"""
def wrapper(self, *args, **kwargs):
def wrapper(*args, **kwargs):
ret = None
if comms.is_main_process():
ret = func(self, *args, **kwargs)
return ret
return wrapper
def check_print_stats_step(func: Callable) -> Callable:
"""Decorator: check if it is time to print stats update"""
def wrapper(self, *args, **kwargs):
ret = None
if (
self.step % self.config.logging.steps_per_log == 0
or (self.config.graph.steps_per_save and self.step % self.config.graph.steps_per_save == 0)
or self.step % self.config.graph.steps_per_test == 0
):
ret = func(self, *args, **kwargs)
ret = func(*args, **kwargs)
return ret
return wrapper