1
0
Fork 0

fix(api): check for cache rather than converted model before fetch

This commit is contained in:
Sean Sube 2023-03-07 23:51:27 -06:00
parent 843e2f1ff3
commit c0b88733b8
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
1 changed files with 6 additions and 9 deletions

View File

@ -138,14 +138,7 @@ base_models: Models = {
def fetch_model(
ctx: ConversionContext, name: str, source: str, model_format: Optional[str] = None
) -> str:
cache_name = path.join(ctx.cache_path, name)
model_path = path.join(ctx.model_path, name)
model_onnx = model_path + ".onnx"
for p in [model_path, model_onnx]:
if path.exists(p):
logger.debug("model already exists, skipping fetch")
return p
cache_path = path.join(ctx.cache_path, name)
# add an extension if possible, some of the conversion code checks for it
if model_format is None:
@ -155,7 +148,11 @@ def fetch_model(
if ext is not None:
cache_name += ext
else:
cache_name = "%s.%s" % (cache_name, model_format)
cache_name = "%s.%s" % (cache_path, model_format)
if path.exists(cache_name):
logger.debug("model already exists in cache, skipping fetch")
return cache_name
for proto in model_sources:
api_name, api_root = model_sources.get(proto)