From cfc20d3133b63803da660df2056c12936defa0c3 Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Sun, 5 Mar 2023 19:30:52 -0600 Subject: [PATCH] fix(api): improve cache logging --- api/onnx_web/server/model_cache.py | 5 ++++- api/onnx_web/worker/pool.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/onnx_web/server/model_cache.py b/api/onnx_web/server/model_cache.py index 7b1f4728..138f3a8d 100644 --- a/api/onnx_web/server/model_cache.py +++ b/api/onnx_web/server/model_cache.py @@ -13,6 +13,7 @@ class ModelCache: self.limit = limit def drop(self, tag: str, key: Any) -> None: + logger.debug("dropping item from cache: %s", tag) self.cache[:] = [ model for model in self.cache if model[0] != tag and model[1] != key ] @@ -20,8 +21,10 @@ class ModelCache: def get(self, tag: str, key: Any) -> Any: for t, k, v in self.cache: if tag == t and key == k: + logger.debug("found cached model: %s", tag) return v + logger.debug("model not found in cache: %s", tag) return None def set(self, tag: str, key: Any, value: Any) -> None: @@ -44,7 +47,7 @@ class ModelCache: total = len(self.cache) if total > self.limit: logger.info( - "Removing models from cache, %s of %s", (total - self.limit), total + "removing models from cache, %s of %s", (total - self.limit), total ) self.cache[:] = self.cache[-self.limit :] else: diff --git a/api/onnx_web/worker/pool.py b/api/onnx_web/worker/pool.py index 60d0930f..96550a8d 100644 --- a/api/onnx_web/worker/pool.py +++ b/api/onnx_web/worker/pool.py @@ -245,7 +245,7 @@ class DevicePoolExecutor: return (True, p) if key not in self.active_jobs: - logger.warn("checking status for unknown job: %s", key) + logger.debug("checking status for unknown job: %s", key) return (None, 0) _device, progress = self.active_jobs[key] @@ -357,7 +357,7 @@ class DevicePoolExecutor: else: self.total_jobs[device] = 1 - logger.debug("device job count: %s", self.total_jobs[device]) + logger.debug("job count for device %s: %s", device, self.total_jobs[device]) self.recycle() self.pending[device].put((key, fn, args, kwargs), block=False)