From c3f5e02e199bc88d2659a795e6beaab640ef028f Mon Sep 17 00:00:00 2001 From: Vladislav Sovrasov Date: Thu, 9 Jan 2025 11:51:33 +0100 Subject: [PATCH] Disable data cache in unit tests (#4174) --- src/otx/core/data/mem_cache.py | 2 +- tests/conftest.py | 2 +- tests/unit/conftest.py | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 tests/unit/conftest.py diff --git a/src/otx/core/data/mem_cache.py b/src/otx/core/data/mem_cache.py index 7d34867fbaa..6f14e359de0 100644 --- a/src/otx/core/data/mem_cache.py +++ b/src/otx/core/data/mem_cache.py @@ -323,7 +323,7 @@ def check_system_memory(cls, mem_size: int, available_cpu_mem: int) -> bool: """Check there is enough system memory to maintain memory caching pool. Parameters: - mem_size: Requested memory size (bytes) for the memory cahcing pool + mem_size: Requested memory size (bytes) for the memory caching pool available_cpu_mem: Memory capacity (bytes) of this system Returns: Return true if there is enough system memory. Otherwise, return false. diff --git a/tests/conftest.py b/tests/conftest.py index 62ca433376d..8bac696329b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -42,7 +42,7 @@ def pytest_addoption(parser: pytest.Parser): action="store", default="all", choices=("speed", "balance", "accuracy", "default", "other", "all"), - help="Choose speed|balcence|accuracy|default|other|all. Defaults to all.", + help="Choose speed|balance|accuracy|default|other|all. Defaults to all.", ) parser.addoption( "--data-group", diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py new file mode 100644 index 00000000000..12a10ba2d3b --- /dev/null +++ b/tests/unit/conftest.py @@ -0,0 +1,17 @@ +# Copyright (C) 2025 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 +# +from __future__ import annotations + +import pytest +from otx.core.data.mem_cache import MemCacheHandlerSingleton + + +@pytest.fixture(autouse=True) +def fxt_disable_mem_cache(): + """Disable mem cache to reduce memory usage.""" + + original_mem_limit = MemCacheHandlerSingleton.CPU_MEM_LIMITS_GIB + MemCacheHandlerSingleton.CPU_MEM_LIMITS_GIB = 99999999 + yield + MemCacheHandlerSingleton.CPU_MEM_LIMITS_GIB = original_mem_limit