Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions voice_validation_api/validation_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,19 @@ def setup_routes(self):
self.app.include_router(self.router)

def repository_exists(self, repo_id: str) -> bool:
try:
self.hf_api.repo_info(repo_id)
return True
except RepositoryNotFoundError:
return False
except GatedRepoError:
return False
except Exception as e:
if self.event_logger_enabled:
self.event_logger.error("hf_repo_error", error=e)
return False
# Retry 3 times while checking repo availability
for retried in range(3):
try:
self.hf_api.repo_info(repo_id)
return True
except Exception as e:
if self.event_logger_enabled:
self.event_logger.error("hf_repo_error", error=e)
# No need to sleep in the 3rd time error
if retried < 2:
time.sleep(retried + 1) # linear growth
# Repo is not public after 3 times retried
return False
@staticmethod
def hash_check(request: EvaluateModelRequest) -> bool:
hash_matches = int(request.hash) == regenerate_hash(
Expand Down Expand Up @@ -349,4 +351,4 @@ def start():
api.start(args.main_api_port)

if __name__ == "__main__":
start()
start()