From 8ad89e368a6c4a78d680e500fe4d536a8f8dbeb6 Mon Sep 17 00:00:00 2001 From: Engel Nyst Date: Mon, 24 Feb 2025 16:35:16 +0100 Subject: [PATCH] Small rename to long term memory (#6914) --- .github/workflows/py-unit-tests.yml | 2 +- openhands/memory/__init__.py | 2 +- openhands/memory/{memory.py => long_term_memory.py} | 0 .../unit/{test_memory.py => test_long_term_memory.py} | 10 ++++++---- 4 files changed, 8 insertions(+), 6 deletions(-) rename openhands/memory/{memory.py => long_term_memory.py} (100%) rename tests/unit/{test_memory.py => test_long_term_memory.py} (96%) diff --git a/.github/workflows/py-unit-tests.yml b/.github/workflows/py-unit-tests.yml index f6f6805140..a7dcfb84ac 100644 --- a/.github/workflows/py-unit-tests.yml +++ b/.github/workflows/py-unit-tests.yml @@ -48,7 +48,7 @@ jobs: - name: Build Environment run: make build - name: Run Tests - run: poetry run pytest --forked -n auto --cov=openhands --cov-report=xml -svv ./tests/unit --ignore=tests/unit/test_memory.py + run: poetry run pytest --forked -n auto --cov=openhands --cov-report=xml -svv ./tests/unit --ignore=tests/unit/test_long_term_memory.py - name: Upload coverage to Codecov uses: codecov/codecov-action@v5 env: diff --git a/openhands/memory/__init__.py b/openhands/memory/__init__.py index 89109ea270..7529ea33ec 100644 --- a/openhands/memory/__init__.py +++ b/openhands/memory/__init__.py @@ -1,4 +1,4 @@ from openhands.memory.condenser import Condenser -from openhands.memory.memory import LongTermMemory +from openhands.memory.long_term_memory import LongTermMemory __all__ = ['LongTermMemory', 'Condenser'] diff --git a/openhands/memory/memory.py b/openhands/memory/long_term_memory.py similarity index 100% rename from openhands/memory/memory.py rename to openhands/memory/long_term_memory.py diff --git a/tests/unit/test_memory.py b/tests/unit/test_long_term_memory.py similarity index 96% rename from tests/unit/test_memory.py rename to tests/unit/test_long_term_memory.py index 96c06e0fd4..1845022e02 100644 --- a/tests/unit/test_memory.py +++ b/tests/unit/test_long_term_memory.py @@ -7,7 +7,7 @@ import pytest from openhands.core.config import AgentConfig, LLMConfig from openhands.events.event import Event, EventSource from openhands.events.stream import EventStream -from openhands.memory.memory import LongTermMemory +from openhands.memory.long_term_memory import LongTermMemory from openhands.storage.files import FileStore @@ -154,7 +154,7 @@ def test_load_events_into_index_with_invalid_json( """Test loading events with malformed event data.""" # Simulate an event that causes event_to_memory to raise a JSONDecodeError with patch( - 'openhands.memory.memory.event_to_memory', + 'openhands.memory.long_term_memory.event_to_memory', side_effect=json.JSONDecodeError('Expecting value', '', 0), ): event = _create_action_event('invalid_action') @@ -190,7 +190,8 @@ def test_search_returns_correct_results(long_term_memory: LongTermMemory): MagicMock(get_text=MagicMock(return_value='result2')), ] with patch( - 'openhands.memory.memory.VectorIndexRetriever', return_value=mock_retriever + 'openhands.memory.long_term_memory.VectorIndexRetriever', + return_value=mock_retriever, ): results = long_term_memory.search(query='test query', k=2) assert results == ['result1', 'result2'] @@ -201,7 +202,8 @@ def test_search_with_no_results(long_term_memory: LongTermMemory): mock_retriever = MagicMock() mock_retriever.retrieve.return_value = [] with patch( - 'openhands.memory.memory.VectorIndexRetriever', return_value=mock_retriever + 'openhands.memory.long_term_memory.VectorIndexRetriever', + return_value=mock_retriever, ): results = long_term_memory.search(query='no results', k=5) assert results == []