Skip to content

Commit

Permalink
Devops: Remove deprecations for v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sphuber committed Sep 18, 2023
1 parent aed3d7d commit 98a0ef5
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 83 deletions.
36 changes: 0 additions & 36 deletions disk_objectstore/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions disk_objectstore/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import itertools
import os
import uuid
import warnings
import zlib
from contextlib import contextmanager
from enum import Enum
Expand Down Expand Up @@ -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.
Expand Down
21 changes: 0 additions & 21 deletions tests/test_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
14 changes: 0 additions & 14 deletions tests/test_deprecations.py
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 98a0ef5

Please sign in to comment.