From e21451ac07f35526563cdf9434955e5b24130587 Mon Sep 17 00:00:00 2001 From: matveyvarg Date: Mon, 13 Nov 2023 09:54:27 +0100 Subject: [PATCH 1/3] - Parsing simple ints for memory limit --- deker/tools/array.py | 5 +++++ tests/test_cases/test_tools/test_tools.py | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/deker/tools/array.py b/deker/tools/array.py index 9ef340b..5f1f66d 100644 --- a/deker/tools/array.py +++ b/deker/tools/array.py @@ -54,6 +54,11 @@ def convert_human_memory_to_bytes(memory_limit: Union[int, str]) -> int: if isinstance(memory_limit, int): return memory_limit + try: + return int(memory_limit) + except ValueError: + pass + limit, div = memory_limit[:-1], memory_limit.lower()[-1] try: int_limit: int = int(limit) diff --git a/tests/test_cases/test_tools/test_tools.py b/tests/test_cases/test_tools/test_tools.py index 0df3848..a32d607 100644 --- a/tests/test_cases/test_tools/test_tools.py +++ b/tests/test_cases/test_tools/test_tools.py @@ -10,8 +10,8 @@ from tests.parameters.collection_params import CollectionParams from deker.collection import Collection -from deker.errors import DekerInstanceNotExistsError, DekerMemoryError -from deker.tools import check_memory +from deker.errors import DekerInstanceNotExistsError, DekerMemoryError, DekerValidationError +from deker.tools import check_memory, convert_human_memory_to_bytes from deker.tools.time import convert_datetime_attrs_to_iso, convert_iso_attrs_to_datetime @@ -227,5 +227,23 @@ def test_generate_id_raises(array_type_arg): generate_uid(array_type_arg) +@pytest.mark.parametrize( + "params,result,error", + ( + ("1K", 1024, None), + ("1M", 1024**2, None), + ("1G", 1024**3, None), + ("0", 0, None), + ("Foo", None, DekerValidationError), + ), +) +def test_convert_human_to_bytes(params, result, error): + if error: + with pytest.raises(error): + convert_human_memory_to_bytes(params) + else: + assert convert_human_memory_to_bytes(params) == result + + if __name__ == "__main__": pytest.main() From 04516ef3bdefc446f62569fc6bceaa19cc26d869 Mon Sep 17 00:00:00 2001 From: matveyvarg Date: Wed, 15 Nov 2023 19:26:54 +0100 Subject: [PATCH 2/3] typo fix --- docs/deker/installation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deker/installation.rst b/docs/deker/installation.rst index 7141f92..91dcd22 100755 --- a/docs/deker/installation.rst +++ b/docs/deker/installation.rst @@ -36,7 +36,7 @@ Deker depends on the following third-party packages: * ``h5py`` >= 3.8.0 * ``hdf5plugin`` >= 4.0.1 -Also please not that for flexibility few internal Deker components are published as separate +Also please note that for flexibility few internal Deker components are published as separate packages: * ``deker-local-adapters`` From 8a07038c764474ba6f71ecec2ea6391f2f074c56 Mon Sep 17 00:00:00 2001 From: Sergey Rybakov Date: Fri, 17 Nov 2023 12:26:52 +0200 Subject: [PATCH 3/3] fix of varray slice in docs --- docs/deker/collection_schema.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deker/collection_schema.rst b/docs/deker/collection_schema.rst index 00bed2f..8ac1dde 100755 --- a/docs/deker/collection_schema.rst +++ b/docs/deker/collection_schema.rst @@ -104,7 +104,7 @@ with its *zero-index* at the front-left-bottom corner. .. image:: images/varray.png :scale: 30% -Let's query the following slice of it: ``[:, 2:4, :]`` +Let's query the following slice of it: ``[2:4, :, :]`` .. image:: images/varray_request.png :scale: 30%