From 85214ec3030f497e68544d25b86f03aeb3309f49 Mon Sep 17 00:00:00 2001 From: Steven Palma Date: Fri, 7 Mar 2025 14:54:43 +0100 Subject: [PATCH] fix(lerobot/common/utils): remove lint warnings/errors --- lerobot/common/utils/benchmark.py | 4 ++-- lerobot/common/utils/import_utils.py | 2 +- lerobot/common/utils/logging_utils.py | 2 ++ lerobot/common/utils/utils.py | 2 +- lerobot/common/utils/wandb_utils.py | 4 ++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lerobot/common/utils/benchmark.py b/lerobot/common/utils/benchmark.py index 4b08e6f6d..8d8868df6 100644 --- a/lerobot/common/utils/benchmark.py +++ b/lerobot/common/utils/benchmark.py @@ -68,9 +68,9 @@ class TimeBenchmark(ContextDecorator): Block took approximately 10.00 milliseconds """ - def __init__(self, print=False): + def __init__(self, print_time=False): self.local = threading.local() - self.print_time = print + self.print_time = print_time def __enter__(self): self.local.start_time = time.perf_counter() diff --git a/lerobot/common/utils/import_utils.py b/lerobot/common/utils/import_utils.py index cd5f82450..4f4e5b52e 100644 --- a/lerobot/common/utils/import_utils.py +++ b/lerobot/common/utils/import_utils.py @@ -46,7 +46,7 @@ def is_package_available(pkg_name: str, return_version: bool = False) -> tuple[b else: # For packages other than "torch", don't attempt the fallback and set as not available package_exists = False - logging.debug(f"Detected {pkg_name} version: {package_version}") + logging.debug("Detected %s version: %s", {pkg_name}, package_version) if return_version: return package_exists, package_version else: diff --git a/lerobot/common/utils/logging_utils.py b/lerobot/common/utils/logging_utils.py index b99c348f7..25ca22f68 100644 --- a/lerobot/common/utils/logging_utils.py +++ b/lerobot/common/utils/logging_utils.py @@ -27,6 +27,8 @@ class AverageMeter: def __init__(self, name: str, fmt: str = ":f"): self.name = name self.fmt = fmt + self.val = 0.0 + self.avg = 0.0 self.reset() def reset(self) -> None: diff --git a/lerobot/common/utils/utils.py b/lerobot/common/utils/utils.py index 563a7b813..88acb39fd 100644 --- a/lerobot/common/utils/utils.py +++ b/lerobot/common/utils/utils.py @@ -69,7 +69,7 @@ def get_safe_torch_device(try_device: str, log: bool = False) -> torch.device: case _: device = torch.device(try_device) if log: - logging.warning(f"Using custom {try_device} device.") + logging.warning("Using custom %s device.", try_device) return device diff --git a/lerobot/common/utils/wandb_utils.py b/lerobot/common/utils/wandb_utils.py index 9985b894c..141278372 100644 --- a/lerobot/common/utils/wandb_utils.py +++ b/lerobot/common/utils/wandb_utils.py @@ -86,7 +86,7 @@ class WandBLogger: resume="must" if cfg.resume else None, ) print(colored("Logs will be synced with wandb.", "blue", attrs=["bold"])) - logging.info(f"Track this run --> {colored(wandb.run.get_url(), 'yellow', attrs=['bold'])}") + logging.info("Track this run --> %s", colored(wandb.run.get_url(), "yellow", attrs=["bold"])) self._wandb = wandb def log_policy(self, checkpoint_dir: Path): @@ -108,7 +108,7 @@ class WandBLogger: for k, v in d.items(): if not isinstance(v, (int, float, str)): logging.warning( - f'WandB logging of key "{k}" was ignored as its type is not handled by this wrapper.' + 'WandB logging of key "%s" was ignored as its type is not handled by this wrapper.', k ) continue self._wandb.log({f"{mode}/{k}": v}, step=step)