audb icon indicating copy to clipboard operation
audb copied to clipboard

Loading database can fail if a previous version was published in a different repository

Open frankenjoe opened this issue 2 years ago • 0 comments

When loading a database with audb.load() we currently check the repository in which the requested version was found. Loading files from a previous version published in a different repository (which is generally supported), will therefore fail. Here's a minimal example to reproduce the issue:

import audb
import audformat



repo1 = audb.Repository(
    'local',
    'host1',
    'file-system',
)
repo2 = audb.Repository(
    'local',
    'host2',
    'file-system',
)
audb.config.REPOSITORIES = [repo1, repo2]

db = audformat.testing.create_db(minimal=True)
db['table1'] = audformat.Table()
db.save('1.0.0')

audb.publish(
    '1.0.0',
    '1.0.0',
    repo1,
    cache_root='cache',
)

db = audb.load_to(
    '2.0.0',
    db.name,
    cache_root='cache',
    only_metadata=True,
)
db['table2'] = audformat.Table()
db.save('2.0.0')

audb.publish(
    '2.0.0',
    '2.0.0',
    repo2,
    cache_root='cache',
    previous_version='1.0.0',
)

audb.load(db.name)
KeyError: 'db.table1.csv'

To solve the issue we should also check the other repositories of audb.config.REPOSITORIES if a file is not found in the repository of the requested version.

frankenjoe avatar Oct 19 '22 13:10 frankenjoe