Skip to content

Commit

Permalink
models_check: retry 5 times for HuggingFace
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
  • Loading branch information
bigcat88 committed Sep 13, 2024
1 parent e412c1a commit 9463a9a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion scripts/ci/models_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import sys
from pathlib import Path
from time import sleep

import requests
from huggingface_hub import HfApi
Expand All @@ -19,7 +20,7 @@ def parse_huggingface_url(url: str):
return repo_id, filename, revision


def get_huggingface_model_hash(model_url: str) -> str | None:
def __get_huggingface_model_hash(model_url: str) -> str | None:
with contextlib.suppress(Exception):
repo_id, filename, revision = parse_huggingface_url(model_url)
repo_info = HfApi().model_info(repo_id, revision=revision, files_metadata=True)
Expand All @@ -29,6 +30,15 @@ def get_huggingface_model_hash(model_url: str) -> str | None:
return None


def get_huggingface_model_hash(model_url: str) -> str | None:
for _ in range(5):
r = __get_huggingface_model_hash(model_url)
if r is not None:
return r
sleep(1)
return None


def get_civitai_model_hash(model_url: str) -> str | None:
m = re.search(r"api/download/models/(\d+)", model_url)
if not m:
Expand Down

0 comments on commit 9463a9a

Please sign in to comment.