fix(api): improve cache logging
This commit is contained in:
parent
39b9741b24
commit
cfc20d3133
|
@ -13,6 +13,7 @@ class ModelCache:
|
||||||
self.limit = limit
|
self.limit = limit
|
||||||
|
|
||||||
def drop(self, tag: str, key: Any) -> None:
|
def drop(self, tag: str, key: Any) -> None:
|
||||||
|
logger.debug("dropping item from cache: %s", tag)
|
||||||
self.cache[:] = [
|
self.cache[:] = [
|
||||||
model for model in self.cache if model[0] != tag and model[1] != key
|
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:
|
def get(self, tag: str, key: Any) -> Any:
|
||||||
for t, k, v in self.cache:
|
for t, k, v in self.cache:
|
||||||
if tag == t and key == k:
|
if tag == t and key == k:
|
||||||
|
logger.debug("found cached model: %s", tag)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
logger.debug("model not found in cache: %s", tag)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def set(self, tag: str, key: Any, value: Any) -> None:
|
def set(self, tag: str, key: Any, value: Any) -> None:
|
||||||
|
@ -44,7 +47,7 @@ class ModelCache:
|
||||||
total = len(self.cache)
|
total = len(self.cache)
|
||||||
if total > self.limit:
|
if total > self.limit:
|
||||||
logger.info(
|
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 :]
|
self.cache[:] = self.cache[-self.limit :]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -245,7 +245,7 @@ class DevicePoolExecutor:
|
||||||
return (True, p)
|
return (True, p)
|
||||||
|
|
||||||
if key not in self.active_jobs:
|
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)
|
return (None, 0)
|
||||||
|
|
||||||
_device, progress = self.active_jobs[key]
|
_device, progress = self.active_jobs[key]
|
||||||
|
@ -357,7 +357,7 @@ class DevicePoolExecutor:
|
||||||
else:
|
else:
|
||||||
self.total_jobs[device] = 1
|
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.recycle()
|
||||||
|
|
||||||
self.pending[device].put((key, fn, args, kwargs), block=False)
|
self.pending[device].put((key, fn, args, kwargs), block=False)
|
||||||
|
|
Loading…
Reference in New Issue