Skip to content

Commit

Permalink
fix(api): skip model download if final converted version already exis…
Browse files Browse the repository at this point in the history
…ts (fixes #139)
  • Loading branch information
ssube committed Feb 14, 2023
1 parent 4cc1d63 commit 7f6fa22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions api/onnx_web/convert/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ 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

# add an extension if possible, some of the conversion code checks for it
if model_format is None:
Expand Down
2 changes: 1 addition & 1 deletion api/onnx_web/convert/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def download_progress(urls: List[Tuple[str, str]]):
dest_path.parent.mkdir(parents=True, exist_ok=True)

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

req = requests.get(
Expand Down

0 comments on commit 7f6fa22

Please sign in to comment.