Skip to content

Commit

Permalink
Speed up audb.versions() (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw authored Jan 10, 2024
1 parent e36d548 commit 12ad852
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions audb/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,22 @@ def versions(
vs = []
for repository in config.REPOSITORIES:
backend = utils.access_backend(repository)
header = backend.join('/', name, 'db.yaml')
vs.extend(backend.versions(header, suppress_backend_errors=True))
if isinstance(backend, audbackend.Artifactory):
# Avoid using ls() on Artifactory
# see https://github.com/devopshq/artifactory/issues/423
folder = backend.join('/', name, 'db')
path = audbackend.core.artifactory._artifactory_path(
backend._expand(folder),
backend._username,
backend._api_key,
)
if path.exists():
for p in path:
version = p.parts[-1]
header = p.joinpath(f'db-{version}.yaml')
if header.exists():
vs.extend([version])
else:
header = backend.join('/', name, 'db.yaml')
vs.extend(backend.versions(header, suppress_backend_errors=True))
return audeer.sort_versions(vs)

0 comments on commit 12ad852

Please sign in to comment.