Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove audbackend.checksum() and use MD5 sum #255

Merged
merged 5 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

import audeer
import audformat

import audbackend

Expand Down Expand Up @@ -83,6 +84,34 @@ def owner(request):
yield owner


@pytest.fixture(scope="function")
def parquet_file(tmpdir):
r"""Provide a parquet file with checksum stored in metadata.

``audformat`` provides the possibility
to store a checksum,
based on the content of a parquet file,
in the metadata of that file.
The motivation is that a parquet file
cannot be written in a deterministic way
and the checksum is a way to track,
if the content has changed.

"""
db = audformat.Database("mydb")
db.schemes["age"] = audformat.Scheme("int")
db["files"] = audformat.Table(audformat.filewise_index(["f1"]))
db["files"]["age"] = audformat.Column(scheme_id="age")
db["files"]["age"].set([40])
path = audeer.path(tmpdir, "files.parquet")
db["files"].save(
audeer.replace_file_extension(path, ""),
storage_format="parquet",
)

yield path


@pytest.fixture(scope="function", autouse=False)
def interface(tmpdir_factory, request):
r"""Create a backend with interface.
Expand Down
20 changes: 20 additions & 0 deletions tests/test_backend_artifactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,23 @@ def test_open_close(host, repository):
audbackend.backend.Artifactory.create(host, repository)
backend.open()
backend.close()


@pytest.mark.parametrize(
"interface",
[(audbackend.backend.Artifactory, audbackend.interface.Maven)],
indirect=True,
)
def test_parquet_file(interface, parquet_file):
"""Test uploading a parquet file with hash in metadata.

We need to make sure to hand the MD5 sum
to the deploy method of Artifactory,
not the checksum hash of the parquet file metadata.
See https://github.com/audeering/audbackend/issues/254.

"""
dst_file = f"/{os.path.basename(parquet_file)}"
version = "1.0.0"
interface.put_file(parquet_file, dst_file, version)
assert interface.exists(dst_file, version)
Loading