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/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% 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`` 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()