Skip to content

Commit

Permalink
Skip non-registered or non-supported backends (#487)
Browse files Browse the repository at this point in the history
* Skip non-accessible/existing repos

* Adjust test to run under all Python versions
  • Loading branch information
hagenw authored Dec 6, 2024
1 parent c2ac160 commit 883c358
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions audb/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def add_database(name: str, version: str, repository: Repository):
name = path.split("/")[1]
add_database(name, version, repository)

except audbackend.BackendError:
except (audbackend.BackendError, ValueError):
continue

df = pd.DataFrame.from_records(
Expand Down Expand Up @@ -635,7 +635,7 @@ def versions(
suppress_backend_errors=True,
)
)
except audbackend.BackendError:
except (audbackend.BackendError, ValueError):
# If the backend cannot be accessed,
# e.g. host or repository do not exist,
# we skip it
Expand Down
2 changes: 1 addition & 1 deletion audb/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _lookup(
try:
backend_interface = repository.create_backend_interface()
backend_interface.backend.open()
except audbackend.BackendError:
except (audbackend.BackendError, ValueError):
continue

header = backend_interface.join("/", name, "db.yaml")
Expand Down
21 changes: 16 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,22 @@ def test_available(repository):
# Non existing repo
name = "non-existing-repo"
audb.config.REPOSITORIES = [
audb.Repository(
name=name,
host=repository.host,
backend=repository.backend,
)
audb.Repository(name, repository.host, repository.backend)
]
df = audb.available()
assert len(df) == 0

# Non existing backend
audb.config.REPOSITORIES = [
audb.Repository(repository.name, repository.host, "custom")
]
df = audb.available()
assert len(df) == 0

# artifactory backend with non-existing host,
# and non-support under Python>=3.12
audb.config.REPOSITORIES = [
audb.Repository("repo", "https:artifactory.url.com", "artifactory")
]
df = audb.available()
assert len(df) == 0
Expand Down

0 comments on commit 883c358

Please sign in to comment.