diff --git a/audbcards/core/dataset.py b/audbcards/core/dataset.py index 8088e49..2c4965f 100644 --- a/audbcards/core/dataset.py +++ b/audbcards/core/dataset.py @@ -245,14 +245,14 @@ def name(self) -> str: @functools.cached_property def publication_date(self) -> str: r"""Date dataset was uploaded to repository.""" - path = self._backend.join("/", self.name, "db.yaml") - return self._backend.date(path, self._version) + path = self.backend.join("/", self.name, "db.yaml") + return self.backend.date(path, self.version) @functools.cached_property def publication_owner(self) -> str: r"""User who uploaded dataset to repository.""" - path = self._backend.join("/", self.name, "db.yaml") - return self._backend.owner(path, self._version) + path = self.backend.join("/", self.name, "db.yaml") + return self.backend.owner(path, self.version) def properties(self): """Get list of properties of the object.""" @@ -393,8 +393,8 @@ def version(self) -> str: def _load_backend(self) -> audbackend.Backend: r"""Load backend containing dataset.""" backend = audbackend.access( - name=self._repository_object.backend, - host=self._repository_object.host, + name=self.repository_object.backend, + host=self.repository_object.host, repository=self.repository, ) if isinstance(backend, audbackend.Artifactory): diff --git a/tests/requirements.txt b/tests/requirements.txt index dfb4542..0949692 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,2 +1,3 @@ +audb >=1.6.5 # for audb.Dependencies.__eq__() audeer >=1.21.0 pytest diff --git a/tests/test_dataset.py b/tests/test_dataset.py index 4c9836c..e69c5c0 100644 --- a/tests/test_dataset.py +++ b/tests/test_dataset.py @@ -365,3 +365,49 @@ def test_dataset_cache_path(): "emodb-1.2.1.pkl", ) assert cache_path_calculated == cache_path_expected + + +@pytest.mark.parametrize( + "db", + [ + "medium_db", + ], +) +def test_dataset_cache_loading(audb_cache, tmpdir, repository, db, request): + """Test cached properties after loading from cache. + + We no longer store all attributes/properties + in cache as pickle files, + but limit ourselves to the cached properties. + This test ensures, + that other attributes will be re-calculated. + + """ + db = request.getfixturevalue(db) + cache_root = audeer.mkdir(tmpdir, "cache") + dataset = audbcards.Dataset(db.name, pytest.VERSION, cache_root=cache_root) + del dataset + dataset = audbcards.Dataset(db.name, pytest.VERSION, cache_root=cache_root) + deps = audb.dependencies( + db.name, + version=pytest.VERSION, + cache_root=audb_cache, + ) + backend = audbackend.access( + name=repository.backend, + host=repository.host, + repository=repository.name, + ) + # header = audb.info.header( + # db.name, + # version=pytest.VERSION, + # cache_root=audb_cache, + # ) + assert dataset.backend == backend + assert dataset.deps == deps + # Disabled due to potential audformat issue: + # the `files` table cannot be found in cache, + # which is requested when using `load_tables=True` + # in `audb.info.header`. + # assert dataset.header == header + assert dataset.repository_object == repository