-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix dependency table loading from cache (#417)
* Fix dependency table cache for pandas versions * Fix import sort order * Improve text
- Loading branch information
Showing
9 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
venv/ | ||
db.csv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Dependency table pandas compatibility | ||
|
||
Since version 1.7.0 of `audb`, | ||
we use `pyarrow` dtypes | ||
inside the dependency table | ||
(`audb.Dependencies._df`). | ||
The dependency table | ||
is still stored in cache | ||
as a pickle file. | ||
When loading the pickle file | ||
with a different `pandas` version, | ||
than the one used to store the file, | ||
an error related to the `pyarrow` dtypes | ||
might be raised. | ||
|
||
To test this, | ||
we store an example dependency table | ||
from the `emodb` dataset | ||
as pickle file | ||
using different `pandas` versions | ||
as test assests. | ||
|
||
The pickle files, | ||
stored in this folder, | ||
where created by running: | ||
|
||
```bash | ||
$ bash store_dependency_tables.sh | ||
``` |
Binary file not shown.
Binary file not shown.
Binary file not shown.
41 changes: 41 additions & 0 deletions
41
tests/assests/dependency-table-pandas/store_dependency_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import argparse | ||
|
||
import audb | ||
|
||
|
||
def main(pandas_version): | ||
"""Load dependency from CSV and store as PKL file. | ||
Args: | ||
pandas_version: version of installed ``pandas`` package | ||
""" | ||
# Download emodb dependency table | ||
# from version 1.4.1, | ||
# which is still stored as CSV file | ||
repository = audb.Repository( | ||
"data-public", | ||
"https://audeering.jfrog.io/artifactory", | ||
"artifactory", | ||
) | ||
backend_interface = repository.create_backend_interface() | ||
remote_file = backend_interface.join("/", "emodb", "db.zip") | ||
with backend_interface.backend: | ||
backend_interface.get_archive(remote_file, ".", "1.4.1", verbose=False) | ||
|
||
deps = audb.Dependencies() | ||
deps.load("db.csv") | ||
outfile = f"emodb-pandas-{pandas_version}.pkl" | ||
deps.save(outfile) | ||
|
||
|
||
if __name__ == "__main__": | ||
# Call the program with: | ||
# | ||
# $ python store_dependency_table.py 2.2.2 | ||
# | ||
# where 2.2.2 refers to the installed pandas version. | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("pandas_version") | ||
args = parser.parse_args() | ||
main(args.pandas_version) |
17 changes: 17 additions & 0 deletions
17
tests/assests/dependency-table-pandas/store_dependency_tables.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
# | ||
# This stores dependency tables of emodb | ||
# as pickle files | ||
# for different versions of pandas | ||
# to test compatibility | ||
audb_version="1.7.2" | ||
python_version="3.10" | ||
for pandas_version in 2.0.3 2.1.4 2.2.2; do | ||
rm -rf venv | ||
virtualenv -p "python${python_version}" venv | ||
source venv/bin/activate | ||
pip install "audb==${audb_version}" | ||
pip install "pandas==${pandas_version}" | ||
python store_dependency_table.py ${pandas_version} | ||
deactivate | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters