Skip to content
Draft
Show file tree
Hide file tree
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
18 changes: 4 additions & 14 deletions audb/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ def cached(
if (
define.DEPENDENCY_FILE not in files
and define.LEGACY_DEPENDENCY_FILE not in files
and define.CACHED_DEPENDENCY_FILE not in files
):
# Skip all cache entries
# that don't contain a dependency file
Expand Down Expand Up @@ -293,28 +292,19 @@ def dependencies(
version,
cache_root=cache_root,
)
cached_deps_file = os.path.join(db_root, define.CACHED_DEPENDENCY_FILE)
deps_file = os.path.join(db_root, define.DEPENDENCY_FILE)

with FolderLock(db_root):
try:
deps = Dependencies()
deps.load(cached_deps_file)
deps.load(deps_file)
except Exception: # does not catch KeyboardInterupt
# If loading cached file fails, load again from backend
#
# Loading a cache file can fail
# as we use PyArrow data types,
# which when loading from pickle
# are not compatible between all pandas versions.
# We had originally some tests for it,
# but as the actual failure is not that important,
# we removed them in
# See https://github.com/audeering/audb/pull/507
#
backend_interface = utils.lookup_backend(name, version)
deps = download_dependencies(backend_interface, name, version, verbose)
# Store as pickle in cache
deps.save(cached_deps_file)
# Store in cache
deps.save(deps_file)

return deps

Expand Down
11 changes: 4 additions & 7 deletions audb/core/define.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@
HEADER_FILE = f"{DB}.yaml"

# Dependencies
DEPENDENCY_FILE = f"{DB}.parquet"
DEPENDENCY_FILE = f"{DB}.lance"
r"""Filename and extension of dependency table file."""

CACHED_DEPENDENCY_FILE = f"{DB}.pkl"
r"""Filename and extension of cached dependency table file.
PARQUET_DEPENDENCY_FILE = f"{DB}.parquet"
r"""Filename and extension of parquet dependency table file.

As loading from a pickle file is still faster
than loading from a parquet file,
we are storing the dependency table
as a pickle file in cache.
Used as a backward compatible format for loading older databases.

"""

Expand Down
Loading
Loading