Skip to content

Commit

Permalink
fix(api): bypass model cache entirely when limit is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Feb 15, 2023
1 parent 2b29b09 commit df5fb93
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions api/logging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ formatters:
handlers:
console:
class: logging.StreamHandler
level: INFO
level: DEBUG
formatter: simple
stream: ext://sys.stdout
loggers:
'':
level: INFO
level: DEBUG
handlers: [console]
propagate: True
root:
level: INFO
handlers: [console]
level: DEBUG
handlers: [console]
2 changes: 1 addition & 1 deletion api/onnx_web/diffusion/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def load_pipeline(
lpw: bool,
):
pipe_key = (pipeline, model, device.device, device.provider, lpw)
scheduler_key = (scheduler_type,)
scheduler_key = (scheduler_type, model)

cache_pipe = server.cache.get("diffusion", pipe_key)

Expand Down
4 changes: 4 additions & 0 deletions api/onnx_web/server/model_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def get(self, tag: str, key: Any) -> Any:
return None

def set(self, tag: str, key: Any, value: Any) -> None:
if self.limit == 0:
logger.debug("Cache limit set to 0, not caching model: %s", tag)
return

for i in range(len(self.cache)):
t, k, v = self.cache[i]
if tag == t:
Expand Down

0 comments on commit df5fb93

Please sign in to comment.