Skip to content

Commit

Permalink
feat(tqdm): set mininterval to 10 seconds (#105)
Browse files Browse the repository at this point in the history
Reduce the primary cause of log spam in the runner: tqdm. Force the minimum refresh interval to 10 seconds.
  • Loading branch information
Caceresenzo authored Aug 22, 2024
1 parent bca1575 commit e82152b
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions crunch/monkey_patches.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import functools
import os
import pathlib
import logging
import sys


_APPLIED = False


Expand All @@ -15,6 +12,7 @@ def apply_all():
return

io_no_tty()
tqdm_init()
tqdm_display()
pathlib_str_functions()
keras_model_verbosity()
Expand All @@ -34,6 +32,25 @@ def io_no_tty():
io.isatty = lambda: False


TQDM_MININTERVAL = 10


def tqdm_init():
import tqdm

original = tqdm.tqdm.__init__

def patched(*args, **kwargs):
mininterval = kwargs.get("mininterval")
if mininterval is None or not isinstance(mininterval, (int, float)) or mininterval < TQDM_MININTERVAL:
kwargs = kwargs.copy()
kwargs["mininterval"] = TQDM_MININTERVAL

return original(*args, **kwargs)

tqdm.tqdm.__init__ = patched


def tqdm_display():
import tqdm

Expand All @@ -55,6 +72,8 @@ def tqdm_display(self, msg=None, pos=None):


def pathlib_str_functions():
import pathlib

functions = [
str.startswith,
str.endswith
Expand Down Expand Up @@ -121,6 +140,8 @@ def patched(self: _CatBoostBase, params):


def logging_file_handler():
import logging

original = logging.FileHandler.__init__

def patched(self: logging.FileHandler, filename: str, *args, **kwargs):
Expand All @@ -138,5 +159,5 @@ def pycaret_internal_logging():
import pycaret.internal.logging
except ModuleNotFoundError:
return

pycaret.internal.logging.LOGGER = pycaret.internal.logging.create_logger("/dev/stdout")

0 comments on commit e82152b

Please sign in to comment.