From 49b3765169fa6a4880c1286d626dd881b46f2a7d Mon Sep 17 00:00:00 2001 From: Sebastiaan Huber Date: Mon, 18 Sep 2023 23:56:23 +0200 Subject: [PATCH] Devops: Remove deprecations for v1.0 --- disk_objectstore/container.py | 36 ----------------------------------- disk_objectstore/utils.py | 12 ------------ tests/test_container.py | 21 -------------------- tests/test_deprecations.py | 14 -------------- 4 files changed, 83 deletions(-) diff --git a/disk_objectstore/container.py b/disk_objectstore/container.py index 7bbf080..7ba394e 100644 --- a/disk_objectstore/container.py +++ b/disk_objectstore/container.py @@ -8,7 +8,6 @@ import os import shutil import uuid -import warnings from collections import defaultdict, namedtuple from contextlib import contextmanager from enum import Enum @@ -2301,41 +2300,6 @@ def import_objects( # pylint: disable=too-many-locals,too-many-statements,too-m return old_new_obj_hashkey_mapping - def export( - self, - hashkeys: Sequence[str], - other_container: "Container", - compress: bool = False, - target_memory_bytes: int = 104857600, - callback: Optional[Callable] = None, - ) -> Dict[str, str]: - """Export the specified hashkeys to a new container (must be already initialised). - - ..deprecated:: 0.5 - Deprecated: use the ``import_objects`` method of ``other_container`` instead. Will be removed in 0.6. - - :param hashkeys: an iterable of hash keys. - :param other_container: another Container class into which you want to export the specified hash keys of this - container. - :param compress: specifies if content should be stored in compressed form. - :param target_memory_bytes: how much data to store in RAM before dumping to the new container. Larger values - allow to read and write in bulk that is more efficient, but of course require more memory. - Note that actual memory usage will be larger (SQLite DB, storage of the hashkeys are not included - this - only counts the RAM needed for the object content). Default: 100MB. - - :return: a mapping from the old hash keys (in this container) to the new hash keys (in `other_container`). - """ - warnings.warn( - "function is deprecated, use `import_objects` instead", DeprecationWarning - ) - return other_container.import_objects( - hashkeys=hashkeys, - source_container=self, - compress=compress, - target_memory_bytes=target_memory_bytes, - callback=callback, - ) - # Let us also compute the hash def _validate_hashkeys_pack( # pylint: disable=too-many-locals self, pack_id: int, callback: Optional[Callable] = None diff --git a/disk_objectstore/utils.py b/disk_objectstore/utils.py index 3dc1b03..26f7984 100644 --- a/disk_objectstore/utils.py +++ b/disk_objectstore/utils.py @@ -11,7 +11,6 @@ import itertools import os import uuid -import warnings import zlib from contextlib import contextmanager from enum import Enum @@ -1188,17 +1187,6 @@ def get_hash_cls(hash_type: str) -> Callable: raise ValueError(f"Unknown or unsupported hash type '{hash_type}'") -def get_hash(hash_type: str) -> Callable: - """Return a hash class with an update method and a hexdigest method. - - .. deprecated:: Deprecated since 1.0. Use `get_hash_cls` instead. - """ - warnings.warn( - "`get_hash` is deprecated, use `get_hash_cls` instead", DeprecationWarning - ) - return get_hash_cls(hash_type) - - def _compute_hash_for_file(filepath: Path, hash_type: str) -> str | None: """Return the hash for the given file. diff --git a/tests/test_container.py b/tests/test_container.py index b3ba6a4..dae8841 100644 --- a/tests/test_container.py +++ b/tests/test_container.py @@ -2181,27 +2181,6 @@ def test_import_to_pack( other_container.close() -def test_export_deprecated(temp_container): - """Test that the export_function exists but is deprecated.""" - obj1 = b"111111" - - with tempfile.TemporaryDirectory() as tmpdir: - other_container = Container(tmpdir) - # Use the same hash type - other_container.init_container(clear=True, hash_type=temp_container.hash_type) - - hashkey1 = temp_container.add_object(obj1) - - # Put only two objects - with pytest.warns(DeprecationWarning): - temp_container.export([hashkey1], other_container) - - assert other_container.get_object_content(hashkey1) == obj1 - - # Close before going out, or the test will fail on Windows not being able to delete the folder - other_container.close() - - @pytest.mark.parametrize("compress", [True, False]) def test_validate(temp_container, compress): """Test the validation function.""" diff --git a/tests/test_deprecations.py b/tests/test_deprecations.py index 17b746d..8bf7665 100644 --- a/tests/test_deprecations.py +++ b/tests/test_deprecations.py @@ -1,17 +1,3 @@ """Module to test deprecated functionality. Both to check that they work, but also to ensure full coverage.""" -import pytest - -from disk_objectstore import utils - - -def test_get_hash(): - """Test the get_hash method.""" - hash_type = "sha256" - content = b"523453dfvsd" - with pytest.warns(DeprecationWarning, match="get_hash_cls"): - hasher = utils.get_hash(hash_type=hash_type)() - hasher.update(content) - hashkey = hasher.hexdigest() - assert hashkey == "11c4da82bc95154d2a3116e66c3d49568e4fd0f7184d44a9d611f2749539b7f6"