1
0
Fork 0

fix(api): improve cache logging

This commit is contained in:
Sean Sube 2023-03-05 19:30:52 -06:00
parent 39b9741b24
commit cfc20d3133
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 6 additions and 3 deletions

View File

@ -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:

View File

@ -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)