Skip to content

Commit

Permalink
Catch HFH Errors in listing files in repo
Browse files Browse the repository at this point in the history
  • Loading branch information
juhoinkinen committed Mar 4, 2024
1 parent a1e7605 commit 25a46dc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions annif/cli_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,17 @@ def get_selected_project_ids_from_hf_hub(project_ids_pattern, repo_id, token, re

def _list_files_in_hf_hub(repo_id, token, revision):
from huggingface_hub import list_repo_files
from huggingface_hub.utils import HfHubHTTPError, HFValidationError

Check warning on line 305 in annif/cli_util.py

View check run for this annotation

Codecov / codecov/patch

annif/cli_util.py#L304-L305

Added lines #L304 - L305 were not covered by tests

return [
repofile
for repofile in list_repo_files(repo_id=repo_id, token=token, revision=revision)
]
try:
return [

Check warning on line 308 in annif/cli_util.py

View check run for this annotation

Codecov / codecov/patch

annif/cli_util.py#L307-L308

Added lines #L307 - L308 were not covered by tests
repofile
for repofile in list_repo_files(
repo_id=repo_id, token=token, revision=revision
)
]
except (HfHubHTTPError, HFValidationError) as err:
raise OperationFailedException(str(err))

Check warning on line 315 in annif/cli_util.py

View check run for this annotation

Codecov / codecov/patch

annif/cli_util.py#L314-L315

Added lines #L314 - L315 were not covered by tests


def download_from_hf_hub(filename, repo_id, token, revision):
Expand Down

0 comments on commit 25a46dc

Please sign in to comment.