mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-08-28 05:25:04 +00:00
Some checks are pending
Pre-commit / run (ubuntu-latest) (push) Waiting to run
Tests ReMe / Unit Tests - py3.11 (push) Waiting to run
Tests ReMe / Unit Tests - py3.12 (push) Waiting to run
Tests ReMe / Unit Tests - py3.13 (push) Waiting to run
Windows Smoke / CLI smoke - py3.11 (push) Waiting to run
* feat(core): add shell command execution and memory status reporting - Introduce ShellStep for executing shell commands with timeout support - Add StatusStep to report memory estimates for stateful data components - Register shell and status commands in default configuration - Update documentation with new reme status and shell command capabilities - Implement comprehensive unit tests for both new step types - Add support for asynchronous command execution with proper error handling * feat(config): add log_config option to suppress config loading logs - Add log_config parameter to resolve_app_config function with default True - Conditionally log config loading messages based on log_config flag - Update reme.py and service_utils.py to use log_config=False for client calls - Suppress config logging in user-facing contexts to avoid output pollution refactor(shell): rename command parameter to cmd for clarity - Change 'command' to 'cmd' in default.yaml configuration schema - Rename 'timeout' to 'shell_timeout' to avoid parameter name collisions - Update ShellStep to accept both legacy and new parameter names - Maintain backward compatibility with existing command/timeout usage test(shell): add comprehensive tests for shell step parameter handling - Add test cases for new cmd and shell_timeout parameter names - Verify legacy command and timeout parameters still work - Test blank command rejection message updated to use cmd - Create integration test for shell parameter payload passing * fix(shell): ensure proper environment loading and process timeout handling - Move load_env() call to execute before parse_args() in main function - Add proper process group killing for timeout scenarios on POSIX systems - Implement recursive child process termination on Windows for proper cleanup - Change parameter name from 'timeout' to 'shell_timeout' in shell execution - Remove support for legacy 'command' and 'timeout' parameter names - Update test cases to verify new timeout behavior and parameter requirements - Add comments explaining component size tracking implementation details
98 lines
3.3 KiB
Python
98 lines
3.3 KiB
Python
"""Tests for the built-in runtime memory status report."""
|
|
|
|
import asyncio
|
|
|
|
from reme.components.application_context import ApplicationContext
|
|
from reme.components.base_component import BaseComponent
|
|
from reme.enumeration import ComponentEnum
|
|
from reme.steps.common.status import (
|
|
StatusStep,
|
|
_collect_memory,
|
|
_component_size,
|
|
)
|
|
|
|
|
|
class _SizedComponent(BaseComponent):
|
|
"""Small component with predictable owned payload for accounting tests."""
|
|
|
|
component_type = ComponentEnum.FILE_STORE
|
|
|
|
def __init__(self, payload: bytes, **kwargs):
|
|
super().__init__(**kwargs)
|
|
self.payload = payload
|
|
self.peer = None
|
|
|
|
|
|
def test_component_size_does_not_charge_referenced_components_twice():
|
|
"""A dependency component is accounted under its own status entry."""
|
|
dependency = _SizedComponent(b"x" * 4096)
|
|
owner = _SizedComponent(b"y")
|
|
owner.peer = dependency
|
|
|
|
owner_size = _component_size(owner)
|
|
dependency_size = _component_size(dependency)
|
|
|
|
assert dependency_size > owner_size
|
|
|
|
|
|
def test_collect_memory_reports_only_stateful_data_components_and_sum(tmp_path):
|
|
"""Status includes only the data components whose state can grow."""
|
|
context = ApplicationContext(workspace_dir=str(tmp_path))
|
|
context.components = {
|
|
ComponentEnum.FILE_STORE: {
|
|
"default": _SizedComponent(b"abc", app_context=context),
|
|
},
|
|
ComponentEnum.AGENT_WRAPPER: {
|
|
"default": _SizedComponent(b"agent", app_context=context),
|
|
},
|
|
ComponentEnum.AS_LLM: {
|
|
"default": _SizedComponent(b"llm", app_context=context),
|
|
},
|
|
ComponentEnum.FILE_CATALOG: {
|
|
"default": _SizedComponent(b"catalog", app_context=context),
|
|
},
|
|
ComponentEnum.FILE_CHUNKER: {
|
|
"default": _SizedComponent(b"chunker", app_context=context),
|
|
},
|
|
ComponentEnum.TOKENIZER: {
|
|
"words": _SizedComponent(b"defgh", app_context=context),
|
|
},
|
|
ComponentEnum.FILE_GRAPH: {
|
|
"default": _SizedComponent(b"graph", app_context=context),
|
|
},
|
|
}
|
|
|
|
memory = _collect_memory(context)
|
|
|
|
assert set(memory["components"]) == {"file_graph", "file_store"}
|
|
assert (
|
|
not {
|
|
"agent_wrapper",
|
|
"as_llm",
|
|
"file_catalog",
|
|
"file_chunker",
|
|
"tokenizer",
|
|
}
|
|
& memory["components"].keys()
|
|
)
|
|
sizes = [usage["bytes"] for group in memory["components"].values() for usage in group.values()]
|
|
assert memory["components_total_bytes"] == sum(sizes)
|
|
assert memory["process_rss_bytes"] > 0
|
|
|
|
|
|
def test_status_step_returns_human_summary_and_exact_metadata(tmp_path):
|
|
"""The public step response serves CLI users and programmatic clients."""
|
|
context = ApplicationContext(workspace_dir=str(tmp_path))
|
|
context.components = {
|
|
ComponentEnum.FILE_STORE: {
|
|
"default": _SizedComponent(b"abc", app_context=context),
|
|
},
|
|
}
|
|
|
|
response = asyncio.run(StatusStep(app_context=context)())
|
|
|
|
assert not response.answer.startswith("ReMe status")
|
|
assert "Memory (estimated component object size)" in response.answer
|
|
assert "file_store:default" in response.answer
|
|
assert "Storage" not in response.answer
|
|
assert set(response.metadata["status"]) == {"memory"}
|