fix(api): skip model download if final converted version already exists (fixes #139)
This commit is contained in:
parent
4cc1d63cec
commit
7f6fa22b4e
|
@ -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:
|
||||||
|
|
|
@ -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(
|
||||||
|
|
Loading…
Reference in New Issue