1
0
Fork 0

fix(api): skip model download if final converted version already exists (fixes #139)

This commit is contained in:
Sean Sube 2023-02-13 23:03:51 -06:00
parent 4cc1d63cec
commit 7f6fa22b4e
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 8 additions and 1 deletions

View File

@ -136,6 +136,13 @@ def fetch_model(
ctx: ConversionContext, name: str, source: str, model_format: Optional[str] = None ctx: ConversionContext, name: str, source: str, model_format: Optional[str] = None
) -> str: ) -> str:
cache_name = path.join(ctx.cache_path, name) 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
# add an extension if possible, some of the conversion code checks for it # add an extension if possible, some of the conversion code checks for it
if model_format is None: if model_format is None:

View File

@ -49,7 +49,7 @@ def download_progress(urls: List[Tuple[str, str]]):
dest_path.parent.mkdir(parents=True, exist_ok=True) dest_path.parent.mkdir(parents=True, exist_ok=True)
if dest_path.exists(): if dest_path.exists():
logger.info("Destination already exists: %s", dest_path) logger.debug("Destination already exists: %s", dest_path)
return str(dest_path.absolute()) return str(dest_path.absolute())
req = requests.get( req = requests.get(